* fix(client): wait longer for session responses * fix(client): default RPC waits to sixty seconds * fix(app): preserve detached stream scroll on delayed history Code drift: longer client RPC waits let delayed timeline responses arrive after a user scroll-away, so web stream anchoring must not reattach on transient scroll-top resets. Restore the 15s connect deadline and leave app initialization slack above the default 60s session RPC wait. * fix(client): keep helper waits within caller deadlines Review fix: the 60s default session RPC wait leaked into wait previews and waitForAgentUpsert helper fetches. Bound those helper RPCs to the caller deadline or a short best-effort preview timeout, and allow small scroll ranges to reattach at bottom. * fix(client): respect caller timeout budgets * fix(cli): keep diagnostic probes responsive * Refactor daemon client request options * Preserve daemon client legacy overloads
68 lines
1.9 KiB
TypeScript
68 lines
1.9 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
type AgentCommandsClient,
|
|
type DraftCommandConfig,
|
|
fetchAgentCommands,
|
|
} from "./use-agent-commands-query";
|
|
|
|
type ListCommands = AgentCommandsClient["listCommands"];
|
|
type ListCommandsResult = Awaited<ReturnType<ListCommands>>;
|
|
|
|
interface ListCommandsCall {
|
|
agentId: string;
|
|
draftConfig: DraftCommandConfig | undefined;
|
|
}
|
|
|
|
interface FakeAgentCommandsClient extends AgentCommandsClient {
|
|
calls: ListCommandsCall[];
|
|
}
|
|
|
|
function createClient(response: ListCommandsResult): FakeAgentCommandsClient {
|
|
const calls: ListCommandsCall[] = [];
|
|
return {
|
|
calls,
|
|
listCommands: (async (options: Parameters<ListCommands>[0]) => {
|
|
calls.push({ agentId: options.agentId, draftConfig: options.draftConfig });
|
|
return response;
|
|
}) as ListCommands,
|
|
};
|
|
}
|
|
|
|
function commandsPayload(commands: ListCommandsResult["commands"]): ListCommandsResult {
|
|
return {
|
|
requestId: "req_commands",
|
|
agentId: "",
|
|
error: null,
|
|
commands,
|
|
};
|
|
}
|
|
|
|
describe("fetchAgentCommands", () => {
|
|
it("loads commands for a draft composer without an agent id", async () => {
|
|
const client = createClient(
|
|
commandsPayload([{ name: "compact", description: "Compact context", argumentHint: "" }]),
|
|
);
|
|
|
|
const draftConfig: DraftCommandConfig = {
|
|
provider: "opencode",
|
|
cwd: "/repo",
|
|
modeId: "build",
|
|
};
|
|
|
|
const commands = await fetchAgentCommands({ client, agentId: "", draftConfig });
|
|
|
|
expect(commands).toEqual([
|
|
{ name: "compact", description: "Compact context", argumentHint: "" },
|
|
]);
|
|
expect(client.calls).toEqual([{ agentId: "", draftConfig }]);
|
|
});
|
|
|
|
it("passes the agent id when fetching commands for a running agent", async () => {
|
|
const client = createClient(commandsPayload([]));
|
|
|
|
await fetchAgentCommands({ client, agentId: "agent-1" });
|
|
|
|
expect(client.calls).toEqual([{ agentId: "agent-1", draftConfig: undefined }]);
|
|
});
|
|
});
|