Skip to content

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

TypeScript

mods/diff: an asked diff rides down to the turn on the prompt's context, not onto the answer

poteatd920522c4b90
diff --git a/mods/diff/hooks/register.ts b/mods/diff/hooks/register.ts
index decad2e8..19258b53 100644
--- a/mods/diff/hooks/register.ts
+++ b/mods/diff/hooks/register.ts
@@ -590,17 +590,23 @@ export function register(on: On) {
})
on('prompt.submit', async ($, e, next) => {
- const result = await next(e)
const asked = armed
- if (!host || !asked || result.drop !== undefined) {
- return result
+ if (!host || !asked) {
+ return next(e)
}
- disarm(host)
- redraw(host)
- Record.recorderOf(host).asked(asked.lines)
+ const result = await next({
+ ...e,
+ context: [...(e.context ?? []), asked.text],
+ })
+
+ if (result.drop === undefined && armed === asked) {
+ disarm(host)
+ redraw(host)
+ Record.recorderOf(host).asked(asked.lines)
+ }
- return { ...result, context: [...(result.context ?? []), asked.text] }
+ return result
})
}