Skip to content

fix(review): resolve quick PR targets safely - #1478

Merged
akramcodez merged 9 commits into
Nano-Collective:mainfrom
puri-adityakumar:feat/1287-quick-fixes
Oct 12, 2026
Merged

akramcodez merged 9 commits into
Nano-Collective:mainfrom
puri-adityakumar:feat/1287-quick-fixes

Conversation

@puri-adityakumar

@puri-adityakumar puri-adityakumar commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

This PR is part of a stacked series for #1287: Q (this PR) → Foundation → Grounded default → Deep → Headless. They merge in that order (plan). This PR doesn't close the issue on its own.

Overview

/review quick is the fast review: one model call with the diff in the prompt, no tools, no agents. When I tested it from my fork, it couldn't find upstream PRs, printed the review as raw Markdown, and diffed against a stale local main. This PR fixes those problems and keeps quick review one-shot.

  • PR lookup works from a fork. My origin is my fork, so /review quick 1478 couldn't find the upstream PR, and PR URLs weren't accepted. It now checks each configured remote and its fork parent, and takes a full PR URL as given. If a number exists in more than one repo, it asks for the URL instead of guessing. A remote with a repo's old name (like Mote-Software/nanocoder) counts as the same repo, and a stale remote that returns 404 is skipped.

  • Clear scope and strict arguments. The output should say what was reviewed, and a typo shouldn't cost a model call. The reply now starts with the review scope and says how much of a long diff was left out. Extra arguments give a usage error without calling the model, and the slash command is echoed in the chat.

  • The review renders like a chat reply. It used to print as plain green text with raw ## and ** marks. It now uses the normal assistant message: model name, parsed Markdown, collapsed reasoning, and the usage footer.

    Before After
    Before: green raw Markdown After: rendered assistant message
  • Branch reviews use the right base. With no target, the diff was taken against local main. My local main was 315 commits behind upstream, so the review got 38,274 diff lines instead of this PR's 9 files. The base is now the branch's open PR base, then a remote pointing at the fork's parent, then upstream, then origin, and only then local main (with a warning). The scope line names the base and its commit.

    Before After
    Before: against local main, 38,274 lines After: against upstream/main, 1,145 lines
  • Lookups always go to github.com. If GH_HOST points at GitHub Enterprise, gh sent the PR lookups there. The calls are now pinned to github.com.

Try it

/review quick 1478
/review https://github.com/Nano-Collective/nanocoder/pull/1478
/review quick              # current branch against its upstream base
/review quick 42 extra     # usage error, no model call

Testing

  • New unit tests for each fix. The rendering test fails on the old code. The base-branch tests cover 7 cases.
  • review.spec.tsx, app-util.spec.ts, and lazy-registry.spec.ts pass (112 tests)
  • Format, lint, types, knip, and build pass
  • Full local suite: no new failures. The only failures come from my local git hook or also happen on main.
  • Checked by hand in the TUI, 10 scenarios (report with screenshots)
  • Last full CI run (6b777bb1) passed
  • CI on the latest commit: cancelled by a GitHub Actions outage, needs a re-run

Findings

  • In a fork with only origin, the diff is only as fresh as the fork's main. The command warns and prints the command to add the parent repo. It never fetches on its own.
  • Long diffs are still cut to the first and last 500 lines, and the output says how many were skipped.
  • Quick review has no tools by design. The grounded review comes in the next PR of the stack.

@github-actions github-actions Bot added area:tui Terminal UI area:docs Documentation labels Sep 24, 2026
@puri-adityakumar

Copy link
Copy Markdown
Contributor Author

The latest CI run on 5dac18cd didn't actually test anything. GitHub's Actions outage on Oct 5 (incident) meant 11 jobs never got a runner and were cancelled after 15 minutes. The 5 jobs that did start (lint, knip, VS Code extension, Linux sandbox, labeller) passed, and the last full run, at 6b777bb1, was green.

@will-lamerton, could you click "Re-run failed jobs" on the PR checks and changeset check runs when you get a chance? I don't have permission to re-run them myself.

@puri-adityakumar
puri-adityakumar marked this pull request as ready for review October 6, 2026 17:23
@akramcodez akramcodez closed this Oct 8, 2026
@akramcodez akramcodez reopened this Oct 8, 2026
@akramcodez
akramcodez requested a review from addyCooks as a code owner October 8, 2026 05:26
@akramcodez

Copy link
Copy Markdown
Member

/re-review

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

nc-review: comments — 2 important, 3 nits

@puri-adityakumar — a few things worth a look, none blocking.

Fixes /review quick for fork/upstream PR resolution and explicit URLs, adds echo-invocation for /review, and renders the result through the normal AssistantMessage component so Markdown is parsed instead of printed raw green text. The diff is well-scoped (one feature, no drive-by), the new logic is tested across seven scenarios with new state-handling tests, and a changeset is present.

🟠 important · tests · source/commands/review.spec.tsx

