Skip to content

Develop - #2

Merged
padovanl merged 16 commits into
masterfrom
develop
Aug 21, 2026
Merged

padovanl merged 16 commits into
masterfrom
develop

Conversation

@padovanl

Copy link
Copy Markdown
Owner

No description provided.

The overlay is centred and sized to its longest line, so anything that
grows with the selection takes the whole box sideways with it. Landing
on "theme" did that three separate ways:

- the "3/12" position indicator appeared on the selected row only, so
  arrowing onto a row with choices added nine columns (82 -> 91);
- the value column was sized to the values in use, so stepping from
  "nord" to "tokyo-night" grew it by seven more;
- the title itself alternated between two lengths depending on whether
  the selected row had choices, and the box is sized to the longer of
  its title and its widest item.

Every column is now sized for the widest thing that could ever land in
it — including values only reachable by arrowing, and the note a row
shows while being edited — and each row is padded to that. The title is
constant; what the arrows do on the current row lives in the status bar,
which has no effect on the box. A little unused width is a much better
trade than the box moving under the cursor.

Measured across every row, every value the arrows can reach, and the
editing state: one width throughout. Confirmed the test fails against
the old behaviour.
Closing a pane is the one destructive thing in a multiplexer that
happens by accident constantly. Everything else here either asks first
(killing a window, quitting) or is harmless to repeat; a closed pane was
simply gone, in termdock as in tmux.

Ctrl-B Z brings the last one back: a fresh shell, in the window it came
from, started in the directory it was sitting in. The last 16 closures
are kept, so repeated presses walk back through them. It covers a shell
that exited on its own too, which is the case it mostly exists for — an
"exit" typed into the wrong pane.

What comes back is the place, not the process. Nothing can resurrect
what was running, the same limit session persistence already documents,
and it is not the expensive part: retyping the command is easy, while
working out which of four windows it was in and cd-ing three levels down
again is what actually costs. The cwd is captured in detachLeafIn just
before the pane leaves the tree, the last moment it can still be read
off the live process.

Every failure path leaves the entry on the stack — no room to split, a
zoomed window, a pane that would not start — so a pane is never lost to
an undo that could not happen.
The twenty-minute build, the test run, the deploy: jobs you start and
then go and do something else during, which is exactly when you stop
watching a pane you cannot see. Ctrl-B m marks a pane; the moment its
command exits and it drops back to a bare prompt, the terminal bell
rings and the status bar names it. An armed pane wears a [⏳] tag, so it
is visible rather than something to remember having done, and pressing m
again takes it back. It fires once and disarms, so a pane you keep
working in does not ring on every command.

Two things make this worth having over appending "; notify-send done".

It needs no shell configuration at all. termdock already asks the pty
which process group holds the foreground — the same reading that keeps
pane titles current — so "busy" is that name not being the shell's, and
"finished" is the transition back. The check rides along inside Frame,
which was already sampling exactly that per pane, so it adds no polling
and inherits the same cadence.

And it can be armed *after* the command is already running, which a
wrapper fundamentally cannot: you almost never know in advance that this
is the run that will take twenty minutes.

Arming a pane that is already idle deliberately waits for its next
command rather than firing at once, which is the only sensible reading
of arming it at a prompt.

tmux has no equivalent: monitor-silence watches for output going quiet,
which fires on a build that pauses to think and stays silent on one that
ends without a final line.
A terminal sees one undifferentiated stream of characters. It cannot
tell your prompt from the command you typed from that command's output,
which is why no multiplexer offers "jump to the previous command" or
"copy that command's output" — the information simply isn't there.

OSC 133 is the shell telling it, and termdock owns its own VT emulator,
so it can record the marks itself instead of needing the terminal
underneath to cooperate. That is the part tmux cannot match: it has no
emulator to record them in, and no way to add one.

  termdock shell-init [bash|zsh|fish]   # eval it from your shell rc

With marks present:

- { and } in copy-mode jump between commands, landing on the prompt with
  the command's output filling the screen below it.
