Motivation
lua/code-preview/diff.lua show_diff(original_path, proposed_path, real_file_path, abs_file_path, action) takes four path-like parameters whose names have drifted. Two are misleading:
real_file_path is not the real path — it's the display string used in the winbar (often a cwd-relative path). The name implies it's the canonical identity.
abs_file_path is the actual canonical identity (key in active_diffs, passed to the changes registry, used by neo-tree reveal).
original_path / proposed_path are paths to temp files (/tmp/claude-diff-{original,proposed}-<pid>) holding the before/after content — not the real file.
A reader (or future-us during issue #47 phase 3) will misuse these. The friction shows up in diff.lua, bin/core-pre-tool.sh, and bin/apply-patch.lua, all of which thread these args through.
Proposed naming
The three concepts:
- Source paths — the two temp files:
original_source_path, proposed_source_path.
- File path — the canonical absolute path of the real file (identity):
file_path.
- Display path — what's shown in the winbar:
display_path.
So: show_diff(original_source_path, proposed_source_path, display_path, file_path, action).
Scope
- Pure refactor. No behaviour change.
- Touches
lua/code-preview/diff.lua (function signature + internal use), bin/core-pre-tool.sh and bin/apply-patch.lua (call sites, JSON arg keys).
- Tests under
tests/plugin/diff_lifecycle_spec.lua may reference parameter names — update accordingly.
Out of scope
Acceptance
- All references to
real_file_path and abs_file_path removed in favour of display_path and file_path.
- All references to
original_path / proposed_path for temp content files renamed to _source_path.
- Existing tests pass with no behaviour change.
Motivation
lua/code-preview/diff.luashow_diff(original_path, proposed_path, real_file_path, abs_file_path, action)takes four path-like parameters whose names have drifted. Two are misleading:real_file_pathis not the real path — it's the display string used in the winbar (often a cwd-relative path). The name implies it's the canonical identity.abs_file_pathis the actual canonical identity (key inactive_diffs, passed to the changes registry, used by neo-tree reveal).original_path/proposed_pathare paths to temp files (/tmp/claude-diff-{original,proposed}-<pid>) holding the before/after content — not the real file.A reader (or future-us during issue #47 phase 3) will misuse these. The friction shows up in
diff.lua,bin/core-pre-tool.sh, andbin/apply-patch.lua, all of which thread these args through.Proposed naming
The three concepts:
original_source_path,proposed_source_path.file_path.display_path.So:
show_diff(original_source_path, proposed_source_path, display_path, file_path, action).Scope
lua/code-preview/diff.lua(function signature + internal use),bin/core-pre-tool.shandbin/apply-patch.lua(call sites, JSON arg keys).tests/plugin/diff_lifecycle_spec.luamay reference parameter names — update accordingly.Out of scope
core-pre-tool.sh. This rename should land before or after phase 3, not as part of it, so Migrate hook orchestration from bash to Lua #47's diff stays reviewable as a port (not a port + rename).Acceptance
real_file_pathandabs_file_pathremoved in favour ofdisplay_pathandfile_path.original_path/proposed_pathfor temp content files renamed to_source_path.