The truncation test asserts the user-prompt wording (Partial diff coverage / first 500 and last 500 of 1100 diff lines) but the production code in getTruncationNotice returns first ${Math.ceil(1000/2)} and last ${Math.floor(1000/2)} — i.e. first 500 and last 500 of 1100 diff lines (1000 lines total) — and then reports 1100 − 500 − 500 = 100 intervening lines were omitted. The omitted count is correct, but the existing userPrompt assertion userMessage.includes('first and last 500 of 1100 lines') was kept alongside the new output text assertions. With both old and new strings on the prompt, the test is no longer pointing at the actual code — if getTruncationNotice regressed to the old phrasing the original assertion still passes, and if it regressed to nothing the new assertion would catch it. Drop the legacy t.true(userMessage.includes('diff truncated')) / t.true(userMessage.includes('first and last 500 of 1100 lines')) assertions so the test is anchored to the live code rather than satisfied by either wording.

🟠 important · correctness · source/commands/review.ts

metadata.model is threaded from the built-in command handler, but the new AssistantMessage call here passes model: metadata.model while the chat path that ships usage is the buildResponseUsageBounded(response.usage, metadata.model) call. If response.usage is undefined but reply?.content is non-empty (a real possibility for some providers), the component still renders with usage={undefined} and model={metadata.model}, which is correct. However the surrounding code in source/hooks/chat-handler/conversation/conversation-loop.tsx reads showUsageFooter and uses it to decide whether to compute responseUsage. This PR does the same and gates only the cost computation, not the message itself, which matches the conversation-loop pattern. No bug — flagging for the record because the diff is doing a fair amount of small awaits and any future change to AssistantMessageProps.usage would need to be matched here.

⚪ nit · tests · source/app/utils/app-util.spec.ts

The new TUI /review quick runs a one-shot review test installs a commandRegistry.get('review')-shaped command and is responsible for restoring it in finally, but it specifically only restores when originalReview is truthy. If a prior test ever left the registry in a state with no entry for review, the cleanup if (originalReview) commandRegistry.register(originalReview) is a no-op, which would leak the registered mock into subsequent tests. AVA is serial so this won't currently fail, but a hard t.teardown(() => commandRegistry.register(originalReview ?? defaultReviewCommand)) (or t.registerCleanup) is the standard pattern in this codebase and would make the test safe to reorder.

⚪ nit · correctness · source/commands/review.ts

parseReviewTarget strips a leading quick but only the first occurrence. /review quick quick 42 parses as the branch quick against whatever resolveReviewBase returns, and then the trailing 42 is silently dropped after args.slice(1). Compare with REVIEW_USAGE which says "Pass exactly one target" — the validator only fires for the post-strip args. Worth either treating repeated quick as the usage error, or having REVIEW_USAGE say it explicitly. Minor.

⚪ nit · tests · source/commands/review.spec.tsx

The new createGitHubFixture is generous with how it interprets args[3] ?? args[2] ?? '' for remote get-url — git remote get-url -- NAME is the real argv, so args[3] after -- is correct. The fallback args[2] would silently accept git remote get-url origin (no --), which is more permissive than git accepts. The fixture isn't contract-bearing but downstream tests rely on every gh invocation carrying --hostname github.com; this permissive fallback won't break anything because arguments[2] is the remote name in either form. Leave it as is, or tighten it for clarity.


🔴 blocking · 🟠 a reviewer would ask for a change · ⚪ optional

Automated code review — correctness, security, design, tests, plus duplicates and scope. A human still decides; this is not a substitute for review and is not exhaustive. The required status checks separately cover lint, formatting, types, unused dependencies, the test suite and the build. This bot never merges. Maintainers can rerun with /re-review.

@github-actions github-actions Bot added the agent:comments nc-review left non-blocking findings label Oct 8, 2026
@puri-adityakumar

Copy link
Copy Markdown
Contributor Author

Thanks for the review. I went through each point against the code, and I don't think any of them needs a change:

  1. Truncation test "keeps legacy assertions". Those assertions aren't in the test. It only checks the current wording: Partial diff coverage and first 500 and last 500 of 1100 diff lines in the prompt, plus the rendered "100 intervening lines were omitted" notice (source/commands/review.spec.tsx:805-813). If the notice changed or disappeared, the test would fail.
  2. model / usage on AssistantMessage. As the comment says, there's no bug here. It follows the same pattern as the normal chat path.
  3. The test mock "can leak" into later tests. review is always registered by commandRegistry.registerLazy(lazyCommands) at the top of the spec (app-util.spec.ts:1152), so commandRegistry.get('review') always returns the original command and the finally block always puts it back. The case where there is no original command can't happen here.
  4. /review quick quick 42 "silently drops 42". It doesn't. Only the first quick is removed, which leaves two arguments, and two arguments return the usage error (source/commands/review.ts:95-99). Nothing is dropped and no review runs.
  5. The fixture accepts remote get-url without --. That's true, but production always passes ['remote', 'get-url', '--', name] (review.ts:210-215), so every test exercises the real form. I'll leave it as is, as suggested.

I also ran my own review of the diff and found no issues. The review and app-util specs pass (112 tests), and CI is green on all checks. I updated the changeset so the release note also covers the rendering fix and the upstream base for branch reviews.

From my side, this is ready to merge. @akramcodez @will-lamerton, could you take a look when you get a chance?

@akramcodez
akramcodez merged commit 549593d into Nano-Collective:main Oct 12, 2026
17 checks passed
@akramcodez

Copy link
Copy Markdown
Member

Thanks for the PR @puri-adityakumar

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

Labels

agent:comments nc-review left non-blocking findings area:docs Documentation area:tui Terminal UI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants