Skip to content

Commit 789ff74

Browse files
sahrizviclaude
andcommitted
fix: address multi-model review findings on #1274 — dialog selection race, missing CLI URL fallback, unit tests
- `workspace.tsx`: fix a real selection-desync race in `AlreadyLinkedDialog`. `manageUrl` was fetched async inside the dialog via `onMount`, so the options array could grow from 3 to 4 items ("Open in browser" inserted at index 2, pushing "Skip for now" to 3) after the dialog had already painted. dialog-select.tsx's `store.selected` is a raw numeric index, and the only effect that resyncs it fires on `props.current`/`store.filter` changes — not on the options array changing shape. A user who pressed Down twice to reach "Skip for now" before the promise resolved could press Enter and launch a browser instead. Fixed by resolving `manageUrl` in the caller (`runFlow`) before `dialog.replace()`, matching the synchronous-prop pattern `WorkspaceLinkedDialog`/`showLinkedConfirmation` already use — `AlreadyLinkedDialog` no longer has any async state. - `cli/cmd/link.ts`: print the plain manage URL as a `prompts.log.info` fallback when `terminalSupportsHyperlinks()` is false — previously a non-allowlisted terminal had no way to discover the URL at all (the OSC 8 bytes are invisible there), unlike the TUI side which falls back to a copyable toast on open() failure. - `cli/cmd/link.ts`: guard `hyperlink()` against an empty `text` (would otherwise emit an invisible zero-width clickable region). - `workspace-sidebar.tsx`: scope the sidebar tile's click target to just the name line — "(pinned via --workspace)" now renders on its own non-interactive line instead of being appended inside the clickable `<text>` block, and `onMouseUp` is omitted entirely (not attached as a no-op) until a manage URL actually resolves. - Add `test/cli/cmd/link.test.ts` — unit coverage for the four pure helpers introduced in this PR (`stripControlChars`, `terminalSupportsHyperlinks`, `buildManageUrl`, `hyperlink`), including the control-character-injection and URL-join regressions directly. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JsVwcBQP6VUwqEej3vK2zG
1 parent c4e9901 commit 789ff74

4 files changed

Lines changed: 236 additions & 45 deletions

File tree

