refactor(session): tighten cross-session access

This commit is contained in:
Xubin Ren
2026-08-04 12:14:51 +08:00
parent f15ea84dd1
commit 62d34b5eb7
15 changed files with 792 additions and 299 deletions
+38
View File
@@ -3767,4 +3767,42 @@ describe("ThreadShell", () => {
"@obsidian-agent-cli",
);
});
it("offers only same-project sessions in restricted mode", async () => {
const client = makeClient();
const currentScope = {
project_path: "/projects/current",
access_mode: "restricted" as const,
};
const sameProject = {
...session("same-project"),
title: "Same project",
workspaceScope: currentScope,
};
const otherProject = {
...session("other-project"),
title: "Other project",
workspaceScope: {
project_path: "/projects/other",
access_mode: "restricted" as const,
},
};
render(wrap(
client,
<ThreadShell
session={session("current")}
sessions={[sameProject, otherProject]}
title="Current"
onToggleSidebar={() => {}}
workspaceScope={currentScope}
/>,
));
const input = await screen.findByLabelText("Message input");
fireEvent.change(input, { target: { value: "@", selectionStart: 1 } });
expect(screen.getByRole("option", { name: /Same project/i })).toBeInTheDocument();
expect(screen.queryByRole("option", { name: /Other project/i })).not.toBeInTheDocument();
});
});