- Ctrl-B O copies the last command's entire output — exactly the lines
  it printed, none of the prompt or the command itself, however many
  screens that spans. Asked mid-run, it gives what has printed so far.
- A pane whose last command failed carries its exit status, and its
  duration when that was more than a few seconds, in its title. Success
  adds nothing: a title is no place for noise.

The snippet is printed, never installed. A shell rc is a file its owner
has opinions about, and a program that edits yours behind your back is
one you stop trusting.

Marks are stored against a counter of lines ever archived rather than
against row numbers, so scrolling never has to renumber them — the
alternative is both slower and easy to get subtly wrong. Where lines
leave the screen *without* being archived (a resize that slides content
up, a scroll inside a custom region) nothing relates a mark to where its
text went, so they are dropped rather than left pointing at the wrong
line; the next command records a fresh set. Marks from the alternate
screen are ignored outright, since vim is not describing scrollback
anyone will navigate.

All three snippets were run against their real shells, not just
inspected: bash, zsh and fish each emit the full A/B/C/D cycle with the
right exit status for a command that succeeds and one that fails. The
bash one needs the most care — its DEBUG trap fires for every command in
a pipeline and for the prompt's own subshells, which is what makes
hand-rolled versions mark things that were never commands.

With no snippet configured there are no marks, and each of the three
features says so and names the fix rather than silently doing nothing.
The shell integration went in with a paragraph that assumed you already
knew what OSC 133 was for. Rewritten around the problem it solves —
every terminal is blind to where one command ends and the next begins —
with the actual keys, a worked example of retrieving a test failure from
five commands ago, and what the pane title looks like afterwards.

