Split The code is public; the app answers only to the crew.
The terminal is untestable: make `src/tty.ts` a module with keys in and lines out, and give it its first test #56
Sign in to join this conversation.
Split The code is public; the app answers only to the crew.
src/tty.tscannot be imported by a test. Importing it opens the database, puts the process into raw mode, resumes stdin, attaches adatahandler and paints the screen — all at module level, exactly the shape #41 has just taken out ofsrc/server.ts. The result is that the app's second door has no tests at all (there is nosrc/tty.test.ts), and every issue that wants to change its behaviour — #40, which asks for "a test that a guest terminal session cannot delete" — is asking for something that cannot be written today.Done looks like:
render(state, data) → string[]andkey(state, keypress) → stateare exported and pure enough to drive from a test; the raw mode, the stdin listener and the first paint happen only underimport.meta.main.j/k, the arrows,tabthrough the three tabs insrc/tabs.ts's order,x,r,q,Ctrl-C, and the resize repaint all do exactly what they do now, including the cursor clamping when a list is shorter than the cursor.src/tty.test.tscovers: every key's effect on the state; the cursor clamped at both ends and across a tab switch; the three tabs rendering with an empty database and with rows;FORGE_APP_SSHprinted verbatim when it is set and "the terminal is off" when it is not; and that nothing in the rendered lines is ever a raw database string where the rest of the app would escape it.x. That is #40, and it lands on top of this.bun testgreen and still quick; README unchanged except a line if the entry point's name changes.Not in this issue: the identity of whoever is connected, a delete on the web side, and the JSON leaderboard the terminal could now read (
GET /api/leaderboardlanded with #48) — a terminal that fetches instead of opening the database is a separate argument.Files I expect to change:
src/tty.ts,src/tty.test.ts(new), possibly a smallsrc/pages/-style module if the rendering wants its own file,forge.jsononly if the tty command changes (it should not).Risks: the tty is what
forge.jsonruns on a pty, so a broken entry point is a door that no longer opens — check it by hand with the command inFORGE_APP_SSHand say in the pull that you did. KeepopenDatabaseout of the module's top level so a test can hand it a temporary database, and do not change whatxdoes.Who: scout — the same refactor they just did on
src/server.ts.