Refresh diagnostics before showing /tools

This commit is contained in:
murashit 2026-06-28 08:45:40 +09:00
parent 0b603354c4
commit 489f30d97c
6 changed files with 19 additions and 10 deletions

View file

@ -141,7 +141,7 @@ export const SLASH_COMMANDS = [
usage: "/tools",
argsKind: "none",
surface: "diagnostic",
detail: "Show Codex plugins, tool providers, and skills reported by App Server.",
detail: "Show Codex plugins, MCP servers, and skills reported by App Server.",
},
{
command: "/model",

View file

@ -29,7 +29,7 @@ export interface ConversationTurnActionsContext {
modelStatusLines: () => string[];
effortStatusLines: () => string[];
statusSummaryLines: () => string[];
toolInventoryDetails: () => MessageStreamNoticeSection[];
toolInventoryDetails: () => MessageStreamNoticeSection[] | Promise<MessageStreamNoticeSection[]>;
};
thread: {
ensureRestoredThreadLoaded: () => Promise<boolean>;

View file

@ -53,7 +53,7 @@ export interface SlashCommandExecutionPorts {
};
statusSummaryLines: () => string[];
connectionDiagnosticDetails: () => MessageStreamNoticeSection[];
toolInventoryDetails: () => MessageStreamNoticeSection[];
toolInventoryDetails: () => MessageStreamNoticeSection[] | Promise<MessageStreamNoticeSection[]>;
modelStatusLines: () => string[];
effortStatusLines: () => string[];
}
@ -186,7 +186,7 @@ export async function executeSlashCommand(
context.addStructuredSystemMessage("Connection diagnostics", context.connectionDiagnosticDetails());
return;
case "tools":
context.addStructuredSystemMessage("Codex capabilities", context.toolInventoryDetails());
context.addStructuredSystemMessage("Codex capabilities", await context.toolInventoryDetails());
return;
case "model": {
const requested = parseModelOverride(args);

View file

@ -177,6 +177,7 @@ export function createChatPanelSessionGraph(host: ChatPanelSessionGraphHost): Ch
threadFoundation.invalidateThreadWork();
},
runtimeProjection: runtime.projection,
refreshDiagnostics: () => connectionController.refreshDiagnostics(),
refreshLiveState,
notifyActiveThreadIdentityChanged,
});

View file

@ -68,6 +68,7 @@ interface ChatPanelTurnInput {
autoTitleCoordinator: AutoTitleCoordinator;
invalidateThreadWork: () => void;
runtimeProjection: ChatPanelRuntimeProjection;
refreshDiagnostics: () => Promise<void>;
refreshLiveState: () => void;
notifyActiveThreadIdentityChanged: () => void;
}
@ -91,6 +92,7 @@ export function createTurnBundle(host: ChatPanelTurnHost, input: ChatPanelTurnIn
autoTitleCoordinator,
invalidateThreadWork,
runtimeProjection,
refreshDiagnostics,
refreshLiveState,
notifyActiveThreadIdentityChanged,
} = input;
@ -148,7 +150,10 @@ export function createTurnBundle(host: ChatPanelTurnHost, input: ChatPanelTurnIn
modelStatusLines: runtimeProjection.modelStatusLines,
effortStatusLines: runtimeProjection.effortStatusLines,
statusSummaryLines: runtimeProjection.statusSummaryLines,
toolInventoryDetails: runtimeProjection.toolInventoryDetails,
toolInventoryDetails: async () => {
await refreshDiagnostics();
return runtimeProjection.toolInventoryDetails();
},
},
thread: {
ensureRestoredThreadLoaded: () =>

View file

@ -47,7 +47,7 @@ function context(overrides: Partial<SlashCommandExecutionContext> = {}): SlashCo
},
statusSummaryLines: () => ["status"],
connectionDiagnosticDetails: () => [{ title: "Process", rows: [{ key: "connection", value: "connected" }] }],
toolInventoryDetails: vi.fn(() => [{ title: "Tool providers", auditFacts: [{ key: "codex_apps", value: "GitHub" }] }]),
toolInventoryDetails: vi.fn(() => [{ title: "MCP servers", auditFacts: [{ key: "codex_apps", value: "GitHub" }] }]),
modelStatusLines: () => ["model"],
effortStatusLines: () => ["effort"],
...overrides,
@ -674,13 +674,16 @@ describe("slash commands", () => {
});
it("shows Codex capabilities", async () => {
const ctx = context();
const toolInventoryDetails = vi
.fn()
.mockResolvedValue([{ title: "MCP servers", auditFacts: [{ key: "codex_apps", value: "GitHub" }] }]);
const ctx = context({ toolInventoryDetails });
await executeSlashCommand("tools", "", ctx);
expect(ctx.toolInventoryDetails).toHaveBeenCalledOnce();
expect(toolInventoryDetails).toHaveBeenCalledOnce();
expect(ctx.addStructuredSystemMessage).toHaveBeenCalledWith("Codex capabilities", [
{ title: "Tool providers", auditFacts: [{ key: "codex_apps", value: "GitHub" }] },
{ title: "MCP servers", auditFacts: [{ key: "codex_apps", value: "GitHub" }] },
]);
});
@ -703,7 +706,7 @@ describe("slash commands", () => {
});
it("documents Codex capabilities", () => {
expect(slashCommandHelpValue("/tools")).toBe("Show Codex plugins, tool providers, and skills reported by App Server.");
expect(slashCommandHelpValue("/tools")).toBe("Show Codex plugins, MCP servers, and skills reported by App Server.");
});
});