@@ -146,7 +146,7 @@ M.display_path = display_path -- exposed for testing
146146-- to diff.show_diff (or skip when visible_only excludes the file). The only
147147-- per-tool variation is how `proposed_content` is computed, so each handler
148148-- below is a one-liner around this helper.
149- local function present_single_file (file_path , proposed_content , input , cfg )
149+ local function present_single_file (file_path , proposed_content , input , cfg , backend )
150150 local id = next_id ()
151151 local orig = tmpdir () .. " /code-preview-diff-original-" .. id
152152 local prop = tmpdir () .. " /code-preview-diff-proposed-" .. id
@@ -159,29 +159,29 @@ local function present_single_file(file_path, proposed_content, input, cfg)
159159 return
160160 end
161161
162- diff .show_diff (orig , prop , display_path (file_path , input .cwd ), file_path , nil )
162+ diff .show_diff (orig , prop , display_path (file_path , input .cwd ), file_path , nil , backend )
163163end
164164
165- local function handle_edit (input , cfg )
165+ local function handle_edit (input , cfg , backend )
166166 local fp = input .tool_input .file_path
167167 local content = apply_edit .apply (
168168 fp ,
169169 input .tool_input .old_string or " " ,
170170 input .tool_input .new_string or " " ,
171171 input .tool_input .replace_all == true
172172 )
173- present_single_file (fp , content , input , cfg )
173+ present_single_file (fp , content , input , cfg , backend )
174174end
175175
176- local function handle_write (input , cfg )
176+ local function handle_write (input , cfg , backend )
177177 local fp = input .tool_input .file_path
178- present_single_file (fp , input .tool_input .content or " " , input , cfg )
178+ present_single_file (fp , input .tool_input .content or " " , input , cfg , backend )
179179end
180180
181- local function handle_multi_edit (input , cfg )
181+ local function handle_multi_edit (input , cfg , backend )
182182 local fp = input .tool_input .file_path
183183 local content = apply_multi_edit .apply (fp , input .tool_input .edits or {})
184- present_single_file (fp , content , input , cfg )
184+ present_single_file (fp , content , input , cfg , backend )
185185end
186186
187187local function handle_bash (input )
@@ -214,7 +214,7 @@ local function handle_bash(input)
214214 end
215215end
216216
217- local function handle_apply_patch (input , cfg )
217+ local function handle_apply_patch (input , cfg , backend )
218218 local patch_text = input .tool_input and input .tool_input .patch_text
219219 if not patch_text or patch_text == " " then
220220 log .info (" pre_tool: ApplyPatch with empty patch_text" )
@@ -250,7 +250,7 @@ local function handle_apply_patch(input, cfg)
250250 -- whatever the model wrote in the `*** Update File:` directive, and some
251251 -- codex models (e.g. GPT 5.3) write an absolute path there, which would
252252 -- render the tab as `D:\...` instead of a cwd-relative label.
253- diff .show_diff (orig , prop , display_path (file .path , input .cwd ), file .path , file .action )
253+ diff .show_diff (orig , prop , display_path (file .path , input .cwd ), file .path , file .action , backend )
254254 else
255255 log .info (log .fmt (" pre_tool: ApplyPatch skip %s (visible_only)" , file .rel_path ))
256256 end
@@ -261,7 +261,7 @@ local dispatchers = {
261261 Edit = handle_edit ,
262262 Write = handle_write ,
263263 MultiEdit = handle_multi_edit ,
264- Bash = function (input , _cfg ) handle_bash (input ) end ,
264+ Bash = function (input , _cfg , _backend ) handle_bash (input ) end ,
265265 ApplyPatch = handle_apply_patch ,
266266}
267267
@@ -280,7 +280,7 @@ function M.handle(raw, backend)
280280
281281 local fn = dispatchers [tool_name ]
282282 if fn then
283- local ok , err = pcall (fn , input , cfg )
283+ local ok , err = pcall (fn , input , cfg , backend )
284284 if not ok then
285285 log .error (" pre_tool: dispatch failed: " .. tostring (err ))
286286 end
0 commit comments