pi-mono/packages/coding-agent/src/modes
Petr Houška 9376c8d17c
fix(coding-agent): pass host keybinding hints to extension renderers (#11630)
Fixes #4748.

## Problem

Extensions that import `keyText`/`keyHint` from
`@earendil-works/pi-coding-agent` can resolve their own copy of the
package (their own `node_modules`, or the bundled `cli.js` vs
`dist/index.js`). That copy's keybindings are never set by the host, so
it falls back to a manager with only `tui.*` bindings, and
`keyHint("app.tools.expand", "to expand")` renders as ` to expand`.

## Change

The host passes its own `keyText` and `keyHint` to extension renderers,
the same way it passes `theme`:

- `ToolRenderContext` (`renderCall`/`renderResult` context):
`context.keyHint(...)`
- `MessageRenderOptions` and `EntryRenderOptions`:
`options.keyHint(...)`

All three extend a new exported `KeybindingHints` interface. The docs
and the `debug-provider` example now use the injected functions and warn
against importing them in renderers.

Not done:

- Moving the `pi-tui` keybindings singleton to `globalThis`. Per the
discussion in #7011, extension-facing state should be host-owned and
passed through the extension API instead of shared through process-wide
module state.
- `ctx.ui.keyText`/`keyHint`. No reported case needs them outside
renderers, RPC and print modes never install app keybindings, and adding
them to `ExtensionUIContext` would break SDK hosts that implement it.

## Tests

- `test/extension-keybinding-hints.test.ts`: tool, message, and entry
renderers format a user-overridden `app.tools.expand` binding.
- `npm run check` passes.
2026-10-30 23:01:20 +01:00
..
interactive fix(coding-agent): pass host keybinding hints to extension renderers (#11630) 2026-10-30 23:01:20 +01:00
rpc feat(coding-agent): report prompt disposition in RPC responses 2026-09-25 14:53:11 +02:00
index.ts fix(coding-agent): make JSON streaming output linear (#7394) 2026-08-03 18:33:22 +02:00
json-event.ts fix(coding-agent): expose tool metadata at stream start (#7953) 2026-08-19 12:24:30 +02:00
print-mode.ts fix(coding-agent): warn and exit non-zero in print mode on truncated response 2026-10-12 16:06:42 +02:00