Devlog #6
Last time I promised a virtual filesystem. It’s here — plus window snapping, which sneaked in because I got tired of dragging windows into place by hand.
One tree, two apps
The whole filesystem is a single fs.ts file: a nested tree of directories and files, no disk involved. What makes it worth building is that Files and the terminal both read from that same tree. Click into ~/Projects in Files, then type cd ~/Projects in the terminal, and you’re looking at the same list. Neither app owns the data, so they can’t drift apart.
Files ended up as a three-pane Finder: places sidebar, listing, preview at the bottom. Folders are sorted before files, hidden dotfiles are filtered out unless you ask. App bundles carry an app field, so selecting Terminal.app and hitting “Open in app” launches the real window — the fake filesystem reaches back into the real OS, which is a nicer trick than it has any right to be.
The terminal grew pwd, ls, cd, cat, and a smarter open. Path handling is the part nobody sees: one normalizePath swallows ~, ., .., and relative paths, spits out a clean absolute path, and every command routes through it. Write that once and cd ../../Users/nyancat just works. Skip it and you’re writing string hacks forever.
I also stash the current directory on every input line, so scrolling back up shows the prompt exactly as it was — prism ~/Projects $ and not a rewritten one. Small thing. Feels wrong immediately when it’s missing.
Throwing windows at walls
Snapping turned out to be a two-line idea buried under a plumbing problem. Drop a window near the left edge and it fills the left half; right edge, right half; top edge, full screen.
The catch: the drag hook only knew where the window ended up, not where the cursor was. Those are different by however far from the titlebar’s corner you happened to grab. Drag by the right side of the titlebar and the window’s own x never gets close to the left edge, so nothing snaps and you sit there wondering if you broke it. Fix was to pass the pointer coordinates along with the final position and judge the zone by the cursor.
The bug I found while I was in there
Opening the window manager back up, I noticed the layout restore was saved ?? app.initial — and move() only writes {x, y}. So move a window, close it, reopen: the saved partial wins, width and height come back undefined, Math.min(undefined, vw) gives NaN, and the window collapses to the size of its own text. It only shows up if you move a window without ever resizing it, which is why it survived this long.
Merging over the defaults instead of replacing them fixes it, and I bumped the storage key to prisma-layout-v2 so old broken entries get ignored rather than restored.
Where PrismaOS stands
- Virtual filesystem shared by Files and the terminal — same paths, same contents
- Files app: sidebar, listing, preview, and launching apps straight from bundles
- Terminal:
pwd,ls(with-a),cd,cat,open <app|file> - Window snapping to left, right, and full screen, plus the layout NaN fix
Next up
Wrapping up. Version bump to 0.3.0, a pass over the leftovers, and shipping the whole thing.
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.