feat(workspaces): accept ~ paths and name as alias in workspace.add
The console's open dialog advertises `~/Workspace/...` and sends `name`, but the daemon only accepted an absolute `cwd` and only read `alias`, so the most likely first action failed with a generic `E_BAD_REQUEST` and the typed name vanished. `add()` now expands `~`/`~/…` against the store's home before the absolute-path check (a leading `~user` stays an error, and the message names both accepted forms), and `workspace.add` treats `name` as an alias when `alias` is absent, answering `workspaceId` so a client does not need a follow-up list call. feat(cli): tell users when pi2.nvim cannot host a spawned instance `checkPlugin` only looked for `lua/pi/web/bridge.lua`, so a checkout that can drive an existing nvim but cannot be spawned reported `ok` and the failure surfaced later as an unexplained "did not say hello". The probe now also requires `lua/pi/host.lua`: both present is `ok`, bridge only is `warn` with the update hint, neither is `fail`. `pi2 daemon --help` lists the instance knobs (`PI2_NVIM_BIN`, `PI2_NVIM_INIT`, `PI2_PLUGIN_DIR`, `PI2_ENSURE_TIMEOUT_MS`) it previously kept to itself. MSG2
This commit is contained in:
1 parent
db387ae248
commit
85faacb0ba
4 files changed
+80
-8
No files matched your search
@@ -281,6 +281,37 @@ describe("workspace store", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("expands ~ and ~/… against the store's home before the allowlist check", async () => {
|
||||
const home = join(allowRoot, "home");
|
||||
const project = join(home, "project");
|
||||
mkdirSync(project, { recursive: true });
|
||||
const { store, registry } = setup({ env: { PI2_WORKSPACE_HIDE_TEMP: "0" }, home });
|
||||
|
||||
const root = await store.add({ cwd: "~" });
|
||||
expect(root.workspaceId).toBe(workspaceIdForCwd(home));
|
||||
expect(root.cwd).toBe(home);
|
||||
expect(root.alias).toBeNull();
|
||||
|
||||
const child = await store.add({ cwd: "~/project", alias: "Project" });
|
||||
expect(child.workspaceId).toBe(workspaceIdForCwd(project));
|
||||
expect(child.cwd).toBe(project);
|
||||
expect(child.alias).toBe("Project");
|
||||
expect(registry.list()).toHaveLength(2);
|
||||
});
|
||||
|
||||
it("rejects ~user/… and names the accepted forms in the message", async () => {
|
||||
const { store } = setup({ home: allowRoot });
|
||||
|
||||
await expect(store.add({ cwd: "~alice/project" })).rejects.toMatchObject({
|
||||
code: "E_BAD_REQUEST",
|
||||
message: expect.stringContaining("cwd must be an absolute path (or start with ~/)"),
|
||||
});
|
||||
await expect(store.add({ cwd: "relative/project" })).rejects.toMatchObject({
|
||||
code: "E_BAD_REQUEST",
|
||||
message: expect.stringContaining("cwd must be an absolute path (or start with ~/)"),
|
||||
});
|
||||
});
|
||||
|
||||
it("validates relative, missing and non-directory paths", async () => {
|
||||
const file = join(allowRoot, "file.txt");
|
||||
writeFileSync(file, "x");
|
||||
|
||||
Reference in new issue
Block a user