Skip to content
PidebugCLI & tooling11 files · +1188 −486

Fix files-widget freeze/sluggishness on large folders (pi extension, TS)

Session from pi-extensions-sessions on Hugging Face by thomasmustier · MIT · condensed by Coders Talk

1h 34msession
1interventions
GOAL

Investigate and fix performance issues in a terminal file-browser extension: sluggish cursor response during navigation and an indefinite freeze when opening large folders like the home directory.

  1. Prompt · +0
    files-widget has sluggish navigation and freezes indefinitely opening large folders like ~/. Please investigate.
  2. Agent did · +0m
    Explored file-tree.ts, browser.ts, viewer.ts, git.ts; added a line-count cache with a size cap (MAX_LINE_COUNT_BYTES), tracked lineCountComplete for aggregated totals, and made browser header stats compute once instead of per render.
  3. Break · 13h 05m away, not counted
  4. Prompt · +10m
    Can you explain your edits please
  5. Agent did · +11m
    Walked through the caching/size-cap fix file by file with line numbers, then bumped files-widget to 0.1.7, updated CHANGELOG, committed, tagged, and pushed the performance fix.
  6. Prompt · +20m
    Let's publish to npm and add a step to RELEASING.md: whenever we bump version, publish both the extension-specific npm package and the overall pi-extensions npm package.
  7. Agent did · +20m
    Updated RELEASING.md with npm publish steps and published @tmustier/[email protected] to npm; noted the root pi-extensions package is private/unversioned so wasn't published.
  8. Intervention · +20m
    Noticed an unintended README.md diff had crept into the staged changes and ran git checkout to revert it before committing.
    Why: I saw a README change I hadn't asked for mixed into the commit, so I reverted it before committing the real fix.
  9. Prompt · +40m
    I still get a freeze doing /files in my home folder. Let's think through why, and how to fix it, without touching any code yet.
  10. Agent did · +41m
    Discussed root causes (synchronous full-tree scan, per-file reads, full list construction) and iterated through design options with the developer: async line counts with loading indicator, git-as-source-of-truth for repos, and progressive scan with safe mode fallback for huge/non-git folders.
  11. Agent did · +1h 7m
    Rewrote file-tree.ts to build from git file lists for repos, added async batched line-counting and filesystem scanning with a safe-mode/partial indicator for large non-git folders, updated browser.ts extensively, bumped version to 0.1.8, updated docs, committed, and published to npm.
  12. Outcome · +1h 34m
    Shipped files-widget v0.1.8: 9 files changed (654 insertions, 186 deletions), committed, published to npm, and tagged/pushed.
VERDICT

Next time I'd start the first prompt with the actual failure mode (freeze on huge folders) plus a constraint like 'don't break full-repo navigation with diff counts', since that shaped the whole design conversation later anyway. Thinking through the design with the agent before touching code, then doing async line counts + git-as-source-of-truth + safe-mode scanning, was what actually fixed the freeze rather than the first pass which only added caching. The one correction that mattered was catching a stray README diff before commit — otherwise unrelated changes would have slipped into the release.

I tried this · 0

Discussion · 0

How Builds work