What problem does this solve?
When the agent is in ask mode and wants to execute a tool call (e.g. write_file, run_shell), the current confirmation flow is basic and doesn't let the user review the proposed changes before approving them.
Proposed solution
Replace the current implicit execution with a rich interactive confirmation UI that lets the user review changes before they are applied.
Diff view (for write_file / file modifications)
Show the proposed change as a unified diff in a styled Rich Panel before the confirmation prompt:
┌─ write_file src/lmcode/agent/core.py ──────────────────────────────────────┐
│ - old line A │
│ + new line A (modified) │
│ + new line B (added) │
└──────────────────────────────────────────────────────────────────────────────┘
Lines removed in ERROR red, lines added in SUCCESS green — matching the DIFF_ADD/DIFF_REMOVE color aliases already in colors.py.
Confirmation widget
Below the diff, an arrow-key-navigable inline menu styled in ACCENT violet:
Allow this change?
❯ Yes
No
Yes — and allow this tool automatically from now on
┌──────────────────────────────────────────────────────┐
│ ...or tell lmcode what to do instead │
└──────────────────────────────────────────────────────┘
- ↑/↓ arrows navigate the three options.
- Enter confirms the selected option.
- Selecting the text box allows the user to type a redirect instruction (e.g. "use a different file name") which is fed back to the model as a new user turn.
- "Yes — and allow automatically" sets the tool to auto-approve for the rest of the session (equivalent to switching that specific tool to
auto mode).
For run_shell
Show the exact command in a styled code block instead of a diff.
Implementation notes:
- Hook into the
_wrap_tool_verbose path — intercept in ask mode before calling the real tool.
- Use
prompt_toolkit for the arrow-key menu (inline, no full-screen).
- Diff generation: compare existing file content with proposed content using
difflib.unified_diff.
- The "allow automatically" option could set a per-tool flag in
Agent (e.g. self._auto_tools: set[str]).
Acceptance criteria:
- In ask mode,
write_file and run_shell calls show the confirmation UI before executing.
- The diff is syntax-highlighted with correct add/remove colors.
- Arrow-key navigation works in the VSCode integrated terminal.
- Auto-allow state persists for the session, resets on
/clear.
Alternatives considered
None considered.
What problem does this solve?
When the agent is in ask mode and wants to execute a tool call (e.g.
write_file,run_shell), the current confirmation flow is basic and doesn't let the user review the proposed changes before approving them.Proposed solution
Replace the current implicit execution with a rich interactive confirmation UI that lets the user review changes before they are applied.
Diff view (for write_file / file modifications)
Show the proposed change as a unified diff in a styled Rich Panel before the confirmation prompt:
Lines removed in
ERRORred, lines added inSUCCESSgreen — matching theDIFF_ADD/DIFF_REMOVEcolor aliases already incolors.py.Confirmation widget
Below the diff, an arrow-key-navigable inline menu styled in
ACCENTviolet:automode).For run_shell
Show the exact command in a styled code block instead of a diff.
Implementation notes:
_wrap_tool_verbosepath — intercept in ask mode before calling the real tool.prompt_toolkitfor the arrow-key menu (inline, no full-screen).difflib.unified_diff.Agent(e.g.self._auto_tools: set[str]).Acceptance criteria:
write_fileandrun_shellcalls show the confirmation UI before executing./clear.Alternatives considered
None considered.