Fix path-detection bug in a Pi /code snippet extension (TypeScript)
Session from pi-extensions-sessions on Hugging Face by thomasmustier · MIT · condensed by Coders Talk
Click a segment to jump to that moment
49msession
1interventions
GOAL
Investigate why /code wasn't picking up commands with only one slash (like ~/file.html), fix the filtering logic, and clean up the extension's code and docs.
- +0Prompt · +0Last command isn't picked up by /code. Might be a single-slash issue — can we rethink the filtering rule?
- +0mAgent did · +0mLocated code-actions extension, found minSlashCount:2 rule rejecting single-slash paths like ~/file.html; edited snippets.ts to recognize ~/, ./ and file-extension paths as valid.
- +9mPrompt · +9mDo we want ../ though?
- +9mAgent did · +9mExcluded ../ from the strong-match rule since it usually appears in import statements rather than actionable file paths; re-ran node test cases confirming all pass.
- +16mAgent did · +16mRefactored snippets.ts: replaced INLINE_FILTER object with named constants, extracted looksLikePath() helper, removed duplicate slash counting; all 11 test cases passed.
- +21mPrompt · +21mThis TUI table output is getting captured as a code block and I'm not sure why.
- +21mAgent did · +21mProposed and implemented a box-drawing character heuristic to reject decorative TUI output from being captured as code blocks.
- +22mIntervention · +22mDeveloper said 'No no no it's fine, keep it as it was' and had the agent revert the TUI-block filter entirely.Why: That filter was solving a problem I didn't actually want solved — I'd rather see all code blocks unfiltered than risk losing real content to a heuristic.
- +22mAgent did · +22mReverted the box-drawing filter, kept the ~/ path fix, then did a further cleanup pass hoisting constants and removing a regex-state bug from hoisted /g regexes; re-verified all tests pass.
- +49mOutcome · +49mTwo commits pushed (fix + docs update) to code-actions/snippets.ts and README.md; confirmed no other docs needed changes.
VERDICT
I'd start by pointing straight at the file and the exact failing input rather than describing the symptom abstractly — that got us to the root cause (minSlashCount: 2) fast anyway. The one correction that mattered was killing the TUI box-drawing filter the agent invented on its own initiative; it solved a problem I hadn't asked it to solve and I'd rather keep the simpler behavior. Everything else — refactors, doc updates — went smoothly without intervention.