Writing that example turned up a real gap: Ctrl-B O always copied the
*newest* command, so walking back with { and then copying gave you the
wrong output — silently, which is the worst kind, because the paste
looks plausible. It now copies the command the copy-mode cursor is
sitting in, falling back to the newest at a live prompt. Being able to
walk back is pointless if copying ignores where you walked to.

Status bar segments lose their emoji. This is an alignment fix, not a
style one: the client right-aligns the trailing status text by counting
runes, and every emoji there had a rune count that differed from the
columns it occupies — 🧠 and 🔋 are one rune drawn two columns wide,
🖥️ is two runes (base plus variation selector) drawn as one. With any of
them enabled the clock sat a column or two off, varying with which
segments were on. Now "cpu 42%", "mem 61%", "bat +87%" (the "+" marking
charging), all one rune per column. The git segment keeps its  — a
Private Use Area glyph, one rune, one column, and the conventional way
to show a branch.

A test rejects emoji and variation selectors in segment text, so the
alignment cannot quietly regress; confirmed it fails with the brain put
back.
The emoji came out of the status bar because they misaligned it. The
real fault was the measuring: a terminal cell is not a rune, and
len([]rune(...)) is wrong in both directions — 🔋 is one rune drawn two
columns wide, 🖥️ is two runes (base plus a variation selector) drawn as
one glyph. Rather than restricting what may appear there, measure
properly: uniseg does grapheme clusters and East Asian width, and comes
in with tcell already, so it costs an import.

That was wrong when drawing too, not only when aligning. overlayText
advanced one column per rune, so anything following a wide glyph landed
on its second half and corrupted both — visible the moment a pane title
or window name contained one.

With the measurement fixed, icons are safe again, so the segments get
them back — but not the old ones. 🧠 for memory was a metaphor that
reads as "AI" before it reads as RAM, and 🖥️ for CPU depicts a monitor,
which is the one part of a computer it is not. They are now Nerd Font
glyphs matching the branch icon the git segment has always used:
microchip for cpu, database for mem, battery (or a bolt when charging)
for battery. One family instead of two, and one column each.

The width-predictability test stays and still passes: it rejects emoji
and variation selectors, which are the glyphs whose width a terminal may
disagree about. Private Use Area glyphs are exactly one column
everywhere, which is why they are the right answer for a status bar.
A fuzzy picker over every command run in any pane of the session, newest
first, with how each one exited and how long it took. Enter types the
chosen one back into the current pane.

Your shell history cannot be this, for three separate reasons: it is
per-shell, so what ran in the pane next door is invisible; it records
what you typed and not what happened, so the command that worked is
indistinguishable from the three attempts before it; and it is written
when the shell exits, so a pane still open has contributed nothing. The
session already knows all of it, because the OSC 133 marks say where
each command was and how it ended.

Read out of the panes own scrollback rather than accumulated as commands
run: the buffer is already the record, so there is no second copy to
keep in step, and what the picker offers is exactly what is still
scrolled back far enough to go and look at.

Enter types the command rather than running it. The list is full of
things that already happened, some of which failed, and running one
straight off a fuzzy match is how the wrong directory gets deleted.

Recovering the command text needed the marks to carry a column, not just
a line: OSC 133 B lands exactly where the prompt stops and what you
typed begins, and nothing else on that line distinguishes the two. Added
Mark.Col; without it the history listed the prompt along with every
command, which the tests caught immediately.

Repeats collapse to a single entry, since a list you scroll is useless
if the last thing you did fills it.
Typing into several panes at once is what you reach for when driving a
handful of machines together. tmux has it as synchronize-panes, and so
did termdock, but only as all-or-nothing over a window — which is a poor
fit for the actual job. The pane running your editor, or the one holding
the output you are comparing against, is precisely the one that must not
receive the keystrokes, and having to move it to another window first is
enough friction that the feature goes unused.

Ctrl-B y still toggles the whole window exactly as before. Inside the
overview, where you can see every pane at once, space adds or removes
the one under the cursor and the tiles say which are in. An empty
selection still means "all of them", so nothing changes for anyone using
it the old way.

Two details that would otherwise be small annoyances: picking a pane
turns synchronization on by itself, since choosing targets and then
finding nothing happens because a separate switch was off is a puzzle
nobody enjoys; and deselecting the last one turns it off rather than
falling back to "everything", which is what an empty set would
otherwise be read as and is the opposite of what was just asked for.

The status bar reads [SYNC 3/7] when only some panes are in — before
pressing Enter into several machines at once, the number is the thing
you want confirmed. Closed panes are pruned from the set so the count
never names something that no longer exists.
…yout

Recovery brought back the layout and every pane's working directory, and
then handed you four empty prompts. That is a strange half-restore to
live with: the session looks exactly right and has forgotten everything
it was showing, so the stack trace you were reading when the machine
went down is gone.

The snapshot now carries the tail of each pane's screen — 200 lines —
written back into the restored pane, so a recovered session opens on
what you were actually looking at.

Stored as plain text rather than styled cells, on purpose. A snapshot is
restored by writing it into a new terminal, and replaying arbitrary
styling into a shell that is already printing its own prompt is a good
way to leave panes in colours nobody chose. Exact reproduction is not
available at any price anyway: the program that drew it is gone. Legible
content is the goal.

Written to the emulator rather than the pty — sending it to the shell
would have the shell try to run it — and before the pump starts, so the
text is on screen when the first prompt arrives instead of racing it.
Trailing blank lines are dropped: the empty bottom of a screen is not
content, and keeping it would push the restored text off the top.

Bounded deliberately at 200 lines, since these are rewritten
continuously rather than saved once. Measured on a pane with 500 lines
of output: an 11 KB snapshot.

tmux needs tmux-resurrect to restore the layout at all, and even that
does not bring the contents back.
The question was whether you can create a session on a remote machine,
attach to it from a third one, and let colleagues watch read-only.
Verified: the first two already work with nothing added — a session's
socket lives on the machine that owns the panes, so "remote" is SSH:

  ssh -t server termdock new -s work
  ssh -t server termdock attach -t work
  ssh -t server termdock attach -t work -r

The read-only client was confirmed here receiving a session's output
through a pty, which is exactly what "ssh -t" provides.

Letting *other people* watch is the part that did not work, and the
reason is access rather than capability: the socket is 0600 inside a
0700 directory, so attaching means being you on that machine. Confirmed
by trying it as another user. Handing over your login to let someone
watch is not sharing.

SSH already solves that, with a forced command:

  restrict,pty,command="/usr/local/bin/termdock attach -t work -r" ssh-ed25519 ... alice

Alice's key can then do exactly one thing. Every option there was
checked against the installed OpenSSH 8.9 manual rather than written
from memory; "restrict" is the modern form that denies everything and
lets "pty" put back the single capability the client needs.

Documented rather than automated, and deliberately left as SSH's job.
Authentication and encryption are the parts that must not be got wrong,
and a bespoke listener with a hand-rolled token would be a downgrade
wearing the word "feature". Worth saying too that read-only is enforced
server-side, so a modified client cannot type either — which is what
makes handing out that authorized_keys line safe.
Two things that came out of the same complaint: you cannot tell your
panes apart, and you cannot tell why a setting did nothing.

Panes were titled after whatever process held their foreground, which is
"bash" for every idle one — useless exactly when you have six of them.
Ctrl-B . gives one a name that wins over the process name, shows up in
the jump picker so the pane becomes findable by it, and survives a crash
along with the rest of the snapshot. An empty name clears it, putting
the pane back to being named after what is running, which is the obvious
reading of confirming an empty prompt. Windows could already be renamed;
panes could not.

`termdock doctor` checks the things that fail *silently*. Nearly every
setting here is deliberately lenient — an unrecognised line is ignored
so a typo can never stop a session starting — and the cost of that trade
is a class of problem that presents as "I set it and nothing happened"
with nothing anywhere saying why. A misspelled theme is exactly that,
and it cost real time yesterday before anyone thought to suspect the
spelling.

It reports what it found rather than a bare verdict, so the output is
useful in a bug report from a machine you cannot see, and every warning
carries the thing to do about it — a warning without a fix has only
wasted the reader's time. There is a test asserting that.

The theme check reads the config file rather than the parsed Config,
because Config.Theme is only filled in when the name was recognised, and
the unrecognised case is the entire point.
A session snapshot is automatic and about surviving a crash. A layout is
deliberate and about starting the same working set again tomorrow, on
another machine, or handing it to a colleague — which is the job people
currently leave termdock for, using tmuxinator or teamocil: an external
tool, a YAML file, a dependency.

  termdock layout save -t work dev
  termdock layout apply dev
  termdock layout ls / rm

It stores the shape — windows, splits, ratios, names — plus each pane's
working directory and pane name, so applying rebuilds the working set
rather than an empty grid you then repopulate by hand.

Applying *adds* to the session rather than replacing it. A layout is
something you reach for to start work, and having it silently close
panes you had running — with no undo for a whole session's worth — would
make it a thing you approach nervously. Closing the old windows is one
keystroke each and your decision.

The tree is rebuilt with the same guards restoring a snapshot uses, for
a sharper reason here: a layout file is hand-editable and meant to be
shared, so a zero ratio or a split type that is neither vertical nor
horizontal is an input to expect rather than a corruption to dismiss.
layout.Compute has no case for those and would leave both children at a
zero-sized rect — two real shells holding ptys, drawing nothing,
reachable by nothing. There is a test that builds exactly that file and
asserts every pane comes back with a usable rect.

Verified end to end against a live daemon: a two-window layout with a
split and a named window saved, then applied to a different session and
rebuilt alongside what was already open.
Every command in the session on one shared scale, oldest first, with a
bar for its span:

  23:46:40  go build ./...   ██████████··················  31ms  0:api › 1
  23:46:40  go test ./...    ·········███████████████████  60ms  ✗1  0:api › 1
  23:46:40  tail -f app.log  ···························█  running  1:ops › 1

No multiplexer offers this, and not because nobody wanted it: a terminal
receives an undifferentiated stream of characters and has no idea a
command even happened, let alone when it started. The OSC 133 marks give
termdock both timestamps per command, which is what makes the view
possible rather than merely unimplemented.

It answers the question you ask after something has gone wrong and the
evidence is spread across four panes' scrollback: was the build still
running when I started the migration? Overlapping work reads as overlap,
because every bar is drawn on the same scale.

Commands still running are included and marked, since they are usually
the ones being asked about.

A command too brief to fill a column still gets one. Rounding it away
would draw an empty row, which reads as "nothing happened here" — the
opposite of true, and exactly the kind of quiet lie a picture must not
tell. There is a test pinning that against an hour-long scale.

The duration test measures real elapsed time between the start and end
marks rather than asserting durations into existence, so it would catch
the bars being decorative.
…ADME

The favicon was 🐳, which is Docker's mark and not ours to borrow —
a confusion worth avoiding rather than explaining. It is now a small
drawing of a pane layout: an outer border, one vertical split, one
horizontal split in the right half, which is what termdock actually
draws. It describes the product instead of borrowing someone's animal,
and needs no emoji font. The README title and the session's goodbye
messages use ▦ for the same reason.

The site had gone stale: shell integration, the command history, the
timeline, reopen-pane, watch-done, pane naming, selective broadcast,
saved layouts, scrollback restore and doctor were all in the README and
none of them in docs/index.html. Twelve cards added in the existing
style, so the page and the README now describe the same tool.

The README also gained the four sections it was missing — timeline,
saved layouts, naming a pane, and doctor — each with what it looks like
rather than only what it does.

Both files are getting long (1327 and 644 lines). Splitting them is the
next thing to do, and better done as its own change than smuggled into
this one.
Ctrl-B L already logs a pane, but one at a time and to a path it picks.
That is the wrong shape for the case this exists for: you are about to
reproduce something across six panes and want the lot on disk, in a
directory you can hand to a colleague or attach to a ticket. Six
keystrokes and six timestamped filenames in a state directory is not
that.

Ctrl-B A asks where, then logs every pane in the window, one file each.
Pressing it again stops them all.

The names are the part worth caring about. They use the session, the
window, and the pane's own name where one was given —
deploy-feat_login-api_server.log — because a directory of api.log,
worker.log and db.log is worth something an hour later and one of
p3-20260821-154233.log is not.

Three things that would otherwise bite:

- names are sanitised for the filesystem, so a window called feat/login
  writes feat_login rather than trying to open a directory that is not
  there;
- two panes sharing a name get numbered, since nothing stops you calling
  both of them "logs" and one file quietly receiving two panes' output
  would be worse than an ugly suffix;
- a pane already being logged by hand is left alone rather than
  restarted, which would truncate a file someone opened deliberately.

The prompt is prefilled with the default log directory so the common
case is Enter, ~ is expanded, and the directory is created rather than
demanded — being told "no such directory" immediately after saying where
you want the logs is a pointless round trip.

Documented in both the README and the site.
The landing page sells the tool and does it well, so it is untouched
apart from moving its CSS into a shared file — byte for byte the same
stylesheet, now reachable from other pages instead of copied into each.

What was missing is somewhere to actually learn the thing. Six pages:

  getting-started   install, first session, panes, windows, and what
                    detaching actually means — the one idea worth trying
                    deliberately before anything else makes sense
  keys              all 45 bindings, grouped, plus how to rebind
  shell-integration OSC 133 explained from the problem it solves, with a
                    worked example of retrieving a test failure from five
                    commands ago
  workflow          history, timeline, notify-on-finish, pane names,
                    window logging, selective broadcast, reopen, layouts
  configuration     every setting, the eleven themes, live editing,
                    doctor, crash recovery, the input log
  remote            SSH sessions, read-only viewers, and sharing via an
                    authorized_keys forced command

They share one shell (build.py) rather than six copies of a header: a
manual whose pages drift apart in navigation is one people stop trusting
to be complete. Each page's table of contents is generated from its own
headings in the same pass that adds their ids, so the two cannot
disagree — which is how a hand-kept contents list normally rots.

Coverage is checked against the source rather than by eye: a script
reads every binding out of bindings.go and every subcommand out of
main.go and asserts each appears in both the README and the manual. All
45 keys and every CLI verb are covered. That check found select-window
missing from the manual, which reading it would not have.
@padovanl
padovanl merged commit d586c08 into master Aug 21, 2026
4 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