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
@@ -102,6 +102,26 @@ describe("CommandRouter", () => {
|
||||
expect(workspaces.refreshCalls).toEqual(["ws-1"]);
|
||||
});
|
||||
|
||||
it("accepts name as the alias when alias is absent", async () => {
|
||||
const added = await router.dispatch({
|
||||
method: "workspace.add",
|
||||
params: { cwd: "/repo/named", name: " Named " },
|
||||
});
|
||||
|
||||
expect(added.status).toBe(202);
|
||||
expect(workspaces.addCalls).toEqual([{ cwd: "/repo/named", alias: " Named " }]);
|
||||
// The response carries the id both where the protocol documents it and at
|
||||
// the top level (the web client's shortcut).
|
||||
expect(added.body).toMatchObject({ accepted: true, workspaceId: "ws-2", workspace: { workspaceId: "ws-2" } });
|
||||
});
|
||||
|
||||
it("prefers alias over name and drops a whitespace-only name", async () => {
|
||||
await router.dispatch({ method: "workspace.add", params: { cwd: "/repo/both", alias: "A", name: "N" } });
|
||||
await router.dispatch({ method: "workspace.add", params: { cwd: "/repo/blank", name: " " } });
|
||||
|
||||
expect(workspaces.addCalls).toEqual([{ cwd: "/repo/both", alias: "A" }, { cwd: "/repo/blank" }]);
|
||||
});
|
||||
|
||||
it("routes instance and system methods to the instance manager", async () => {
|
||||
const ensured = await router.dispatch({ method: "instance.ensure", params: { workspaceId: "ws-1" } });
|
||||
expect(ensured.status).toBe(202);
|
||||
|
||||
Reference in new issue
Block a user