vscode: clickable #N / PR #N references in terminals - #1418
Merged
Conversation
Plan for clickable #N / PR #N terminal references in the VS Code extension.
Add IssueRefTerminalLinkProvider claiming #N and PR #N spans; resolve via the existing openPRInBrowser / openIssueInBrowser / codev.viewBacklogIssue paths. Bare #N discriminates issue vs PR by the resolved url (/pull/ vs /issues/), since gh issue view resolves PR numbers too. New setting codev.terminalLinks.issueTarget (editor|browser, default editor).
… open Wrap resolution in a status-bar withProgress so a click gives instant feedback, and open the discriminator's already-resolved url directly (openExternal) on the PR-fallthrough and browser-issue paths instead of re-fetching via a helper. Bare #N is now a single forge round-trip except the in-editor preview, whose fetch renders the content.
…test header Consultation (all APPROVE) flagged two stale-text nits: the plan still labeled the shipped openExternal approach 'rejected', and the test header claimed three helper modules are stubbed. Text-only.
amrmelsayed
added a commit
that referenced
this pull request
Aug 12, 2026
amrmelsayed
added a commit
that referenced
this pull request
Aug 12, 2026
amrmelsayed
added a commit
that referenced
this pull request
Aug 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PIR Review: Clickable
#N/PR #Nterminal references (VS Code)Fixes #1412
Summary
Architect and builder terminal output constantly cites issues and PRs by number, but Cmd+click on those spans fell through to VS Code's workspace word-search (which matches nothing). This PR registers a
TerminalLinkProviderthat claims#NandPR #Nspans and opens them:PR #N→ the PR's forge page in the browser; a bare#N→ the in-editor issue viewer by default (or the browser, per a newcodev.terminalLinks.issueTargetsetting), falling through to the PR page when the number turns out to be a PR. Claiming the span also suppresses VS Code's useless fallback search.Files Changed
apps/vscode/src/commands/open-terminal-ref.ts(+97 / -0) — new; click resolution (issue-vs-PR discriminator, setting, progress spinner)apps/vscode/src/terminal-link-provider.ts(+44 / -0) — newIssueRefTerminalLinkProvider(span detection)apps/vscode/src/extension.ts(+9 / -1) — register the provider beside the two existing onesapps/vscode/package.json(+10 / -0) —codev.terminalLinks.issueTargetsettingapps/vscode/src/__tests__/terminal-ref-link-provider.test.ts(+168 / -0) — new; detection + resolution routing testscodev/resources/lessons-learned.md(+1) — thegh issue viewPR-discriminator lessonCommits
9017f4d58[PIR vscode: TerminalLinkProvider — make #N / PR #N references in terminals clickable (issue viewer / browser) #1412] Clickable #N / PR #N terminal referencesa561c0001[PIR vscode: TerminalLinkProvider — make #N / PR #N references in terminals clickable (issue viewer / browser) #1412] Tests: terminal ref detection and resolution routingcb12cab64[PIR vscode: TerminalLinkProvider — make #N / PR #N references in terminals clickable (issue viewer / browser) #1412] Add click feedback + drop redundant fetch on terminal ref openee6dea3f1[PIR vscode: TerminalLinkProvider — make #N / PR #N references in terminals clickable (issue viewer / browser) #1412] Reword issueTarget setting: drop internal 'bare #N' jargonTest Results
pnpm compile(check-types + lint + esbuild): ✓ pass (0 type errors; 1 pre-existingtunnel.tslint warning, not from this change)pnpm test:unit: ✓ pass (807 tests, 13 new in this file)build,tests): ✓ passdev-approvalgate): Cmd+click#Nopens the in-editor issue viewer;PR #Nopens the browser PR page; a bare number that is a PR falls through to the browser; theissueTarget: browsersetting flips bare#Nto the browser. A first pass felt unresponsive (~2s, no feedback); fixed with a progress spinner + single forge round-trip, then re-verified. Wording of the setting description was tightened at the human's request.Architecture Updates
No arch changes. This adds a self-contained terminal link provider plus a resolution module inside the existing
apps/vscode/structure — no module boundaries, invariants, ports, or state paths are affected, and it reuses the existing forge-fetch/open paths (getIssue,openPRInBrowser,codev.viewBacklogIssue) rather than introducing a new one. Not a HOT arch-critical fact; nothing durable to route to COLDarch.md.Lessons Learned Updates
Routed one COLD lesson to
codev/resources/lessons-learned.md(near the[From 787]multi-forge contract lesson):gh issue view <PR#>resolves a PR number (exit 0,.../pull/Nurl) rather than failing — so issue-vs-PR must be discriminated on the resolved url path (/pull/vs/issues/), not on fetch-failure, and the singlegetIssuecall should do double duty (discriminator + url-to-open) rather than triggering a second round-trip. Not HOT: it's a GitHub-forge-narrow recipe, not a behavior-changing cross-cutting rule (it reinforces the existing HOT "verify API behavior empirically" lesson rather than replacing it).Things to Look At During PR Review
open-terminal-ref.ts,/\/pull\/\d/test onissue.url). This is the crux:gh issue viewresolves PR numbers too, so fetch-failure is not the discriminator — the resolved url path is. Verified empirically (gh issue view 1405on a merged PR returns exit 0 with a/pull/url). If the forge supplies nourl(non-GitHub), the code degrades to the issue path; v1 targets GitHub.resolveRef). The first cut funneled every open throughopenPRInBrowser/openIssueInBrowserfor a single owner per destination, which meant bare#Ndid two forge round-trips (discriminator + helper re-fetch) and felt unresponsive. The current code opens the url the discriminator already resolved (openExternal) for the PR-fallthrough and browser-issue paths — no new fetch code, but a PR can now be browser-opened by two code paths (explicitPR #NviaopenPRInBrowser, and the bare-#N-is-a-PR fallthrough viaopenExternal). The in-editor issue preview still fetches once to render its content.terminal-link-provider.ts). The/(?<pr>\bPR\s+)?#(?<num>\d+)/giis built insideprovideTerminalLinks, not shared at module scope — the VS Code d.ts warns the method may be re-entered before a prior call resolves, and a shared/gregex'slastIndexwould race. (The siblingBuilderTerminalLinkProvideruses the module-scope pattern; this one deliberately does not.)executeCommand('codev.viewBacklogIssue', N)rather than importingviewBacklogIssuedirectly, becauseview-issue.tsinstantiates avscode.EventEmittersingleton at module load, which broke a sibling test that loads the provider with a barevscodemock. Same indirectionopen-issue-by-id.tsalready uses.How to Test Locally
pir-1412→ Review Diffafx dev pir-1412#1412→ in-editor issue preview (defaulteditor)PR #1405→ browser opens.../pull/1405#1405) → browser opens the PR page (fallthrough)codev.terminalLinks.issueTarget: browser, Cmd+click#1412→ browser opens the issuesee #12 and PR #34) → both are individually clickable