Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion packages/client/src/desktop-runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,14 @@ export class DesktopRuntimeController {
if (command === "session.list" || command === "host.list") {
this.applySessionListResult(targetId, hostValue, result, expectedIdentity);
} else if (command === "catalog.get") {
const catalog = decodeCatalog({ v: "omp-app/1", type: "catalog", hostId: hostValue, revision: result.revision, items: result.items });
const catalog = decodeCatalog({
v: "omp-app/1",
type: "catalog",
hostId: hostValue,
revision: result.revision,
items: result.items,
...(result.operations === undefined ? {} : { operations: result.operations }),
});
if (catalog.type !== "catalog") throw new DesktopRuntimeError("protocol", "catalog response decoded as settings");
this.replace({ catalogs: mapValue(new Map(this.current.catalogs).set(hostValue, catalog)) });
} else if (command === "settings.read") {
Expand Down
57 changes: 56 additions & 1 deletion packages/client/test/desktop-runtime.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, it } from "vite-plus/test";
import { hostId, revision, sessionId, type WelcomeFrame } from "@t4-code/protocol";
import { hostId, operationId, revision, sessionId, type WelcomeFrame } from "@t4-code/protocol";
import { rendererServerEventFromFrame } from "@t4-code/protocol/desktop-ipc";
import type {
BootstrapResult,
Expand Down Expand Up @@ -340,6 +340,61 @@ describe("desktop runtime projection", () => {
});
expect(runtime.getSnapshot().targetHosts.get("local")).toBe("host-a");
});
it("preserves operation capabilities from catalog responses and live catalog frames", async () => {
const shell = new FakeShell();
shell.catalogResult = {
revision: "catalog-response",
items: [],
operations: [{
operationId: "slash.compact",
label: "/compact",
execution: "headless",
supported: true,
}],
};
const runtime = createDesktopRuntimeController({ shell });
await runtime.start();
shell.emitState({ targetId: "local", state: "connected" });
shell.emitFrame({ targetId: "local", frame: welcome("host-a", [], []) });

await runtime.command("local", {
hostId: hostId("host-a"),
command: "catalog.get",
args: {},
});
expect(runtime.getSnapshot().catalogs.get("host-a")?.operations).toMatchObject([
{ operationId: "slash.compact", execution: "headless", supported: true },
]);

shell.emitFrame({
targetId: "local",
frame: {
v: "omp-app/1",
type: "catalog",
hostId: hostId("host-a"),
revision: revision("catalog-live"),
items: [],
operations: [{
operationId: operationId("slash.plan"),
label: "/plan",
execution: "terminal-only",
supported: false,
disabledReason: {
code: "terminal_only",
message: "This command requires the OMP terminal interface.",
},
}],
},
});
expect(runtime.getSnapshot().catalogs.get("host-a")?.operations).toMatchObject([
{
operationId: "slash.plan",
execution: "terminal-only",
supported: false,
disabledReason: { code: "terminal_only" },
},
]);
});
it("refreshes inventory on cadence so a session started after bootstrap appears without reconnect", async () => {
const timers = new FakeTimerScheduler();
const shell = new FakeShell();
Expand Down
Loading