‎packages/opencode/src/cli/cmd/link.ts‎

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const SET_UP_IN_BROWSER_SENTINEL = "__browser_handoff__"
4949
* prematurely close our hyperlink and open a spoofed one pointing wherever
5050
* they choose, with our trusted URL as the visible (but inert) prefix.
5151
* (CodeRabbit + cubic, PR #1274.) */
52-
function stripControlChars(text: string): string {
52+
export function stripControlChars(text: string): string {
5353
// C0 (\x00-\x1f) + DEL (\x7f) + C1 (\x80-\x9f) — the previous range only
5454
// covered C0/DEL, leaving C1 controls unstripped. ESC (the OSC 8 breakout
5555
// vector) was always covered, but the doc comment claimed C1 coverage it
@@ -75,7 +75,7 @@ function stripControlChars(text: string): string {
7575
* left off the list rather than guessing the user is on a current-enough
7676
* macOS. (Kilo, PR #1274 — corrects an earlier version of this list that
7777
* included it.) */
78-
function terminalSupportsHyperlinks(): boolean {
78+
export function terminalSupportsHyperlinks(): boolean {
7979
if (!process.stdout.isTTY) return false
8080
if (process.env.TERM === "dumb" || process.env.TERM === "linux") return false
8181
const termProgram = process.env.TERM_PROGRAM
@@ -94,7 +94,7 @@ function terminalSupportsHyperlinks(): boolean {
9494
* its own path/query/fragment (e.g. a local dev server), and naive
9595
* concatenation would land ``/w/<id>`` inside the query string instead of the
9696
* path — clears search/hash for the same reason. (CodeRabbit + cubic, PR #1274.) */
97-
function buildManageUrl(base: URL, workspaceId: number): string {
97+
export function buildManageUrl(base: URL, workspaceId: number): string {
9898
const u = new URL(base)
9999
u.pathname = `${u.pathname.replace(/\/+$/, "")}/w/${workspaceId}`
100100
u.search = ""
@@ -113,8 +113,8 @@ function buildManageUrl(base: URL, workspaceId: number): string {
113113
* code — emitting it unconditionally would make the name look clickable in
114114
* terminals where it isn't, so it's gated on ``terminalSupportsHyperlinks``
115115
* (cubic, PR #1274). */
116-
function hyperlink(text: string, url: string | null): string {
117-
if (!url) return text
116+
export function hyperlink(text: string, url: string | null): string {
117+
if (!url || !text) return text
118118
const safeText = stripControlChars(text)
119119
const OSC8 = "\x1b]8;;"
120120
const ST = "\x1b\\"
@@ -217,6 +217,16 @@ export const LinkCommand = cmd({
217217
// case the name below prints as plain (non-clickable) text.
218218
const currentManageUrl =
219219
currentId !== undefined && workspaceWebBase ? buildManageUrl(workspaceWebBase, currentId) : null
220+
// On a terminal `terminalSupportsHyperlinks()` doesn't recognize, the
221+
// OSC 8 wrapping below is invisible bytes and the name renders as plain
222+
// text with no indication a URL exists at all — unlike the TUI, which
223+
// falls back to a toast ("Could not open browser. Copy this URL: ...").
224+
// Print the plain URL once as a fallback the terminal can't hide, rather
225+
// than leaving it unreachable outside the allowlist. (multi-model
226+
// review, PR #1274.)
227+
if (currentManageUrl && !terminalSupportsHyperlinks()) {
228+
prompts.log.info(`Manage it at: ${currentManageUrl}`)
229+
}
220230

221231
const options: Array<{ value: string; label: string; hint?: string }> = [
222232
// Only offer browser handoff for UNLINKED projects (CodeRabbit cycle 5).

‎packages/opencode/src/plugin/tui/altimate/workspace-sidebar.tsx‎

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -100,40 +100,41 @@ function View(props: { api: TuiPluginApi }) {
100100
{/* Clicking the name (or the URL line below) opens the workspace
101101
* in the browser — the manage URL is deterministic from tenant
102102
* + id (see resolveManageBase above), so there's no extra
103-
* round-trip before it's clickable. The whole line is the
104-
* click target (mouse events only land on block-level
105-
* `<text>`/`<box>`, not inline `<span>`/`<a>` nodes), while only
106-
* the name itself is styled to look like a link — matching the
107-
* footer's community/docs links (sidebar/footer.tsx), which use
108-
* the same span-style + onMouseUp pair because raw `<a href>`
109-
* hyperlink nodes crash in this JSX layer. */}
110-
<text
111-
fg={theme().textMuted}
112-
onMouseUp={() => {
113-
const url = manageUrl()
114-
if (url) openManageUrl(props.api, url)
115-
}}
116-
>
103+
* round-trip before it's clickable. The whole line is the click
104+
* target (mouse events only land on block-level `<text>`/`<box>`,
105+
* not inline `<span>`/`<a>` nodes), while only the name itself
106+
* is styled to look like a link — matching the footer's docs/
107+
* community links (sidebar/footer.tsx), which use the same
108+
* span-style + onMouseUp pair because raw `<a href>` hyperlink
109+
* nodes crash in this JSX layer. ``onMouseUp`` is omitted
110+
* entirely (not just a no-op) when there's no URL yet, so the
111+
* name never advertises a click target that does nothing. The
112+
* "pinned via --workspace" hint lives on its own line below
113+
* (rather than appended inline here) so the click region
114+
* doesn't extend over text that isn't part of the link — same
115+
* reasoning as the URL line already being separate. (multi-model
116+
* review, PR #1274.) */}
117+
<text fg={theme().textMuted} onMouseUp={manageUrl() ? () => openManageUrl(props.api, manageUrl()!) : undefined}>
117118
<Show when={manageUrl()} fallback={b().datamateName}>
118119
{(_u) => <span style={{ fg: theme().accent, underline: true }}>{b().datamateName}</span>}
119120
</Show>
120-
{/* ``pinned via --workspace`` means "this SESSION was launched
121-
* with --workspace and it resolved to this id". It does NOT
122-
* mean "the current binding was set by --workspace" — if the
123-
* user relinks mid-session to a different workspace, the pin
124-
* disappears (id mismatch); if they relink to the same id,
125-
* the pin correctly stays because the launch fact is
126-
* unchanged. Known imprecision: relink-to-same-id looks
127-
* indistinguishable from "never relinked". Accepted per
128-
* altimate-harness-bot round 8 (option b of the review).
129-
* ``getResolvedWorkspaceId`` returns null when the launch
130-
* had no --workspace flag or the flag failed to resolve,
131-
* so the pin never falsely appears for a session that
132-
* wasn't launched with the flag. */}
133-
<Show when={getResolvedWorkspaceId() === b().datamateId}>
134-
{" (pinned via --workspace)"}
135-
</Show>
136121
</text>
122+
{/* ``pinned via --workspace`` means "this SESSION was launched
123+
* with --workspace and it resolved to this id". It does NOT
124+
* mean "the current binding was set by --workspace" — if the
125+
* user relinks mid-session to a different workspace, the pin
126+
* disappears (id mismatch); if they relink to the same id,
127+
* the pin correctly stays because the launch fact is
128+
* unchanged. Known imprecision: relink-to-same-id looks
129+
* indistinguishable from "never relinked". Accepted per
130+
* altimate-harness-bot round 8 (option b of the review).
131+
* ``getResolvedWorkspaceId`` returns null when the launch
132+
* had no --workspace flag or the flag failed to resolve,
133+
* so the pin never falsely appears for a session that
134+
* wasn't launched with the flag. */}
135+
<Show when={getResolvedWorkspaceId() === b().datamateId}>
136+
<text fg={theme().textMuted}>(pinned via --workspace)</text>
137+
</Show>
137138
<Show when={manageUrl()}>
138139
{(u) => (
139140
<text fg={theme().textMuted} onMouseUp={() => openManageUrl(props.api, u())}>

‎packages/opencode/src/plugin/tui/altimate/workspace.tsx‎

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,9 @@ interface AlreadyLinkedProps {
652652
hasDrift: boolean
653653
driftedWas?: string | null
654654
unverified?: boolean
655+
/** Pre-resolved by the caller — see ``AlreadyLinkedDialog``'s comment for
656+
* why this must not be fetched async inside the dialog itself. */
657+
manageUrl: string | null
655658
/** Which identifier arm resolved the binding — remote-matched projects
656659
* rebind via ``/by-remote``, path-matched via ``/by-path``. Not the same
657660
* as ``identifier.repoRemote`` / ``identifier.projectPath``, which reflect
@@ -661,13 +664,20 @@ interface AlreadyLinkedProps {
661664
}
662665

663666
function AlreadyLinkedDialog(props: AlreadyLinkedProps) {
664-
// Best-effort — same deterministic tenant+id derivation as buildManageUrl's
665-
// other callers. null on BYOK/unresolvable, in which case the "Open in
666-
// browser" option below is simply omitted.
667-
const [manageUrl, setManageUrl] = createSignal<string | null>(null)
668-
onMount(async () => {
669-
setManageUrl(await buildManageUrl(props.workspaceId))
670-
})
667+
// ``manageUrl`` is a plain prop, resolved by the caller (``runFlow``)
668+
// BEFORE this dialog is shown — not fetched async in an onMount here.
669+
// dialog-select.tsx's ``store.selected`` is a raw numeric index, and
670+
// nothing re-syncs it when ``props.options`` changes shape (the only
671+
// effect that resyncs selection fires on `props.current`/`store.filter`
672+
// changes, not on the options array). Options here start at 3 items and
673+
// conditionally grow to 4 when "Open in browser" becomes available — if
674+
// that insertion landed asynchronously after the dialog painted, a user
675+
// who already pressed Down to reach "Skip for now" (index 2) would find
676+
// Enter now submits "Open in browser" instead, since the array grew out
677+
// from under a stale index. Keeping this component fully synchronous
678+
// (matching ``WorkspaceLinkedDialog``'s ``manageUrl`` prop, resolved via
679+
// ``showLinkedConfirmation`` before render) removes the moving target
680+
// instead of trying to resync around it. (multi-model review, PR #1274.)
671681

672682
// Title carries the primary context (workspace name + drift/unverified hint)
673683
// since DialogSelect doesn't take a top-level description block. Verbose but
@@ -699,7 +709,7 @@ function AlreadyLinkedDialog(props: AlreadyLinkedProps) {
699709
description: "Swap this project's workspace.",
700710
},
701711
]
702-
if (manageUrl()) {
712+
if (props.manageUrl) {
703713
opts.push({
704714
title: "Open in browser",
705715
value: "open",
@@ -724,8 +734,7 @@ function AlreadyLinkedDialog(props: AlreadyLinkedProps) {
724734
return
725735
}
726736
if (option.value === "open") {
727-
const url = manageUrl()
728-
if (url) openManageUrl(props.api, url)
737+
if (props.manageUrl) openManageUrl(props.api, props.manageUrl)
729738
// Stay open — opening the browser isn't a decision about the link
730739
// itself, so the user can still Attach/Re-link/Skip afterward.
731740
return
@@ -1145,6 +1154,9 @@ async function runFlow(api: TuiPluginApi, directory: string): Promise<void> {
11451154
const currentIdent =
11461155
serverBinding.matchedBy === "remote" ? identifier.repoRemote : identifier.projectPath
11471156
const hasDrift = boundIdent != null && currentIdent != null && boundIdent !== currentIdent
1157+
// Resolved before the dialog renders — see AlreadyLinkedDialog's comment
1158+
// on why this can't be fetched async inside the dialog itself.
1159+
const manageUrl = await buildManageUrl(serverBinding.datamate.id)
11481160
api.ui.dialog.replace(() => (
11491161
<AlreadyLinkedDialog
11501162
api={api}
@@ -1154,6 +1166,7 @@ async function runFlow(api: TuiPluginApi, directory: string): Promise<void> {
11541166
matchedBy={serverBinding!.matchedBy}
11551167
hasDrift={hasDrift}
11561168
driftedWas={hasDrift ? boundIdent : undefined}
1169+
manageUrl={manageUrl}
11571170
/>
11581171
))
11591172
return
@@ -1183,6 +1196,7 @@ async function runFlow(api: TuiPluginApi, directory: string): Promise<void> {
11831196
const currentIdent =
11841197
cachedMatchedBy === "remote" ? identifier.repoRemote : identifier.projectPath
11851198
const hasDrift = cachedIdent !== "" && currentIdent != null && cachedIdent !== currentIdent
1199+
const manageUrl = await buildManageUrl(local.datamateId)
11861200
api.ui.dialog.replace(() => (
11871201
<AlreadyLinkedDialog
11881202
api={api}
@@ -1192,6 +1206,7 @@ async function runFlow(api: TuiPluginApi, directory: string): Promise<void> {
11921206
matchedBy={cachedMatchedBy}
11931207
hasDrift={hasDrift}
11941208
driftedWas={hasDrift ? cachedIdent : undefined}
1209+
manageUrl={manageUrl}
11951210
unverified
11961211
/>
11971212
))
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
// altimate_change - new file
2+
// Unit coverage for the pure-logic helpers in
3+
// packages/opencode/src/cli/cmd/link.ts that back the `altimate-code link`
4+
// picker's clickable-workspace-name affordance: control-char sanitization,
5+
// terminal capability detection, URL joining, and the OSC 8 wrapper itself.
6+
// The interactive `@clack/prompts` flow (LinkCommand.handler) needs a TTY
7+
// and is covered by manual verification (PR #1274), not here.
8+
import { afterEach, beforeEach, describe, expect, test } from "bun:test"
9+
import { buildManageUrl, hyperlink, stripControlChars, terminalSupportsHyperlinks } from "../../../src/cli/cmd/link"
10+
11+
describe("stripControlChars", () => {
12+
test("removes C0 control bytes including ESC", () => {
13+
expect(stripControlChars("a\x1bb\x00c")).toBe("abc")
14+
})
15+
16+
test("removes DEL and C1 control bytes", () => {
17+
expect(stripControlChars("a\x7fb\x9fc\x80d")).toBe("abcd")
18+
})
19+
20+
test("neutralizes an embedded OSC 8 sequence into inert text", () => {
21+
const malicious = "name\x1b]8;;http://evil.example\x1b\\CLICK ME\x1b]8;;\x1b\\"
22+
const sanitized = stripControlChars(malicious)
23+
expect(sanitized).not.toContain("\x1b")
24+
// The literal (non-ESC) bytes survive as inert text — only the escape
25+
// bytes that would make it a live control sequence are stripped.
26+
expect(sanitized).toBe("name]8;;http://evil.example\\CLICK ME]8;;\\")
27+
})
28+
29+
test("leaves ordinary printable text untouched", () => {
30+
expect(stripControlChars("Rakuten Analytics Pipeline")).toBe("Rakuten Analytics Pipeline")
31+
})
32+
})
33+
34+
describe("terminalSupportsHyperlinks", () => {
35+
const ORIGINAL_ENV = { ...process.env }
36+
const ORIGINAL_TTY = process.stdout.isTTY
37+
38+
beforeEach(() => {
39+
for (const key of ["TERM", "TERM_PROGRAM", "WT_SESSION", "KONSOLE_VERSION", "VTE_VERSION"]) {
40+
delete process.env[key]
41+
}
42+
})
43+
44+
afterEach(() => {
45+
process.env = { ...ORIGINAL_ENV }
46+
Object.defineProperty(process.stdout, "isTTY", { value: ORIGINAL_TTY, configurable: true })
47+
})
48+
49+
function setTTY(value: boolean) {
50+
Object.defineProperty(process.stdout, "isTTY", { value, configurable: true })
51+
}
52+
53+
test("false when stdout is not a TTY, regardless of TERM_PROGRAM", () => {
54+
setTTY(false)
55+
process.env.TERM_PROGRAM = "iTerm.app"
56+
expect(terminalSupportsHyperlinks()).toBe(false)
57+
})
58+
59+
test("false for TERM=dumb or TERM=linux even on a TTY", () => {
60+
setTTY(true)
61+
process.env.TERM = "dumb"
62+
expect(terminalSupportsHyperlinks()).toBe(false)
63+
process.env.TERM = "linux"
64+
expect(terminalSupportsHyperlinks()).toBe(false)
65+
})
66+
67+
test("true for known-supporting TERM_PROGRAM values", () => {
68+
setTTY(true)
69+
for (const program of ["iTerm.app", "WezTerm", "Hyper", "vscode", "ghostty", "Tabby", "rio"]) {
70+
process.env.TERM_PROGRAM = program
71+
expect(terminalSupportsHyperlinks()).toBe(true)
72+
}
73+
})
74+
75+
test("false for Apple_Terminal — OSC 8 support can't be inferred from TERM_PROGRAM alone", () => {
76+
setTTY(true)
77+
process.env.TERM_PROGRAM = "Apple_Terminal"
78+
expect(terminalSupportsHyperlinks()).toBe(false)
79+
})
80+
81+
test("true when WT_SESSION is set (Windows Terminal)", () => {
82+
setTTY(true)
83+
process.env.WT_SESSION = "some-guid"
84+
expect(terminalSupportsHyperlinks()).toBe(true)
85+
})
86+
87+
test("true when KONSOLE_VERSION is set", () => {
88+
setTTY(true)
89+
process.env.KONSOLE_VERSION = "220400"
90+
expect(terminalSupportsHyperlinks()).toBe(true)
91+
})
92+
93+
test("VTE_VERSION >= 5000 (>= 0.50.0) is supported, below it is not", () => {
94+
setTTY(true)
95+
process.env.VTE_VERSION = "5000"
96+
expect(terminalSupportsHyperlinks()).toBe(true)
97+
process.env.VTE_VERSION = "4800"
98+
expect(terminalSupportsHyperlinks()).toBe(false)
99+
})
100+
101+
test("false with no recognized signal at all", () => {
102+
setTTY(true)
103+
expect(terminalSupportsHyperlinks()).toBe(false)
104+
})
105+
})
106+
107+
describe("buildManageUrl", () => {
108+
test("appends /w/<id> to a bare origin", () => {
109+
expect(buildManageUrl(new URL("https://tenant.ws.myaltimate.com"), 4242)).toBe(
110+
"https://tenant.ws.myaltimate.com/w/4242",
111+
)
112+
})
113+
114+
test("joins via pathname, not string concatenation, when the base carries a query/fragment", () => {
115+
// The dev-only ALTIMATE_WORKSPACE_WEB_URL override can be an arbitrary
116+
// URL (e.g. a local dev server) — naive `toString() + "/w/id"`
117+
// concatenation would land the path inside the query string instead.
118+
const url = buildManageUrl(new URL("http://localhost:3003/base?x=1#frag"), 42)
119+
expect(url).toBe("http://localhost:3003/base/w/42")
120+
})
121+
122+
test("normalizes a trailing slash on the base path", () => {
123+
expect(buildManageUrl(new URL("https://host/base/"), 7)).toBe("https://host/base/w/7")
124+
})
125+
})
126+
127+
describe("hyperlink", () => {
128+
const ORIGINAL_ENV = { ...process.env }
129+
const ORIGINAL_TTY = process.stdout.isTTY
130+
131+
afterEach(() => {
132+
process.env = { ...ORIGINAL_ENV }
133+
Object.defineProperty(process.stdout, "isTTY", { value: ORIGINAL_TTY, configurable: true })
134+
})
135+
136+
test("returns text unchanged when url is null", () => {
137+
expect(hyperlink("anas-skill-test", null)).toBe("anas-skill-test")
138+
})
139+
140+
test("wraps text in OSC 8 with no underline when the terminal isn't recognized", () => {
141+
Object.defineProperty(process.stdout, "isTTY", { value: false, configurable: true })
142+
const out = hyperlink("anas-skill-test", "https://tenant.ws.myaltimate.com/w/4242")
143+
expect(out).toBe("\x1b]8;;https://tenant.ws.myaltimate.com/w/4242\x1b\\anas-skill-test\x1b]8;;\x1b\\")
144+
expect(out).not.toContain("\x1b[4m")
145+
})
146+
147+
test("wraps text in OSC 8 plus underline when the terminal is recognized as supporting", () => {
148+
Object.defineProperty(process.stdout, "isTTY", { value: true, configurable: true })
149+
process.env.TERM_PROGRAM = "iTerm.app"
150+
const out = hyperlink("anas-skill-test", "https://tenant.ws.myaltimate.com/w/4242")
151+
expect(out).toBe(
152+
"\x1b]8;;https://tenant.ws.myaltimate.com/w/4242\x1b\\\x1b[4manas-skill-test\x1b[24m\x1b]8;;\x1b\\",
153+
)
154+
})
155+
156+
test("sanitizes an adversarial name so it cannot open a second, spoofed link", () => {
157+
Object.defineProperty(process.stdout, "isTTY", { value: false, configurable: true })
158+
const malicious = "name\x1b]8;;http://evil.example\x1b\\CLICK ME\x1b]8;;\x1b\\"
159+
const out = hyperlink(malicious, "https://tenant.ws.myaltimate.com/w/4242")
160+
// Exactly one real OSC 8 open + one real OSC 8 close — the malicious
161+
// payload's own OSC 8 bytes were stripped, leaving only inert text.
162+
expect(out.split("\x1b]8;;").length - 1).toBe(2)
163+
expect(out).toContain("name]8;;http://evil.example\\CLICK ME]8;;\\")
164+
})
165+
})

0 commit comments

Comments
 (0)