Skip to content

Commit a50f510

Browse files
fix(workspace): the menu and boot box never pair a binding with another account
The menu brackets its binding read with two account reads. The boot box clears when either read names another account, and never shows lines without one. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_0172qrhMa5TQgETASi5hxMqD
1 parent 102fd5e commit a50f510

3 files changed

Lines changed: 19 additions & 11 deletions

File tree

‎packages/opencode/src/altimate/workspace/welcome-lines.ts‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,12 @@ export function nextWelcomeState(
112112
now?: number
113113
},
114114
): WelcomeState {
115-
const base =
116-
prev.scope !== null && read.scopeBefore !== null && read.scopeBefore !== prev.scope
117-
? { lines: null, scope: null }
118-
: prev
119-
if (read.scopeAfter !== read.scopeBefore) return base
115+
// Either read naming another account proves the lines shown are not this one's.
116+
const another = (scope: string | null) => prev.scope !== null && scope !== null && scope !== prev.scope
117+
const base = another(read.scopeBefore) || another(read.scopeAfter) ? { lines: null, scope: null } : prev
118+
// Nothing new without one known account across the pass: lines with no scope
119+
// could never be recognised as another account's and cleared.
120+
if (read.scopeBefore === null || read.scopeAfter !== read.scopeBefore) return base
120121
const lines = welcomeLinesFor(read.outcome, read.snapshot, read.now)
121122
return lines ? { lines, scope: read.scopeBefore } : base
122123
}

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import {
4040
} from "@/altimate/workspace/workspace-name"
4141
import { currentAttachSnapshot } from "@/altimate/workspace/attach-snapshot"
4242
import {
43+
accountScope,
4344
loadStatusView,
4445
menuStatusLine,
4546
rowLine,
@@ -79,7 +80,6 @@ import {
7980
accountDigest,
8081
credentialDigest,
8182
readLocalBinding,
82-
readLocalBindingScoped,
8383
recordApprovedBinding,
8484
resolvePinnedBindingForRouting,
8585
} from "@/altimate/workspace/state"
@@ -2274,12 +2274,17 @@ function capped(lines: { key: string; note: string }[], max: number): { key: str
22742274

22752275
/** The `/workspace` menu. */
22762276
export async function runWorkspaceManage(api: TuiPluginApi, directory: string): Promise<void> {
2277+
// The Status row and view match the last attach on scope as well as id: the
2278+
// same id under another account is another workspace. Two account reads
2279+
// bracket the binding read; if they differ, the binding cannot be paired with
2280+
// either, and Status matches nothing rather than another account's attach.
2281+
const scopeBefore = await accountScope()
22772282
const report = await Manage.status(directory)
2283+
const scopeAfter = await accountScope()
22782284
const linked = report.binding !== null
2279-
// The Status row and view match the last attach on scope as well as id: the
2280-
// same id under another tenant is another workspace.
2281-
const { scope } = await readLocalBindingScoped(directory).catch(() => ({ scope: null }))
2282-
const bound: BoundWorkspace | null = report.binding ? { scope, datamateId: report.binding.datamateId } : null
2285+
const bound: BoundWorkspace | null = report.binding
2286+
? { scope: scopeBefore === scopeAfter ? scopeBefore : null, datamateId: report.binding.datamateId }
2287+
: null
22832288
// Resolved before render, like AlreadyLinkedDialog's: an option appearing after
22842289
// paint would shift the row under the user's cursor.
22852290
// Under an IDE pin, skills, memory and routing follow the pinned workspace, so Open must too.

‎packages/opencode/test/altimate/workspace/welcome-lines.test.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,11 @@ describe("nextWelcomeState: one refresh of the box", () => {
112112
["same account, unknown: left as it is", shown, A, unknown, A, "kept"],
113113
["another account, unknown: the old account's lines go", shown, B, unknown, B, "cleared"],
114114
["another account, resolved: the new account's lines", shown, B, bound, B, "new"],
115-
["account moved during the pass: dropped, nothing paired", shown, A, bound, B, "kept"],
115+
["moved to another account during the pass: the old lines go, nothing committed", shown, A, bound, B, "cleared"],
116116
["moved to another account during the pass: cleared, nothing committed", shown, B, bound, A, "cleared"],
117117
["credentials unreadable this instant: not another account", shown, null, unknown, null, "kept"],
118+
["a binding resolved with no readable account: not shown without a scope", shown, null, bound, null, "kept"],
119+
["first pass with no readable account: nothing shown yet", { lines: null, scope: null }, null, bound, null, "kept"],
118120
["first pass, resolved", { lines: null, scope: null }, A, bound, A, "new"],
119121
])("%s", (_label, prev, scopeBefore, outcome, scopeAfter, expected) => {
120122
const next = nextWelcomeState(prev, { scopeBefore, outcome, snapshot: undefined, scopeAfter })

0 commit comments

Comments
 (0)