Skip to content

Commit 1d715c6

Browse files
sahrizviclaude
andcommitted
fix(workspace): v0.12.4 release PR review — attach-path wording, portable tests
- The "not found" message after linking or re-linking now fits both paths: the chosen workspace may be gone (attach), or the project's link to it (re-link). It no longer sends an attach user to "pick Create". TUI picker, TUI inline attach, and `altimate-code link`. - `state.ts`: the `pinned` comment no longer claims the field is unused; `identity.ts` reads it, and no write-permission check keys on it. - `release-v0.12.4-adversarial.test.ts`: pass `""` for "no password" (an `undefined` argument selects the environment's `OPENCODE_SERVER_PASSWORD`), and build snapshot-path expectations from the platform's root and separator so the file passes on Windows. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018fJ3X7pcGT4R9yzjsJnqsV
1 parent 6af88f4 commit 1d715c6

4 files changed

Lines changed: 39 additions & 30 deletions

File tree

‎packages/opencode/src/altimate/workspace/state.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ export interface CachedBinding {
8282
* off anything that claims it on disk. Callers use it to tell an explicit,
8383
* user-made selection apart from a binding the server volunteered.
8484
*
85-
* No production consumer yet. `memory-sync` deliberately mirrors to adopted bindings too: a
85+
* `identity.ts` reads it to describe a pinned session; no write-permission check keys on it.
86+
* `memory-sync` deliberately mirrors to adopted bindings too: a
8687
* project belongs to exactly one workspace, so a teammate's clone of a linked project is
8788
* working in that workspace and its new memory belongs there. What an adopted binding does
8889
* NOT get without the user's say-so is the bulk backfill of memory saved before the link was

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,7 @@ async function bindOrRebind(
786786
} else if (err instanceof PreconditionFailedError) {
787787
prompts.log.error("Someone else re-linked this project — re-run and try again.")
788788
} else if (err instanceof NotFoundError) {
789-
prompts.log.error("This project's link to that workspace no longer exists. Re-run and pick again.")
789+
prompts.log.error("That workspace, or this project's link to it, no longer exists. Re-run and pick again.")
790790
} else if (err instanceof ForbiddenError) {
791791
prompts.log.error("Only the workspace owner can attach projects to it.")
792792
} else {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,7 @@ function PickerDialog(props: PickerProps) {
912912
} else if (err instanceof PreconditionFailedError) {
913913
msg = "Someone else re-linked this project — reload and try again."
914914
} else if (err instanceof NotFoundError) {
915-
msg = "This project's link to that workspace no longer exists. Re-run `altimate-code link` and pick Create."
915+
msg = "That workspace, or this project's link to it, no longer exists. Re-run `altimate-code link` and pick again."
916916
} else if (err instanceof ForbiddenError) {
917917
msg = "Only the workspace owner can attach projects to it."
918918
} else {
@@ -1109,7 +1109,7 @@ export async function bindOrRebindInline(
11091109
} else if (err instanceof PreconditionFailedError) {
11101110
msg = "Someone else re-linked this project — reload and try again."
11111111
} else if (err instanceof NotFoundError) {
1112-
msg = "This project's link to that workspace no longer exists. Try again."
1112+
msg = "That workspace, or this project's link to it, no longer exists. Try again."
11131113
} else if (err instanceof ForbiddenError) {
11141114
msg = "Only the workspace owner can attach projects to it."
11151115
} else {

‎packages/opencode/test/skill/release-v0.12.4-adversarial.test.ts‎

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -32,65 +32,73 @@ import { Server } from "../../src/server/server"
3232
import { WORKSPACE_PILOT_OFF_MESSAGE } from "../../src/cli/cmd/workspace-pilot"
3333

3434
const SNAP = path.join(".altimate-code", "skill", "_workspace")
35+
// Native absolute paths, so the expectations hold on Windows (drive-qualified, `\\`) as on POSIX.
36+
const ROOT = path.parse(process.cwd()).root
37+
const abs = (...parts: string[]) => path.join(ROOT, ...parts)
38+
const P = abs("p")
3539

3640
describe("v0.12.4 adversarial: snapshot attribution by path segments", () => {
3741
test("a traversal out of the snapshot is not attributed to it", () => {
38-
// Resolves to /p/.altimate-code/evil — no `_workspace` segment survives.
39-
expect(snapshotProjectOf(`/p/${SNAP}/../../evil/SKILL.md`)).toBeNull()
42+
// Resolves to <root>/p/.altimate-code/evil — no `_workspace` segment survives.
43+
expect(snapshotProjectOf(`${P}${path.sep}${SNAP}${path.sep}..${path.sep}..${path.sep}evil${path.sep}SKILL.md`)).toBeNull()
4044
})
4145

4246
test("a traversal INTO the snapshot is attributed after resolution", () => {
43-
expect(snapshotProjectOf(`/p/x/../${SNAP}/a/SKILL.md`)).toBe("/p")
47+
expect(snapshotProjectOf(`${P}${path.sep}x${path.sep}..${path.sep}${SNAP}${path.sep}a${path.sep}SKILL.md`)).toBe(P)
4448
})
4549

4650
test("lookalike segments are not a snapshot", () => {
47-
expect(snapshotProjectOf("/p/.altimate-code/skill/_workspace2/a/SKILL.md")).toBeNull()
48-
expect(snapshotProjectOf("/p/.altimate-code-x/skill/_workspace/a/SKILL.md")).toBeNull()
49-
expect(snapshotProjectOf("/p/.altimate-code/skills/_workspace/a/SKILL.md")).toBeNull()
50-
expect(snapshotProjectOf("/p/_workspace/skill/.altimate-code/a/SKILL.md")).toBeNull()
51+
expect(snapshotProjectOf(abs("p", ".altimate-code", "skill", "_workspace2", "a", "SKILL.md"))).toBeNull()
52+
expect(snapshotProjectOf(abs("p", ".altimate-code-x", "skill", "_workspace", "a", "SKILL.md"))).toBeNull()
53+
expect(snapshotProjectOf(abs("p", ".altimate-code", "skills", "_workspace", "a", "SKILL.md"))).toBeNull()
54+
expect(snapshotProjectOf(abs("p", "_workspace", "skill", ".altimate-code", "a", "SKILL.md"))).toBeNull()
5155
})
5256

53-
test("a project opened at the filesystem root is `/`, not 'no project'", () => {
54-
expect(snapshotProjectOf(`/${SNAP}/a/SKILL.md`)).toBe("/")
57+
test("a project opened at the filesystem root is the root, not 'no project'", () => {
58+
const result = snapshotProjectOf(abs(SNAP, "a", "SKILL.md"))
59+
expect(result).not.toBeNull()
60+
expect(path.resolve(result!)).toBe(path.resolve(ROOT))
5561
})
5662

5763
test("nested snapshots attribute to the outermost project", () => {
58-
expect(snapshotProjectOf(`/p/${SNAP}/q/${SNAP}/a/SKILL.md`)).toBe("/p")
64+
expect(snapshotProjectOf(abs("p", SNAP, "q", SNAP, "a", "SKILL.md"))).toBe(P)
5965
})
6066

6167
test("isWithin refuses a prefix sibling and a parent", () => {
62-
expect(isWithin("/proj", "/proj2/SKILL.md")).toBe(false)
63-
expect(isWithin("/proj", "/")).toBe(false)
64-
expect(isWithin("/proj", "/proj")).toBe(true)
65-
expect(isWithin("/proj", "/proj/a/../b")).toBe(true)
66-
expect(isWithin("/proj", "/proj/../proj2")).toBe(false)
68+
expect(isWithin(P, abs("p2", "SKILL.md"))).toBe(false)
69+
expect(isWithin(P, ROOT)).toBe(false)
70+
expect(isWithin(P, P)).toBe(true)
71+
expect(isWithin(P, `${P}${path.sep}a${path.sep}..${path.sep}b`)).toBe(true)
72+
expect(isWithin(P, `${P}${path.sep}..${path.sep}p2`)).toBe(false)
6773
})
6874
})
6975

7076
describe("v0.12.4 adversarial: snapshotCopyYields type confusion", () => {
71-
const match = `/proj/${SNAP}/pub-1/SKILL.md`
77+
const PROJ = abs("proj")
78+
const match = abs("proj", SNAP, "pub-1", "SKILL.md")
79+
const own = abs("proj", ".claude", "skills", "x", "SKILL.md")
7280

7381
test("non-string or relative existing locations never make the workspace copy yield", () => {
7482
for (const existing of [undefined, null, 0, 1, {}, [], true, "builtin:x", "<built-in>", "relative/SKILL.md", ""]) {
75-
expect(snapshotCopyYields(match, existing as unknown, "/proj")).toBe(false)
83+
expect(snapshotCopyYields(match, existing as unknown, PROJ)).toBe(false)
7684
}
7785
})
7886

7987
test("no project root means no protection", () => {
80-
expect(snapshotCopyYields(match, "/proj/.claude/skills/x/SKILL.md", undefined)).toBe(false)
81-
expect(snapshotCopyYields(match, "/proj/.claude/skills/x/SKILL.md", "")).toBe(false)
88+
expect(snapshotCopyYields(match, own, undefined)).toBe(false)
89+
expect(snapshotCopyYields(match, own, "")).toBe(false)
8290
})
8391

8492
test("only a project skill inside the root wins over the workspace copy", () => {
85-
expect(snapshotCopyYields(match, "/proj/.claude/skills/x/SKILL.md", "/proj")).toBe(true)
86-
expect(snapshotCopyYields(match, "/proj2/.claude/skills/x/SKILL.md", "/proj")).toBe(false)
87-
expect(snapshotCopyYields(match, "/home/me/.claude/skills/x/SKILL.md", "/proj")).toBe(false)
93+
expect(snapshotCopyYields(match, own, PROJ)).toBe(true)
94+
expect(snapshotCopyYields(match, abs("proj2", ".claude", "skills", "x", "SKILL.md"), PROJ)).toBe(false)
95+
expect(snapshotCopyYields(match, abs("home", "me", ".claude", "skills", "x", "SKILL.md"), PROJ)).toBe(false)
8896
// Another snapshot entry is not the user's own skill.
89-
expect(snapshotCopyYields(match, `/proj/${SNAP}/pub-2/SKILL.md`, "/proj")).toBe(false)
97+
expect(snapshotCopyYields(match, abs("proj", SNAP, "pub-2", "SKILL.md"), PROJ)).toBe(false)
9098
})
9199

92100
test("a non-snapshot match never yields, whatever it collides with", () => {
93-
expect(snapshotCopyYields("/proj/.claude/skills/y/SKILL.md", "/proj/.claude/skills/x/SKILL.md", "/proj")).toBe(false)
101+
expect(snapshotCopyYields(abs("proj", ".claude", "skills", "y", "SKILL.md"), own, PROJ)).toBe(false)
94102
})
95103
})
96104

@@ -228,9 +236,9 @@ describe("v0.12.4 adversarial: workspace route gate", () => {
228236
})
229237

230238
test("an origin on an unsecured server is refused; a native client is not", () => {
231-
expect(Server.workspaceRouteRefusal("http://127.0.0.1:4096", "127.0.0.1:4096", undefined)?.status).toBe(403)
239+
// "" rather than undefined: undefined selects the default, the environment's server password.
232240
expect(Server.workspaceRouteRefusal("http://127.0.0.1:4096", "127.0.0.1:4096", "")?.status).toBe(403)
233-
expect(Server.workspaceRouteRefusal(undefined, "127.0.0.1:4096", undefined)).toBeUndefined()
241+
expect(Server.workspaceRouteRefusal(undefined, "127.0.0.1:4096", "")).toBeUndefined()
234242
})
235243

236244
test("with a password, malformed and lookalike origins are refused", () => {

0 commit comments

Comments
 (0)