feat: add issue view with body cleaning and truncation (task 0003) #2

Merged
alexion merged 1 commits from task-0003-issue-view-and-truncation into main 2026-07-11 20:03:30 -04:00
Owner

Implements task 0003 — issue view <n> as the first detail command, introducing the content-cleaning and truncation machinery that later issue and PR slices reuse.

What's in it

  • src/body.ts (new) — cleanBody / truncateBody plus the BODY_TRUNCATE_LIMIT (500) and COMMENT_TRUNCATE_LIMIT (800) constants. Cleaning runs only when a body exceeds its limit, so short bodies pass through byte-for-byte.
  • src/commands/issue.tsissue view <n>: default fields (number, title, state, author, created, body) plus comment_count; --comments expands every comment with no cap; --full suppresses all truncation.
  • src/render.tsrenderDetail, joining the detail entity, optional sub-blocks (comments), and the help block. Shares a private encodeRows helper with renderList.
  • src/cli.ts — top-level help lists issue view.

Behaviour notes

  • cleanBody normalizes Gitea issue/PR URLs on the detected host to Issue#N / PR#N, strips markdown image embeds, removes long URLs, and collapses email-style quoted blocks.
  • Type guard: a PR number fails with VALIDATION_ERROR and a pr view <n> hint, detected via the fetched object's pull_request field.
  • comment_count is emitted only in the default view — with --comments the full block replaces it rather than sitting alongside a redundant scalar (matches gh-axi).
  • The --full suggestion fires whenever the rendered body differs from the raw one (cleaned or truncated), read off the rendered output so it can't drift from truncateBody's own limit decision.

Verification

  • 96 tests pass (29 new: 13 in test/body.test.ts, 16 in test/issue-view.test.ts).
  • Fixture-server tests cover truncation boundaries, cleanBody transforms, --comments, --full, the type guard, and error paths.
  • Typecheck and build clean; branch coverage 89.08%, above the regression threshold.
Implements task 0003 — `issue view <n>` as the first detail command, introducing the content-cleaning and truncation machinery that later issue and PR slices reuse. ## What's in it - **`src/body.ts`** (new) — `cleanBody` / `truncateBody` plus the `BODY_TRUNCATE_LIMIT` (500) and `COMMENT_TRUNCATE_LIMIT` (800) constants. Cleaning runs *only* when a body exceeds its limit, so short bodies pass through byte-for-byte. - **`src/commands/issue.ts`** — `issue view <n>`: default fields (`number`, `title`, `state`, `author`, `created`, `body`) plus `comment_count`; `--comments` expands every comment with no cap; `--full` suppresses all truncation. - **`src/render.ts`** — `renderDetail`, joining the detail entity, optional sub-blocks (comments), and the help block. Shares a private `encodeRows` helper with `renderList`. - **`src/cli.ts`** — top-level help lists `issue view`. ## Behaviour notes - `cleanBody` normalizes Gitea issue/PR URLs on the detected host to `Issue#N` / `PR#N`, strips markdown image embeds, removes long URLs, and collapses email-style quoted blocks. - Type guard: a PR number fails with `VALIDATION_ERROR` and a `pr view <n>` hint, detected via the fetched object's `pull_request` field. - `comment_count` is emitted only in the default view — with `--comments` the full block replaces it rather than sitting alongside a redundant scalar (matches gh-axi). - The `--full` suggestion fires whenever the rendered body differs from the raw one (cleaned *or* truncated), read off the rendered output so it can't drift from `truncateBody`'s own limit decision. ## Verification - 96 tests pass (29 new: 13 in `test/body.test.ts`, 16 in `test/issue-view.test.ts`). - Fixture-server tests cover truncation boundaries, cleanBody transforms, `--comments`, `--full`, the type guard, and error paths. - Typecheck and build clean; branch coverage 89.08%, above the regression threshold.
alexion added 1 commit 2026-07-11 19:36:42 -04:00
feat: add issue view with body cleaning and truncation (task 0003)
All checks were successful
CI / test (pull_request) Successful in 26s
CI / test (push) Successful in 23s
5e66b4d746
Add `issue view <n>` as the first detail command, introducing the
content-cleaning and truncation machinery (src/body.ts) that later issue
and PR slices reuse.

- Default output: number, title, state, author, created, body (truncated
  at 500), plus comment_count; --comments expands every comment (bodies
  truncated at 800); --full suppresses all truncation.
- cleanBody runs only when a body exceeds its limit: normalizes Gitea
  issue/PR URLs on the detected host to Issue#N/PR#N, strips image embeds
  and long URLs, and collapses quoted blocks.
- Type guard: a PR number fails with VALIDATION_ERROR and a `pr view <n>`
  hint, detected via the fetched object's pull_request field.
- renderDetail joins the detail entity, optional sub-blocks, and help.
alexion force-pushed task-0003-issue-view-and-truncation from 3446ce33a5 to 5e66b4d746 2026-07-11 19:36:42 -04:00 Compare
alexion merged commit 5e66b4d746 into main 2026-07-11 20:03:30 -04:00
alexion deleted branch task-0003-issue-view-and-truncation 2026-07-11 20:03:30 -04:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: alexion/gitea-axi#2