fix(tui): purge hidden tool images
This commit is contained in:
@@ -1878,6 +1878,7 @@ export class InputController {
|
||||
}
|
||||
}
|
||||
|
||||
if (this.ctx.hideToolActivity) this.ctx.ui.clearInlineImages();
|
||||
this.ctx.ui.resetDisplay();
|
||||
this.ctx.showStatus(`Tool activity: ${this.ctx.hideToolActivity ? "hidden" : "visible"}`);
|
||||
}
|
||||
|
||||
@@ -487,6 +487,7 @@ export class SelectorController {
|
||||
child.setToolResultImagesVisible(!hidden);
|
||||
}
|
||||
}
|
||||
if (hidden) this.ctx.ui.clearInlineImages();
|
||||
this.ctx.ui.resetDisplay();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -74,6 +74,7 @@ async function createContext() {
|
||||
customHandlers.clear();
|
||||
});
|
||||
const resetDisplay = vi.fn();
|
||||
const clearInlineImages = vi.fn();
|
||||
const showModelSelector = vi.fn();
|
||||
const requestRender = vi.fn();
|
||||
const showError = vi.fn();
|
||||
@@ -142,6 +143,7 @@ async function createContext() {
|
||||
ui: {
|
||||
requestRender,
|
||||
resetDisplay,
|
||||
clearInlineImages,
|
||||
addInputListener,
|
||||
addStartListener,
|
||||
getFocused: vi.fn(() => focused),
|
||||
@@ -234,6 +236,7 @@ async function createContext() {
|
||||
retry,
|
||||
abort,
|
||||
resetDisplay,
|
||||
clearInlineImages,
|
||||
refreshAppearance,
|
||||
resetDisplayAfterAppearanceRefresh,
|
||||
handleBtwBranchKey,
|
||||
@@ -283,6 +286,7 @@ describe("InputController keybinding setup", () => {
|
||||
|
||||
expect(ctx.hideToolActivity).toBe(true);
|
||||
expect(ctx.settings.set).toHaveBeenCalledWith("display.hideToolActivity", true);
|
||||
expect(spies.clearInlineImages).toHaveBeenCalledTimes(1);
|
||||
expect(spies.resetDisplay).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
|
||||
+7
-2
@@ -60,6 +60,7 @@ describe("InputController tool activity visibility", () => {
|
||||
const addChild = vi.fn();
|
||||
const rebuildChatFromMessages = vi.fn();
|
||||
const set = vi.fn();
|
||||
const clearInlineImages = vi.fn();
|
||||
const resetDisplay = vi.fn();
|
||||
const showStatus = vi.fn();
|
||||
const ctx = {
|
||||
@@ -69,7 +70,7 @@ describe("InputController tool activity visibility", () => {
|
||||
chatContainer: { children, clear, addChild },
|
||||
rebuildChatFromMessages,
|
||||
showStatus,
|
||||
ui: { resetDisplay },
|
||||
ui: { clearInlineImages, resetDisplay },
|
||||
};
|
||||
const controller = new InputController(ctx as unknown as InteractiveModeContext) as unknown as InputController & {
|
||||
toggleToolActivityVisibility(): void;
|
||||
@@ -83,7 +84,9 @@ describe("InputController tool activity visibility", () => {
|
||||
expect(clear).not.toHaveBeenCalled();
|
||||
expect(addChild).not.toHaveBeenCalled();
|
||||
expect(rebuildChatFromMessages).not.toHaveBeenCalled();
|
||||
expect(resetDisplay).toHaveBeenCalled();
|
||||
expect(clearInlineImages).toHaveBeenCalledTimes(1);
|
||||
expect(resetDisplay).toHaveBeenCalledTimes(1);
|
||||
expect(clearInlineImages.mock.invocationCallOrder[0]).toBeLessThan(resetDisplay.mock.invocationCallOrder[0]);
|
||||
expect(showStatus).toHaveBeenLastCalledWith("Tool activity: hidden");
|
||||
expect(setToolResultImagesVisible).toHaveBeenLastCalledWith(false);
|
||||
|
||||
@@ -96,6 +99,8 @@ describe("InputController tool activity visibility", () => {
|
||||
expect(clear).not.toHaveBeenCalled();
|
||||
expect(addChild).not.toHaveBeenCalled();
|
||||
expect(rebuildChatFromMessages).not.toHaveBeenCalled();
|
||||
expect(clearInlineImages).toHaveBeenCalledTimes(1);
|
||||
expect(resetDisplay).toHaveBeenCalledTimes(2);
|
||||
expect(showStatus).toHaveBeenLastCalledWith("Tool activity: visible");
|
||||
expect(setToolResultImagesVisible).toHaveBeenLastCalledWith(true);
|
||||
});
|
||||
|
||||
@@ -141,12 +141,13 @@ describe("selector setting side effects", () => {
|
||||
const setToolResultImagesVisible = vi.fn();
|
||||
const assistant = Object.create(AssistantMessageComponent.prototype) as AssistantMessageComponent;
|
||||
assistant.setToolResultImagesVisible = setToolResultImagesVisible;
|
||||
const clearInlineImages = vi.fn();
|
||||
const resetDisplay = vi.fn();
|
||||
const ctx = {
|
||||
hideToolActivity: !hidden,
|
||||
toolOutputExpanded: true,
|
||||
chatContainer: { children: [tool, readGroup, assistant] },
|
||||
ui: { resetDisplay },
|
||||
ui: { clearInlineImages, resetDisplay },
|
||||
};
|
||||
const controller = new SelectorController(ctx as unknown as InteractiveModeContext);
|
||||
|
||||
@@ -159,7 +160,13 @@ describe("selector setting side effects", () => {
|
||||
expect(setToolExpanded).toHaveBeenCalledTimes(hidden ? 0 : 1);
|
||||
expect(setReadExpanded).toHaveBeenCalledTimes(hidden ? 0 : 1);
|
||||
expect(ctx.toolOutputExpanded).toBe(hidden);
|
||||
expect(clearInlineImages).toHaveBeenCalledTimes(hidden ? 1 : 0);
|
||||
expect(resetDisplay).toHaveBeenCalledTimes(1);
|
||||
if (hidden) {
|
||||
expect(clearInlineImages.mock.invocationCallOrder[0]).toBeLessThan(
|
||||
resetDisplay.mock.invocationCallOrder[0],
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user