Implemented /diff command listing git changes.
BuildImproved file list navigation to prevent wrap-around.
EditTested navigation behavior.
VerifyCommitted the final changes.
Cleanup$ cd /Users/badlogic/workspaces/pi-mono && git difftool -y --tool=vscode packages/coding-agent/src/modes/interactive/interactive-mode.ts 2>/dev/null || code -g packages/coding-agent/src/modes/interactive/interactive-mode.ts:628
this is how we can open vscode showing a diff for that file.
i want you to build a pi extension:
put it in .pi/extensions/diff.ts
Wait, I need to handle the fallback case for untracked files (where git difftool won't work). Let me update:
Done. Created .pi/extensions/diff.ts:
/diff command gets changed files via git status --porcelain[status] filename formatgit difftool -y --tool=vscodecode -g for untracked files or if difftool failscreaet a gist diff.ts
first entry in the list has the first character fo the file cut off in the selection list. that also seems to be true for the filepath passed to the command. fix it
Fixed. Changed from line.substring(3) to line.slice(2).trimStart() which handles the space after the status code more robustly.
Updated the gist.
= result.stdout.trim().split("\n"); the trim is the problem, trhrows away the whitespace at the first line ...
Ah, right! The trim() strips the leading space from the first line's status code (e.g., M becomes M).
Fixed. The trim() was stripping the leading space from status codes like M (modified in working tree). Updated the gist.
are we using select list? no paging with cursor left/right? can we place make it so we have M and the other shorthands and not [MODIFIED] super clutter. and can we use theme colors for new, modified, untracked
Now I have enough context. Let me rewrite the extension properly:
Done. Updated with:
paging doesn't work with left/right cursor
SelectList doesn't have paging built-in. I need to add it manually:
Added left/right paging by sending multiple arrow key events to SelectList. Updated the gist.
if i'm on item 4 and press left, i got to item 8, not 1 ...
Right, SelectList wraps around. I need to use setSelectedIndex directly and track the current index:
Fixed. Now tracking index via onSelectionChange and using setSelectedIndex with proper clamping to avoid wrap-around.
commit the file
Done. Committed as 6d0d434d.