Merge PR #8626: fix(tui): refresh token usage rows when toggled (@notnotype)

This commit is contained in:
can1357
2026-08-16 02:03:16 +02:00
3 changed files with 28 additions and 0 deletions
+3
View File
@@ -21,6 +21,9 @@
### Fixed
- Fixed long `ask` option labels being hard-truncated at the terminal width with no way to read the clipped tail; the rich ask dialog now wraps labels onto indented continuation lines, matching the legacy selector ([#1243](https://github.com/can1357/oh-my-pi/issues/1243), [#8594](https://github.com/can1357/oh-my-pi/issues/8594)).
### Fixed
- Fixed toggling `display.showTokenUsage` from `/settings` leaving existing token-usage rows stale until the transcript was rebuilt.
## [17.3.4] - 2026-08-14
@@ -562,6 +562,12 @@ export class SelectorController {
this.ctx.rebuildChatFromMessages();
this.ctx.ui.resetDisplay();
break;
case "display.showTokenUsage":
// Rebuild reruns usage-row detection under the new setting; resetDisplay
// retires rows already committed to native scrollback.
this.ctx.rebuildChatFromMessages();
this.ctx.ui.resetDisplay();
break;
case "tui.tight":
setTuiTight(value as boolean);
this.ctx.ui.invalidate();
@@ -166,6 +166,25 @@ describe("selector setting side effects", () => {
});
}
for (const enabled of [false, true]) {
it(`rebuilds the transcript when display.showTokenUsage=${enabled} changes in /settings`, () => {
const rebuildChatFromMessages = vi.fn();
const resetDisplay = vi.fn();
const controller = new SelectorController({
rebuildChatFromMessages,
ui: { resetDisplay },
} as unknown as InteractiveModeContext);
controller.handleSettingChange("display.showTokenUsage", enabled);
expect(rebuildChatFromMessages).toHaveBeenCalledTimes(1);
expect(resetDisplay).toHaveBeenCalledTimes(1);
expect(rebuildChatFromMessages.mock.invocationCallOrder[0]).toBeLessThan(
resetDisplay.mock.invocationCallOrder[0],
);
});
}
it("clears stale default role thinking when auto is selected", async () => {
const testTheme = await getThemeByName("dark");
if (!testTheme) throw new Error("Failed to load dark theme for model selector test");