Skip to content

feat(trail): show the description and a browser URL in trail show#1476

Open
khaong wants to merge 1 commit into
mainfrom
feat/trail-show-intent-and-url
Open

feat(trail): show the description and a browser URL in trail show#1476
khaong wants to merge 1 commit into
mainfrom
feat/trail-show-intent-and-url

Conversation

@khaong

@khaong khaong commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

https://entire.io/gh/entireio/cli/trails/616

What

entire trail show now renders the two things missing from it:

  1. The trail description / intent — fetched from the detail endpoint (trail.body_document.text_snapshot), which the list endpoint omits. This is the same content the web UI shows at the top of the trail page (the collaborative body editor).
  2. A browser URL for the trail (BaseURL()/gh/<owner>/<repo>/trails/<number>; the web app is co-hosted with the data API).

Notes

  • body_document is nested under trail in the detail response (not top-level); fetchTrailDetail decodes only trail + body_document, so it's unaffected by the checkpoints/thread shapes. A regression test pins the nested path.
  • The detail fetch is best-effort: the core metadata already came from the list lookup, so a detail-fetch failure warns to stderr and still prints metadata + URL (degrades to "no description"; falls back to found.Body).
  • No URL/description for number-less trails (the detail endpoint is keyed by the integer number).

Testing

  • TestTrailWebURL (incl. trailing-slash dedup), TestFetchTrailDetail_ReadsNestedBodyDocument (httptest; nested-body path + ignores the checkpoints array), TestPrintTrailDetailsRendersURLAndDescription (URL + Description render; empty/whitespace omitted).
  • Verified live: entire trail show <n> now prints the Description + URL.
  • gofmt clean; golangci-lint 0 issues.
  • Reviewed via pr-review-toolkit (code / tests / silent-failure); findings addressed.

Tracked by Entire trail #616.

🤖 Generated with Claude Code


Note

Low Risk
Read-only CLI display and an extra GET on trail show; metadata still comes from list lookup and detail failures degrade gracefully.

Overview
entire trail show now prints a browser URL (from the API base + forge/owner/repo/trails/number) and the trail description from the detail API’s trail.body_document.text_snapshot, which the list response does not include.

After the usual list lookup, the command best-effort calls the per-number detail endpoint via new fetchTrailDescription; failures warn on stderr but still show metadata and the URL. Descriptions use a Description block instead of inline Body; empty loaded descriptions show -- no description provided --. Trails without a number skip URL and description fetch.

TrailResource gains optional BodyDocument / TrailBodyDocument types for JSON decoding. Tests cover URL building, display helpers, nested body decode, and output formatting.

Reviewed by Cursor Bugbot for commit 1db9051. Configure here.

@khaong khaong requested a review from a team as a code owner June 19, 2026 06:36
Copilot AI review requested due to automatic review settings June 19, 2026 06:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates entire trail show to enrich its output with a browser URL and a fuller “Description” pulled from the trail detail endpoint, aligning the CLI output with what the web UI shows.

Changes:

  • Enrich trail show output with a web URL and multi-line Description (best-effort detail fetch; warnings on failure).
  • Add a minimal detail fetch helper that decodes the nested trail.body_document.text_snapshot.
  • Extend API types and add tests for URL construction, nested-body decoding, and output rendering.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
cmd/entire/cli/trail_cmd.go Adds best-effort detail fetch, web URL generation, and renders a Description block in trail show.
cmd/entire/cli/trail_cmd_test.go Adds tests covering URL building, nested body_document decode, and updated show output formatting.
cmd/entire/cli/api/trail_types.go Extends TrailResource with BodyDocument / TrailBodyDocument for detail decoding.

Comment thread cmd/entire/cli/trail_cmd.go Outdated
@khaong khaong force-pushed the feat/trail-show-intent-and-url branch 3 times, most recently from cbffb34 to 2630d3e Compare June 19, 2026 07:51
@khaong

khaong commented Jun 19, 2026

Copy link
Copy Markdown
Contributor Author

bugbot run

Comment thread cmd/entire/cli/trail_cmd.go
@khaong khaong force-pushed the feat/trail-show-intent-and-url branch from 2630d3e to 1db9051 Compare June 19, 2026 10:44
@khaong

khaong commented Jun 19, 2026

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

1 issue from previous review remains unresolved.

Fix All in Cursor

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 1db9051. Configure here.

'entire trail show' now fetches the trail detail and renders the
description (trail.body_document.text_snapshot, which the list endpoint
omits) plus a browser URL (BaseURL/gh/<owner>/<repo>/trails/<number>; the
web app is co-hosted with the data API). Adds trailWebURL and
fetchTrailDetail, and a body_document field on TrailResource. Unit tests
cover the URL builder and the nested-body decode (the field is under
trail.body_document, not top-level).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Soph

Soph commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

The PR description says detail-fetch failure "degrades to 'no description'; falls back to found.Body", but the code does not implement that fallback.

On a detail-fetch failure, descriptionLoaded stays false and bodyText stays "", so trailDescriptionForDisplay("", false) returns "" and nothing is rendered. The same happens for number-less trails (found.Number == 0), where the whole enrich block is skipped.

Since the old Body: line was removed, both degraded paths now show no body at all — even though found.Body (from the list lookup) is already in hand. This is a regression for those paths versus the previous behavior.

Suggested fix — seed from found.Body and let the detail response supersede it on success:

m := found.ToMetadata()
bodyText := found.Body          // start from the list body
descriptionLoaded := found.Body != ""
if found.Number > 0 {
    webURL = trailWebURL(...)
    if bt, derr := fetchTrailDescription(...); derr == nil {
        bodyText = bt           // detail supersedes when it succeeds
        descriptionLoaded = true
    } else {
        fmt.Fprintf(errW, "Warning: could not load trail description: %v\n", derr)
    }
}

This matches the PR description and improves both the failure and number-less paths. (If dropping the list body on failure is actually intended, the PR description should be corrected instead.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants