






















@@ -101,6 +101,7 @@ function createHarness(params?: {
101101params?.setEmptySession ?? (vi.fn().mockResolvedValue(undefined) as SetEmptySessionMock);
102102const addUser = vi.fn();
103103const addSystem = vi.fn();
104+const clearTools = vi.fn();
104105const reserveAssistantSlot = vi.fn();
105106const requestRender = vi.fn();
106107const noteLocalRunId = vi.fn();
@@ -144,7 +145,7 @@ function createHarness(params?: {
144145 resetSession,
145146 runGoalCommand,
146147} as never,
147-chatLog: { addUser, addSystem, reserveAssistantSlot } as never,
148+chatLog: { addUser, addSystem, clearTools, reserveAssistantSlot } as never,
148149tui: { requestRender } as never,
149150opts: params?.opts ?? {},
150151state: state as never,
@@ -187,6 +188,7 @@ function createHarness(params?: {
187188 setEmptySession,
188189 addUser,
189190 addSystem,
191+ clearTools,
190192 reserveAssistantSlot,
191193 requestRender,
192194 loadHistory,
@@ -732,6 +734,60 @@ describe("tui command handlers", () => {
732734});
733735});
734736737+it("hides tools locally for /verbose off without reloading history", async () => {
738+const patchResult = { entry: { verboseLevel: "off" } };
739+const patchSession = vi.fn().mockResolvedValue(patchResult);
740+const applySessionInfoFromPatch = vi.fn();
741+const loadHistory = vi.fn().mockResolvedValue(undefined);
742+const refreshSessionInfo = vi.fn().mockResolvedValue(undefined);
743+const { handleCommand, clearTools } = createHarness({
744+ patchSession,
745+ applySessionInfoFromPatch,
746+ loadHistory,
747+ refreshSessionInfo,
748+});
749+750+await handleCommand("/verbose off");
751+752+expect(patchSession).toHaveBeenCalledWith({
753+key: "agent:main:main",
754+verboseLevel: "off",
755+});
756+expect(applySessionInfoFromPatch).toHaveBeenCalledWith(patchResult);
757+expect(clearTools).toHaveBeenCalledTimes(1);
758+expect(refreshSessionInfo).toHaveBeenCalledTimes(1);
759+expect(loadHistory).not.toHaveBeenCalled();
760+});
761+762+it("reloads history for /verbose on so prior tool output becomes visible", async () => {
763+const loadHistory = vi.fn().mockResolvedValue(undefined);
764+const refreshSessionInfo = vi.fn().mockResolvedValue(undefined);
765+const { handleCommand, clearTools } = createHarness({
766+ loadHistory,
767+ refreshSessionInfo,
768+});
769+770+await handleCommand("/verbose on");
771+772+expect(loadHistory).toHaveBeenCalledTimes(1);
773+expect(refreshSessionInfo).not.toHaveBeenCalled();
774+expect(clearTools).not.toHaveBeenCalled();
775+});
776+777+it("refreshes session info for /trace without reloading history", async () => {
778+const loadHistory = vi.fn().mockResolvedValue(undefined);
779+const refreshSessionInfo = vi.fn().mockResolvedValue(undefined);
780+const { handleCommand } = createHarness({
781+ loadHistory,
782+ refreshSessionInfo,
783+});
784+785+await handleCommand("/trace on");
786+787+expect(refreshSessionInfo).toHaveBeenCalledTimes(1);
788+expect(loadHistory).not.toHaveBeenCalled();
789+});
790+735791it("reports send failures and marks activity status as error", async () => {
736792const setActivityStatus = vi.fn();
737793const { handleCommand, addSystem, state } = createHarness({
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。