Skip to content

refactor: lift the session out of the web module, and draw a frame in one write - #13

Merged
whackur merged 6 commits into
code0xff:devfrom
whackur:refactor/codebase-cleanup
Aug 1, 2026
Merged

refactor: lift the session out of the web module, and draw a frame in one write#13
whackur merged 6 commits into
code0xff:devfrom
whackur:refactor/codebase-cleanup

Conversation

@whackur

@whackur whackur commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator

Structural cleanup with no intended change in behaviour, plus one
performance fix that fell out of it.

Net effect across the range: 297 files, +7346 / -8111.

The session is its own thing now

src/web/viewer/ had grown to hold state that has nothing to do with
serving HTTP — the repository catalog, the preference store, the
size-ownership rules, config reload. A browser tab and an attached TUI
are both clients of that state, so it moved out from under the web
module and into src/session/:

  • web/viewer/catalog/session/catalog/
  • web/viewer/prefs/session/prefs/
  • web/viewer/session.rssession/operations.rs
  • web/viewer/{reload,size_owner,runtime}session/…

src/cli.rs split along its subcommands (cli/{attach,daemon,init,stop}.rs),
and the PTY and git-tree test files split by what they cover
(pty_tests/{identity,lifecycle,relaunch}.rs,
git/tree/tests/{listing,path_security,search}.rs) rather than sitting in
one file each.

The viewer's App component stopped being the whole app

viewer-ui/src/pages/App.tsx lost 265 lines to hooks that own one concern
apiece — useRepoWorkspace for the repository/tab state, and
terminalSocketMessages.ts for the socket protocol that useTerminalSocket
had inlined. Same protocol, decoded in one place instead of inside the
component that consumes it.

Comments

The first commit removes roughly a thousand lines of comment that restated
the line below them. What is left is the reasoning that is not recoverable
from the code — which is the standard the rest of the tree already holds.

One behaviour change: perf(tui)

io::stdout() is line buffered and a Ratatui frame carries no newlines, so
a frame left the process in whatever pieces the buffer happened to cut it
into. On Windows each piece is a separate console write for the host to
re-parse — the expensive path, and the one where a frame can tear across
writes. A BufWriter sized for a full-screen redraw with per-cell styling
makes it one write per flush, which Ratatui already performs exactly once
per draw.

Verification

All four gates pass locally on Windows (build, test, clippy -D warnings, fmt --check); CI runs them on macOS, Linux, and Windows.

whackur added 6 commits August 1, 2026 15:22
`io::stdout()` is line buffered and a Ratatui frame carries no newlines,
so a frame left this process in whatever pieces the buffer happened to
cut it into. On Windows each piece is a separate console write for the
host to re-parse — the expensive path, and the one where a frame can be
torn across writes.

A `BufWriter` sized for a full-screen redraw with per-cell styling turns
that into one write per `flush`, which Ratatui already performs exactly
once per `draw`. The terminal type is named `TuiTerminal` and built by
`open_terminal`, so the three screens that draw share one definition
rather than spelling the backend out apiece.
@whackur
whackur merged commit 79dad47 into code0xff:dev Aug 1, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant