You are browsing as a guest. Sign up (or log in) to start making projects!

1h 26m 18s logged

Core State Engine — tabTracker.ts

I finally started the actual VS Code extension part of Tab Rot after planning everything out. Today’s goal was just the core state engine — basically tracking when each file was last visited and making sure it survives if you close and reopen VS Code. I made a tabTracker.ts file that has a TabState interface and a TabTracker class. The interface is super strict with the decay stages locked to 0 | 1 | 2 | 3 which felt like good TypeScript practice but also kind of a pain later.The tracker uses a Map to hold everything in memory, but it loads from and saves to context.workspaceState so the data persists across restarts. I added all the main methods — touchTab() to mark something as visited right now, removeTab() when a file closes, getDecayStage() to figure out how rotten a tab is based on the time thresholds, and getDecayedTabs() to spit out everything that’s stage 1 or higher sorted by how dead it is. I also threw in restoreTab() and restoreAllTabs() for when you want to pretend you never abandoned that file.I set it up to read the decay thresholds from VS Code settings (tabRot.decayThresholds) and even made it hot-reload when you change the config without restarting the whole editor. Oh and I added a debounced save because I realized it would be stupid to write to disk every single time you switch tab

0
6

Comments 0

No comments yet. Be the first!