fix(coding-agent): handled discard no-op resolution and dynamic expand hints

- Updated tool expand-hint rendering to use `expandKeyHint()`, which pulls the `app.tools.expand` binding and formats collapsed previews as `<key>: Expand`.
- Updated related tests in render utils and TUI regressions to assert the new hint string for default and remapped bindings.
- Added a resolve-tool regression test and changelog note covering `action: "discard"` with no pending action as a successful cancellation.
This commit is contained in:
can1357
2026-06-07 03:21:25 +02:00
parent 8df5718a66
commit cd2eb7ed28
6 changed files with 71 additions and 10 deletions
@@ -10,8 +10,9 @@ import * as path from "node:path";
import type { ToolCallContext } from "@oh-my-pi/pi-agent-core";
import type { Ellipsis } from "@oh-my-pi/pi-natives";
import type { Component } from "@oh-my-pi/pi-tui";
import { replaceTabs, truncateToWidth } from "@oh-my-pi/pi-tui";
import { getKeybindings, replaceTabs, truncateToWidth } from "@oh-my-pi/pi-tui";
import { pluralize } from "@oh-my-pi/pi-utils";
import { formatKeyHints, type KeyId } from "../config/keybindings";
import { settings } from "../config/settings";
import type { Theme } from "../modes/theme/theme";
import { Hasher } from "../tui/utils";
@@ -75,8 +76,16 @@ export const TRUNCATE_LENGTHS = {
SHORT: 40,
} as const;
/** Standard expand hint text */
export const EXPAND_HINT = "(Ctrl+O for more)";
/** Keybinding action that toggles tool-output expansion. */
const EXPAND_ACTION = "app.tools.expand";
/** Fallback key when no binding is resolvable (e.g. outside an interactive session). */
const DEFAULT_EXPAND_KEY: KeyId = "ctrl+o";
/** Human-readable key currently bound to tool-output expansion, e.g. `Ctrl+O`. */
export function expandKeyHint(): string {
const keys = getKeybindings().getKeys(EXPAND_ACTION);
return formatKeyHints(keys.length > 0 ? keys : [DEFAULT_EXPAND_KEY]);
}
// =============================================================================
// Text Truncation Utilities
@@ -150,7 +159,7 @@ export function formatStatusIcon(status: ToolUIStatus, theme: Theme, spinnerFram
export function formatExpandHint(theme: Theme, expanded?: boolean, hasMore?: boolean): string {
if (expanded) return "";
if (hasMore === false) return "";
return theme.fg("dim", wrapBrackets(EXPAND_HINT, theme));
return theme.fg("dim", wrapBrackets(`${expandKeyHint()}: Expand`, theme));
}
/**