Commit Graph
1449 Commits
Author SHA1 Message Date
l0ng-ai 9fb4e0fe77 fix(update): read the update prompt's answer by the layout it actually showed
The elevation rule was spelled out twice — once to decide whether to offer a
"next launch" button, once twenty lines later to decide whether answer index
1 meant that button. With elevation in play there is no such button and
index 1 is "Later", so the two must agree exactly.

Nothing held the second copy. Dropping `!needs_elevation()` from it turned
every "Later" on an elevation-needing update into a staged install: the user
declines, and the app schedules the thing they declined for the next launch
— the one install it already knows it cannot carry out unattended, which is
why the button was withheld in the first place (#504).

Derived once now and read in both places, so the reader cannot believe in a
button the layout did not draw.
2026-08-24 00:06:13 +08:00
l0ng-ai e787602862 test(render,images): a mark in the last column, and one image in two places
Two gaps of the same shape — a compound condition whose second half no
fixture ever reached.

`segment_row` asks whether the cell after a marked one is a wide char's
spacer, and that is the only read in the loop that indexes the row directly
instead of going through `get`. Every mark fixture put something after the
marked cell, so the bound was never the thing under test. A mark in the last
column — an accented letter typed at the right margin — panics without it,
mid-frame, taking the window with it. Now covered for the wide-spacer
lookahead, the sara-am lookahead beside it, and a row of exactly one cell.

`ImageStore::place` treats identity as the (id, placement) pair, because
kitty lets one image be shown in several places at once and a shell drawing
the same icon down a column sends exactly that. Every fixture used placement
0, so matching on the id alone passed everything: an image shown three times
would have rendered once, at the last spot it was sent to. The `placed(id,
placement)` helper already took the parameter — nothing had varied it.

The placement half of that condition turned out to be held already, by the
delete-and-retire tests. Only the id half was open.
2026-08-24 00:03:13 +08:00
l0ng-ai e1f9a890a8 refactor(pane): decide a command boundary once, in the arm that tests it
`cmd_finished` and `turn_finished` were each a verbatim restatement of a
condition the `match` five lines below already decides. Two spellings of one
rule, free to drift the moment either is edited — and the drift would show
up not here but downstream, where both flags drive the source control edge
refresh.

Neither copy was held by a test. Weakening `cmd_finished` to `!running`
fires the edge on every poll of an idle pane, so every pane re-reads git
status continuously while nothing is happening; weakening it the other way
fires it throughout a command and never at the boundary, so the working tree
a command just changed is the one state never picked up. Nothing failed for
either.

Setting the flag inside the arm makes both unrepresentable rather than
merely detectable: there is no second condition left to get wrong, and the
arm itself is held by the notification tests.

`turn_finished`'s other half was already unreachable — `poll_agent_status`
returns early when the status has not changed, so `status == Done` implies
`prev != Done`. Now stated once, where that is evident.
2026-08-23 23:56:07 +08:00
l0ng-ai 6de9803028 test(install): a directory where the remote binary belongs is not a binary
`usable` asks two things of an existing path — not a directory, and carrying
the executable bit — and only the mode half had a fixture. A directory has
that bit as a matter of course, 0755 being what `mkdir` gives you, so
dropping `!stat.is_dir` left every directory reading as an installed server.
The installer would skip the install and hand `ensure_daemon` a path nothing
can exec: the remote never comes up, says nothing useful about why, and
never tries again, because as far as it is concerned the binary is there.

A directory at that path is not exotic — an interrupted install, an `scp -r`
aimed a level too high, or a hand-made `~/.local/share/tty7` all leave one.

The same predicate guards `published_binary_serves_us`, and there it is
deliberately not asserted: dropping it falls through to a probe that execs
the path, which fails on a directory and reaches the same answer a round
trip later. Equivalent in production, so a test would pin the fake rather
than the behaviour.

Also considered and left alone: `binary = added == "-" && removed == "-"` in
the numstat parse. Git emits the two dashes together or not at all, so one
without the other is input that cannot arrive.
2026-08-23 23:43:12 +08:00
l0ng-ai d42fae9de8 test(remote,scm): hold both halves of the backlog and completeness rules
Two compound conditions where one half decided every existing fixture, so
the other was never asked anything.

`remote.rs` exempts a frame larger than the whole backlog bound — a paste is
whatever the clipboard holds — but only onto an *empty* queue: a second one
arriving before the first has moved a byte is a link that has stopped
reading, and letting it through too trades the bound for a heap that grows
five megabytes at a time. The existing paste test drains the peer, so the
bound is never reached and the empty-queue half never matters. Dropping it
left a stalled link accepting oversize frames forever, and nothing failed.

`log.rs::load_page` calls a page complete only when git answered with fewer
commits than asked for *and* the parse read everything git answered with.
The truncation half had a test — of `parse_log`, whose doc comment promises
`load_page` turns the flag into `complete: false` while asserting only the
flag. Nothing checked the promise. A graph cut at MAX_RECORD would have read
as the end of history and frozen paging there, the commits below it
unreachable with nothing on screen to say why.

Both tests fail against the mutation and pass against the code as written.
No production change: the conditions were right, only unheld.
2026-08-23 23:38:21 +08:00
l0ng-ai 83544bf822 test(daemon): releasing one workspace leaves the connection's others alone
`release` and `release_conn` are two operations on purpose: one lets go of
a single workspace, the other of everything a connection holds when it
disappears. Dropping the workspace half of `release`'s filter collapses
the first into the second, and the suite stayed green.

What that costs: a client detaching from one remote workspace silently
loses its hold on all of them, and the far end considers them free for
somebody else to take. The connection half of the pair *was* held — only
the pairing was not, which is the shape every recent find has had.

Confirmed by dropping it: the test fails on the workspace that should
still have been this connection's to release.
2026-08-23 23:28:48 +08:00
l0ng-ai de20bb696f test(tab-strip): a short label that still does not fit is elided, not a panic
The head candidates for eliding include a hardcoded 6 and 3, and
`longest_tail` computes `cells.len() - head_n`. On a label with fewer than
six clusters that subtraction underflows, so the filter keeping a
candidate within the label is the whole of what stands between a narrow
tab and a crash.

Nothing reached it. The long-branch cases have clusters to spare, and
"main" returns early because it fits — a label has to be *both* short and
too wide, which is an ordinary tab in a narrow column.

Confirmed by dropping the bound: the test panics at the subtraction rather
than failing an assertion, which is what the guard was there for.
2026-08-23 23:23:44 +08:00
l0ng-ai 1fcc282e27 test(diff): a ref name is not an object id however long it is
`short_rev` cuts a rev to eight characters only when it is forty-plus
characters *and* all hex. Every case in its test is shorter than forty, so
the length half decides them alone and the hex half never gets a say.

A ref name that long is the only input that asks it anything, and they
exist: `origin/feature/a-thoroughly-descriptive-branch-name` is fifty-one.
`DiffSource::Range` puts two revs in one header, so losing the hex test
turns a branch comparison into "origin/…origin/".

Also pinned: an oid-length string with a single non-hex character is still
a name, which is the boundary the `all` is there to draw.
2026-08-23 23:16:37 +08:00
l0ng-ai b3f87fd8a1 test(links): pin the two edges of a candidate that nothing held
`file_candidate_at` decides what text in the grid is clickable, and every
existing case walks the happy path — a path-shaped token clicked in the
middle of itself. Two of its arms could be removed with the suite green:

The trailing colon a compiler prints before its message. `src/main.rs:` is
not a filename, and a candidate that keeps the colon names nothing, so the
text simply never underlines.

And that the span a candidate reports contains the click. Trimming moves
the edges inward, so a click on punctuation that was trimmed away is a
click on nothing.

Two neighbouring guards are deliberately not asserted. Mutating them
survived, and checking why showed both to be equivalent mutations rather
than gaps: `url_span_at`'s whitespace check is a fast path, since a token
spanning a space fails the scheme test downstream regardless; and
`location.path.is_empty()` has no input that reaches it, because `":42"`
parses as the path `":42"` and a token trimming to nothing is refused a
line earlier. A surviving mutation is a question, not a finding, and the
answer here was no.
2026-08-23 23:11:10 +08:00
l0ng-ai c7fd8bed96 test(links): the two spellings of ~ that nothing reached
`expand_home` has three arms and only the middle one was covered. A bare
`~` is a link to the home directory — nothing requires a file of it, since
`require_file` is false without a line number — and `~\` is the same path
where the separator is a backslash.

Dropping either left the whole suite green while the link resolved to a
literal `~` joined onto each root in turn, which names nothing, so the
click would find no file and the text would never underline.

Also pinned: a `~` that begins something else is not a home reference.
`~tmp` is a filename and `~user` is an expansion this deliberately does
not perform, so both must survive unexpanded — which is what keeps the
bare-`~` arm from being written as a prefix match.
2026-08-23 22:59:16 +08:00
l0ng-ai ded3f822e5 test(remote): a Take Back is due even when an attach was already sent
`reclaims_due` says what lands in it: "a Take Back sits in `reclaiming`
until an attach answers for it", *and* a workspace nobody has attached
over the link that is up now. Two reasons joined by `||`, and only the
second was held.

Dropping the `reclaiming` half left the suite green while Take Back did
nothing for any workspace this client had already sent an attach for —
which is every workspace it is currently showing, so the feature would
have been inert exactly where it is used.

The second of the two gaps the fixed mutation harness turned up, and like
its neighbour it cannot be reached by driving the app: a remote link
cannot be opened from here at all, so the test is the whole safety net.
2026-08-23 22:40:43 +08:00
l0ng-ai 6366ae131f test(remote): a link still connecting is not forgotten with its profile
`link_alive_or_connecting` decides whether a machine entry survives its
SSH profile being deleted, and says why: the connection holds an
authenticated spec rather than a profile reference, so forgetting the
entry "would release the link under any window still attached to it".

It is two halves and only one was held. Dropping the `LinkState::Connecting`
arm left the suite green while a profile deleted mid-connect pulled the
link out from under a window that was in the middle of getting it.

That half cannot be reached by driving the app from here: opening a
remote link is GUI-only and `tty7 machine connect` reports itself
unimplemented, so the test is the entire safety net for it.

Found only after fixing the harness. A restore had failed silently
earlier — the replacement's anchor was no longer unique and the error was
suppressed — so a mutation stayed in the file and every later round was
"caught" by the leftover rather than by its own change. Re-run against a
verified-clean baseline, two of nine results reversed. The harness now
refuses to start on a dirty tree and checks the file is clean again
afterwards.
2026-08-23 22:37:18 +08:00
l0ng-ai bb73aacc7f test(ssh): a negated Host pattern keeps the block off that alias
OpenSSH reads `Host *.example.com !secret.example.com` as "everything
under example.com except that one", and people write it to keep a
production host off a wildcard's shared user and key. Nothing held the
negation at resolution — disabling it left the suite green while
`secret.example.com` picked up the wildcard's `User` and `Port`, and by
extension its identity file. The connection still succeeds, as somebody
else.

`import_skips_match_blocks_and_negations` covers what *import* makes of
such a block. This is resolution, which is the path that decides what a
connection actually uses, and the two go through different code.

Found by mutating the free predicates no test names directly. Most of
that list is covered through their callers — `is_bare` by `quote_as`,
and so on — so the list is a place to aim mutations, not a list of gaps.
Of the batch tried, this was the only one that survived: the smart-select
predicates, the drop-conflict logic that stops a copy overwriting
unasked, and `unstage_prefix`'s unborn-HEAD branch were all held.
2026-08-23 21:54:04 +08:00
l0ng-ai b4c0cb6254 test(update): the staging sweep matches a name, not a substring
`only_our_own_staging_directories_are_swept` covered names with nothing of
ours in them — `tty7.app`, `.Trash`. It never covered a name that
*contains* the prefix without starting with it, which is the one way the
predicate can be weakened while still looking right.

That distinction is worth holding here more than most. On macOS
`stage_roots` is the parent of the app bundle — `/Applications` for an
ordinary install — and whatever matches is handed to `remove_dir_all`.
Relaxed to `contains`, the sweep would take `my-tty7-update-backup` or
`Adobe tty7-update-helper` on the strength of a substring.

Found by mutation. Three others in the same batch were already held: the
unborn-HEAD branch of `unstage_prefix`, the `-f` that lets `rm --cached`
drop a staged-then-edited file, and the liveness check that keeps the
shell-scratch reaper off a running daemon's directories.
2026-08-23 21:40:45 +08:00
l0ng-ai 717ad23fbe test(tabs): hold the half of a bulk close that spares a live SSH session
`tab_keeps_unclosed_work` is two halves — a tab holding an unsaved buffer,
and one holding a connection whose profile asked to be warned about — and
only the first was held by a test. Dropping the SSH half left the whole
suite green while "Close Other Tabs" began taking live sessions without
asking, which is the one thing a bulk close is documented not to do.

Nothing could reach that gate from a test before. `leaf_is_warn_ssh` reads
the pane's SSH phase, and reaching `Connected` for real wants a server, a
handshake and a channel — so a `#[cfg(test)]` seeder sets the one value
the gate actually consults, in the same spirit as
`editor_seed_dirty_file_for_test`.

Found by mutation: of the four conditions tried across `settle_save` and
this, three were already caught — a stale save marking the buffer clean, a
failed save requeueing, and a tab with unsaved edits being bulk-closed.
This was the one that was not.
2026-08-23 21:35:18 +08:00
l0ng-ai 44ce34a978 refactor(tree-sync): one definition of the panes a window answers for
`settle_census` and `sweep_parked` each built `parked ∪ spawned` from the
state, separately. I introduced that duplication myself when I added the
first of them earlier on this branch, by copying the shape of the second.

They are not interchangeable readings. One decides whether the tree is
worth pulling, the other which panes to end — so drift means either
ending a pane the census never weighed, or pulling for one the sweep will
not judge. `census_of` is now the single answer to "what is this window
still holding".

Which also made the gap visible. Mutating the census showed the `spawned`
half held by nothing: `the_census_holds_the_panes_this_window_made` read
`s.spawned` straight off the state, so it proved the set was filled in
and never that the decision reads it. Dropping `spawned` from the census
left the test green while a pane spawned and not yet in the tree went
back to being invisible to the sweep — which is the whole of the stray
shell leak that set exists to close.

It asserts through `census_of` now, on both halves, and each fails when
dropped. `stranded_of`'s two conditions were already held.
2026-08-23 21:27:23 +08:00
l0ng-ai f6e7e321ae test(scm): hold the two halves of discard-all nothing was holding
Mutating `discard_all_ops` left two conditions standing.

The `-d` on `git clean`. Porcelain v2 names an untracked directory with a
trailing slash, and that slash is the whole of how this decides whether
to recurse. Measured against real git: `clean -f` removes loose.txt and
leaves newdir/ standing; `clean -fd` takes both. Without the flag,
"Discard all" quietly leaves every untracked directory where it was —
not what the button says, and not what its own confirmation described.

And the filter that drops a path git cannot be given. A name that is not
UTF-8 has no pathspec, and `GitOp::validate` rejects an *operation*
carrying one — so leaving it in the list turns "discard everything" into
an error that discards nothing, on a repository that happens to hold one
awkward filename. Dropping it there keeps the rest discardable, and the
test asserts the ops built are ones validate accepts.

The third condition — that discard-all reaches only unstaged paths — was
already held. So were all three of `orphan_panes_of`, which decides which
panes a card offers to close.
2026-08-23 21:19:43 +08:00
l0ng-ai 93129f04e2 test(links): a path with spaces is one argument to the file command
expand_file_command_template splits the template into tokens first and
substitutes {path} inside a token, which is what keeps
`/Users/me/My Notes/a.rs` together. Substituting first and splitting
after reads like the same operation and is not — the editor is handed
`/Users/me/My` and `Notes/a.rs` and opens neither.

Nothing pinned that order, and every existing case used a path without a
space, so the invariant that makes the design correct was never exercised.
Paths with spaces are the common case on the platform this ships on:
Application Support, My Documents.

Three shapes: the plain `{path}`, a compound `{path}:{line}:{column}` where
the glue would part company with it too, and a template carrying spaces of
its own, which are still separators — only the substituted value is
protected.

Checked by writing the refactor it guards against: the path comes back as
three arguments.
2026-08-23 20:55:02 +08:00
l0ng-ai 65094a415b fix(git): a branch name that looks like an option is still a name
`GitOp::CreateBranch` with checkout: false builds `git branch <name>`,
which the commit graph's "branch at this commit" uses — naming a place
without moving to it. That puts a name the user typed where git parses
options.

Measured against real git rather than reasoned about:

  git branch --list main    lists branches, exits 0, creates nothing
  git branch -- --list main fatal: '--list' is not a valid branch name

An exit of 0 is what `run_op` reads as success, so the first line is a
panel reporting a branch that does not exist. `-D` and `-foo` are merely
confusing by comparison; `--help` opens the man page.

So `--` goes ahead of the name on both `branch` forms, create and delete.
Not on `checkout -b`, and that asymmetry is the point: `-b` takes the next
argument as its value whatever it looks like, so that form already
answers "not a valid branch name", and for `checkout` a `--` means
"paths follow" — a different instruction. `CheckoutBranch` already carried
a trailing `--` for its own version of this, so the class was known here;
`branch` was the form that missed it.

My first version of the test searched the argv for the name, which finds
the force flag when the two look alike — `["branch", "-D", "--", "-D"]`
is correct and it called that broken. It asserts what follows the
separator instead.
2026-08-23 20:44:27 +08:00
l0ng-ai 2421c5dc97 test(session): hold the names views.json and session.json are stored under
views.json is which workspaces a window has open and where they point;
session.json is the tabs and panes a cold start brings back. Both are
serde(default) throughout, so a rename does not fail — the field decodes
to its default and the windows, or the panes, are quietly not there.

Same floor as machine.json and the settings file, and the last two files
in the config directory that carry state a user would miss.

The two enums here are tagged differently and both spellings are on disk.
SessionPane is external, so Leaf and Split are keys and a walk finds
them. RemoteTarget is internal — {"kind":"direct",…} — so its variants
are values of kind and a walk over keys never sees them; those are
asserted separately. The two look alike in the source and only the
serialized document tells them apart, which is why this was read out of
serde rather than derived from the types.

Checked both paths: renaming the views field, and respelling the direct
target's kind. Each fails naming what went, and prints what is written
now.
2026-08-23 20:18:15 +08:00
l0ng-ai 582deded35 test(machine): hold every name the workspace tree is stored under
machine.json is the user's workspaces, tabs, panes and layout. Every
field on it carries serde(default), which is what lets an older file load
— and also what makes a rename silent: workspaces under any other name
decodes to an empty Vec, so the whole tree is gone at the next boot with
nothing logged and nothing to repair from. That is a worse loss than a
forgotten setting, and it had no guard at all.

Twenty-two names, as a floor: adding a field does not fail this, dropping
or renaming one does.

The split layout's variant tags are in the list too. PaneNode is stored
externally tagged — {"Leaf":{"pane":3}} — so the variant name sits on
disk exactly as a field name does, and renaming Leaf or Split unmakes
every saved layout. The fixture builds a Split of two Leaves so both are
actually written rather than assumed.

Checked both ways: renaming the workspaces field, and renaming the Leaf
variant. Each fails naming what was lost, and prints the names now being
written so the drift is visible rather than guessed at.
2026-08-23 20:12:41 +08:00
l0ng-ai 1af63cf429 test(config): hold every settings key that has shipped
The values were pinned last commit; this pins the names they live under.
A key tty7 renames does not fail to load — de_lenient leaves the field at
its default, the user's choice is gone, and the old name surfaces through
unknown_config_keys only if they run doctor and look at it.

Seventy-nine keys, recorded as a floor rather than an inventory: adding a
setting does not fail this, renaming or removing one does. The fix when
it fires is usually a serde alias, which is how RightPanelTab went on
reading configs written before it was renamed.

Checked by renaming copy_on_select the way a refactor would. It fails
naming the key and the remedy. The floor also asserts it is not empty,
since a Config that serialized to nothing would satisfy the first check
by having no keys to lose.
2026-08-23 20:06:52 +08:00
l0ng-ai ef1e9bcee8 test(config): pin what every enum setting is spelled as on disk
a_config_round_trips_every_field checks bools and numbers and skips
strings on purpose, because de_lenient falls back to the default for a
spelling it does not know. That is right for a file a human may have
mistyped, and it is exactly what makes a rename invisible: the value does
not fail to load, the setting is forgotten and the user finds their
choice reverted with nothing said. The wire has the same guard already;
this is the disk's copy of it.

Fifteen enums, forty-nine variants, two rename rules between them. The
strings were read out of serde rather than derived from the rename_all,
which is how RightPanelTab::Scm turned out to be "changes" — a rename
whose own doc explains it was done in place so an older build could still
read the file back. Someone tidying that enum would undo it and kick
every user off the panel they were on.

Both directions are asserted, since an alias can make a variant readable
under a name it is no longer written as.

Checked by tidying the rename away: fails with left "scm", right
"changes". My first attempt at that mutation edited the word in the doc
comment instead of the attribute and the test passed — a mutation that
does not mutate proves nothing, which is why the second one names what
it changed.
2026-08-23 20:02:10 +08:00
l0ng-ai e339848d5a test(git): name every merge conflict the way git names it
Sweeping the enums for variants no test mentions turned up ConflictKind:
seven XY pairs, three tested. The rest matter because an unrecognised
pair falls back to BothModified rather than failing, so a wrong entry
does not break — it relabels a conflict as one whose resolution is
something else. "Both modified" invites merging two versions of a file;
"deleted by them" means there is no other version to merge.

Four of the pairs are directional, which is the half that is easy to get
backwards: DU is deleted by us, UD by them, AU added by us, UA by them,
and nothing short of a real merge says which way round git means it.

Two merges reach all seven. An ordinary content merge gives AA, UU, UD
and DU. A rename/rename gives the other three at once — DD at the path
both sides renamed away from, AU at the name we chose, UA at theirs —
which is how the three that had never been produced anywhere become
producible in four commands.

Checked by swapping each directional pair in turn: both swaps fail, and
the message prints the whole set so the direction is visible rather than
inferred.
2026-08-23 19:54:42 +08:00
l0ng-ai 4b22a32ef8 test(git): hold the one error kind nothing was holding
Thirteen of the fourteen GitOpErrorKind variants had a test; Timeout had
none. It is the one that says a git operation ran out of patience rather
than failed to start, and the difference is what the user is told: Spawn
reports that git could not be run and to check the install, which is the
wrong thing to say about a push that is still going on the far side and
may yet land.

The distinction rests on a single ErrorKind travelling three files —
ControlClient::call_with_deadline turns a RecvTimeoutError into
ErrorKind::TimedOut, RemoteHost::git_with_deadline propagates it, and
run_op maps it. Nothing held any link of that. Only a remote host can
produce it at all: the local git_with_deadline has no timeout of its own
and says so.

Both ends are pinned now. The client's contract is tested against a peer
that accepts a request and never answers — the deadline is honoured, the
error is TimedOut, and the request is cancelled rather than left with the
server working on a reply nobody will read. The mapping moved into
unstarted_kind, which can be asked directly what it makes of a timeout
and of five other ways a command fails to start.

Checked by removing each: the TimedOut arm, and the cancel.
2026-08-23 19:49:50 +08:00
l0ng-ai 07fcbdb0ba docs(test): note which bash the pty test covers on which machine
The rcfile installs its hook into PROMPT_COMMAND as an array only on
bash 5.1 and up, and appends to a string below that — a version check
inherited from bash-preexec. macOS still ships 3.2.57, so a developer run
takes the older branch and a Linux CI runner takes the newer one.

Neither machine covers both, which is worth saying in the test rather
than leaving for someone to work out from a passing run.
2026-08-23 19:41:00 +08:00
l0ng-ai 608c3c48e1 test(shell-integration): drive bash over a real pty too
zsh is steered with ZDOTDIR in the environment; bash is steered with
`--rcfile … -i` on the command line, and `replaces_argv` is true for bash
alone. Two mechanisms with two ways to break — a dropped `-i` leaves a
shell that runs the rc and exits, a wrong `--rcfile` path leaves one with
no integration and nothing said — and neither had been run.

It works: all four marks arrive and OSC 7 names the real cwd. `-i` is
asserted on the injection as well as implied by the marks, because that
is the argument whose absence would otherwise show up as a timeout rather
than as an explanation.

Same sentinel discipline as the zsh test, and the same reason for it.
Confirmed the run is real rather than an early return: /bin/bash, args
["--rcfile", "…/tty7-bashrc-<pid>-0/bashrc", "-i"], 417 bytes off the
pty — which also exercises the exclusive scratch-directory creation from
earlier on this branch, since that rcfile is read out of one.
2026-08-23 19:36:50 +08:00
l0ng-ai 6527e88f69 test(shell-integration): drive zsh over a real pty
Four shells had a pty test — git-bash and WSL on Windows, pwsh, and
nushell (Windows). Not zsh, the macOS default, and not bash. So the route
almost every user of this project takes — ZDOTDIR aimed at a scratch
directory of redirectors, each sourcing the user's own file and then
adding the hooks — was covered only by unit tests of the strings it
writes, never by running it.

It works: 133;A, 133;B, 133;C and 133;D;1 all arrive, and OSC 7 names the
real cwd.

Through `setup`, never `setup_zsh`, and the injection is asserted to carry
the empty sentinel before the shell is spawned. This suite runs inside a
tty7 pane, so TTY7_SHELL_INTEGRATION=1 is already in the environment and
every redirector guards on it being empty; reaching for the builder
directly leaves the whole injection inert while stock zsh still emits
marks of its own, and the test passes having proved nothing. Checked by
putting the sentinel back and watching the assertion fire.

The test also asserted a title at first, and was wrong to. Only
PowerShell's integration writes an OSC 0 title, because PowerShell has no
convention of its own; on a POSIX shell the title belongs to the user's
prompt and tty7 names the pane from OSC 7. That is now asserted the other
way round, so a title appearing here is a change someone has to mean.
2026-08-23 19:33:17 +08:00
l0ng-ai 6709e006f5 test(git): resolve a real linked worktree, not a hand-written path
`repo_home_resolves_worktree_layouts` feeds `repo_home` the --git-dir and
--git-common-dir this file believes git prints. That tests the model, and
the model is the part that can be wrong: the only reason `repo_home`
exists is that those two disagree inside a linked worktree, and what they
look like when they do is git's to decide.

So: `git worktree add` for real, then probe from inside it. The root has
to be the worktree the pane sits in and the home the repository it was
added from — swap them and every path the SCM panel offers belongs to the
wrong checkout. tty7 is developed in worktrees, so this is the layout the
panel runs in most days.

They agree, and `assert_ne!(home, root)` keeps the test honest: equal
there would mean the branch under test was never taken. Both paths are
canonicalized because the temp directory is reached through a symlink on
macOS. Checked that the run reaches its assertions rather than taking one
of its two early returns — root ends in /linked, home in /main, branch
"side".
2026-08-23 19:25:53 +08:00
l0ng-ai 13c9fee220 test(git): check the +N -N counts against git's own numstat
`added` and `removed` are counted while parsing the patch rather than
read from git, so they are a second implementation of a number git
already computes — and every test of them was against a patch this file
wrote. `--numstat` asks git the same question directly.

Over a tree holding each shape that counts differently: a plain edit, a
pure addition, a pure deletion, a rename with an edit, and a file with no
trailing newline. They agree exactly, and the two hardest cases are the
ones worth naming — the file without a trailing newline comes out (0, 1)
rather than a line off, and the rename is (1, 1) like git's own -M rather
than the (6, 6) it would be if the rename went unnoticed.

Floored at five files so a comparison of two nearly-empty maps cannot
pass for agreement, and both sides were printed once to confirm the
comparison had real content in it.
2026-08-23 19:21:49 +08:00
l0ng-ai eb139b48ab test(scm): check each panel group against the plumbing it stands for
`in_group` decides which of Staged, Changes, Untracked and Merge a file
is drawn under, and every test of it was against records this file wrote
— which checks the mapping against our reading of the porcelain rather
than against git. The two rows a mistake there produces are a Stage
button on a file with nothing staged, and a Discard button on a file
whose only change is already in the index.

So the same tree described twice: once by `probe_status`, once by the
plumbing each group mirrors — `diff --cached --name-only`,
`diff --name-only`, `ls-files --others --exclude-standard`. They agree,
including the two cases worth arranging on purpose: a file staged and
then edited again belongs to Staged *and* Changes, and a deletion that
was never staged belongs to Changes.

Two ways this could have passed without proving anything, both closed:
every group is asserted non-empty, so agreement between two empty sets
does not count; and the run was checked to reach its assertions rather
than take the no-git early return.
2026-08-23 19:17:13 +08:00
l0ng-ai b17dfa9797 test(git): check awkward filenames against real git, not against our model
Two tests already cover spaces, quotes, newlines and non-UTF8 paths — but
against records this file writes itself, which tests the model of what
git emits rather than what git emits. Porcelain v2 separates records with
NUL precisely so these names need no quoting, and that assumption had
never been put to the real thing.

So: a scratch repository holding a name with a space, a double quote, a
backslash, a newline, a tab and non-ASCII, each made with std::fs rather
than through a shell — a shell eats exactly the characters under test.
Real git, real parse, and every path asserted to open on disk, because
that is what the consequence would be: a quoted or re-spelled name is one
the panel offers to discard and git then cannot find.

It passes, which is the answer worth recording — git hands all six back
byte for byte and the parser keeps them. Checked that the test really
reaches its assertions rather than taking one of its two early returns:
six entries come back from git, one per name.
2026-08-23 19:13:34 +08:00
l0ng-ai 3eed5c297f docs(duplex): say how the stdio link actually closes, and pin it
`LinkShutdown` asks for a way to "force the read half to return … while
the reader is blocked inside read", and calls itself "not optional
politeness; without it a client cannot be closed". Both socket
implementors do exactly that with shutdown(Both), and a test shows one of
them releasing a parked reader.

The stdio one cannot. A pipe has no shutdown, so `StdioDuplex::split`
hands the *writer* back as the closer: shutting the link down closes our
outbound pipe and nothing else, and the reader parked on the inbound one
is released only when the peer notices that EOF and closes its own end.
Measured rather than argued — with a real pipe pair the reader is still
parked 200ms after shutdown_link and returns as soon as the peer closes.

Nothing here is broken: for the SSH-piped server the peer does exit on
EOF, which is the whole design. But the trait claimed something one
implementor gets only by way of the far end, and a pipe carries no read
timeout to fall back on, so a wedged peer leaves a reader parked where a
socket would not. That is worth being written down rather than
rediscovered.

The body also had `if !taken { return Ok(()) } Ok(())` — two arms doing
the same thing, which reads as something lost in an edit. It is a drop
and a comment now saying why the slot is emptied at all.
2026-08-23 18:59:12 +08:00
l0ng-ai 58974e889d test(shell-quote): cover cmd, and write down the one thing it cannot do
`quote_for_shell` decides how a path is typed into the user's own shell,
so a name that argues with the quoting is a path that names the wrong
file. Posix and PowerShell had tests; cmd had none for quoting at all —
only `unquote_word` and `quoting_for` — so what it does with an awkward
name was written down nowhere.

The `"` case is genuinely closed and the doc already said why: a Windows
path cannot hold one. `%` is the open one. It is legal in a Windows
filename and cmd expands `%NAME%` inside double quotes, before it parses
them, so a file actually called `%USERPROFILE%.txt` pastes as a line
naming somewhere else. There is no escape for it on an interactive line —
`%%` is a batch-file rule and `^` is not read inside quotes — so this is
pinned and documented rather than fixed, and the doc now says what it
costs: the wrong path, never a command, because `%` substitutes an
environment variable and can do nothing else.

The rest is the coverage cmd was missing, plus a check that `is_bare`
never lets a metacharacter through unquoted — which is the actual
boundary, since anything bare is typed with no quoting whatsoever.
2026-08-23 18:51:19 +08:00
l0ng-ai 0469e75b15 test(i18n): hold the awaiting-a-caller list to its own instruction
`SCM_KEYS_AWAITING_A_CALLER` says it out loud: "delete a key from this
list as soon as something renders it". `ScmCheckoutBranch` had been the
placeholder of the inline "switch to which branch" input for some time
and was still on the list.

That is not a warning anyone sees, but it spends the list's whole purpose
in reverse. It exists so `dead_code` keeps reporting on the rest of the
enum and a genuinely stale key cannot hide in a crowd of unused ones; a
key that is in use makes the list an inventory of nothing in particular.
The other five are real — commit detail, staged count, reset to commit,
branch search, stash and switch are all unbuilt.

The guard reads the sources rather than trusting the list, because
trusting the list is what failed. It fails with the offending key named,
which the instruction alone could not do.
2026-08-23 18:45:28 +08:00
l0ng-ai 3c78ccd719 test(ssh): make the live GSSAPI test skip rather than fail without Kerberos
The other three live SSH tests fall back to localhost, $USER and
~/.ssh/id_ed25519, so `cargo test --lib live_ -- --ignored` is something
to run on any developer machine — it exercises the transport every remote
pane sits on, which CI cannot reach. This one panicked there on a bare
`TTY7_LIVE_SSH_HOST`, for want of an environment that cannot be assumed,
and a failure claims something is broken where a skip would have said
"no Kerberos here".

Now opted into by name with TTY7_LIVE_GSSAPI=1, and everything else comes
from `live_key_spec` like its siblings, so one set of overrides steers all
four. Checked both ways: without the variable it skips and says how to
enable it; with it set it really connects and reports what it found —
"gssapi-with-mic could not be tried; the server offers publickey,
password, keyboard-interactive" — so it is skipped, never disabled.

All four now pass against a live sshd on this machine: key auth, a
direct-tcpip forward carrying bytes both ways, and SFTP listing and
editing a real directory.
2026-08-23 18:38:39 +08:00
l0ng-ai b9c397c47e test(terminal): fuzz the four parsers a hostile file can reach
`parse_agent_event`, `osc::parse_notification`, `OscTokenizer` and the
kitty graphics control parser all read bytes chosen by whatever runs in
the pane — `cat` of a hostile file is enough. A panic in any of them is a
pane a stranger can end, and osc.rs and cli_agent.rs had no fuzz coverage
at all.

Every truncation of eight seeds plus 4,000 seeded corruptions: no panic
in any of them. That is a negative result, and it is only worth having
because the harness was checked against planted panics in two of the four
first — a fuzz that reaches nothing passes just as quietly as one that
finds nothing.

Read while writing it, and left alone because each is already right:
`OscTokenizer` abandons a payload past MAX_PAYLOAD rather than truncating
it, so an unterminated escape cannot grow the buffer without bound; the
kitty parser returns None on `width * height * bpp` overflow and caps the
inflate; and `parse_notification` indexes only what it has just measured.
2026-08-23 18:24:05 +08:00
l0ng-ai a0b4e056f2 test(git): fuzz the status parser, and drop the pathless entry it found
`parse_porcelain_v2` had tests for every record type, non-UTF8 paths,
newlines in paths and both caps — and none for a stream that stops in the
middle. Truncating a realistic sample at every byte, plus 2,000 seeded
corruptions, found no panic but did find 27 cuts that produce a
`StatusEntry` naming no file at all, one for each record type: a record
severed between its last field and its path parses down to an entry with
an empty path.

Not reachable today — `status_of` parses only when git exited 0, and a
git that exits 0 has written all of it. But this module's stated bargain
is that a record it cannot read is dropped, "far better for the panel
than no status at all", and a pathless entry is one it passed on
half-built instead. It would draw as a blank row whose own Stage and
Discard buttons hand git an empty pathspec.

So `push` drops it, and does not count it either. The fuzz stays as the
guard: every truncation rather than a sampled few, because the
interesting cuts are exactly the ones between a field and its separator,
and the corruptions are seeded so a failure reproduces from its message.
2026-08-23 18:18:53 +08:00
l0ng-ai 6410ea5105 fix(scm): say why a Git command with no repository did nothing
`run_scm_action` opened with a guard that returned when the panel had no
active repository, and said nothing. Every Git verb goes through it:
commit, push, pull, sync, fetch, stage all, discard all, checkout,
refresh.

The panel's tiles and the Git menu disable themselves in that state, so
the mouse never reaches this. The key bindings and the palette do — and
the palette lists every Git command whatever the pane's directory is,
which `palette.rs` pins on purpose: "every Git action you can bind is
also a palette command". So in a directory that is not a repository,
choosing Git: Commit did nothing and reported nothing.

That is the case `scm_push` already argues about its own guard one level
down, citing the same issue: a swallowed click looks exactly like an
action that finished instantly, and the toast is the only place a key
binding or a palette entry can say why nothing moved (#545). The message
is `DiffNotARepo`, which already existed in all three locales, so the
wording matches what the diff overlay says about the same state.
2026-08-23 18:08:50 +08:00
l0ng-ai 06534398ed fix(tabs): a bulk close says how many tabs it kept
Sparing them is the right bargain and it is argued for in place: one
dialog per tab is not a question anyone can answer, so "Close Other Tabs"
skips what it will not take — a tab holding unsaved edits, or an SSH
profile that asked to be warned about — and closes the rest.

It did that silently. Choosing Close Other Tabs on a window with three
such tabs left three tabs standing and said nothing, which reads as the
menu item having half worked, and gives the reader nothing to act on.

This is the rule `scm_push` already states about its own swallowed click —
"a swallowed click on Push looks exactly like a push that finished
instantly" — and a close that keeps something back is one of those. Both
bulk closes now count what they spared and name the number, in all three
locales; a close that took everything still says nothing, because there
is nothing to explain.
2026-08-23 18:04:10 +08:00
l0ng-ai a93d5b3bf7 fix(remote): the SSH bootstrap makes its scratch dir, never adopts one
The same hole as the local one, on the far side of the connection and in
generated shell rather than Rust — and on a shared server, which is where
several accounts actually coexist.

  __tty7_d=${TMPDIR:-/tmp}/tty7-zdotdir-$$
  command mkdir -p "$__tty7_d" 2>/dev/null
  command cat > "$__tty7_d/.zshrc" <<'EOF' ...
  ... && export ZDOTDIR="$__tty7_d"

`mkdir -p` succeeds on a directory that already exists, and $$ is the
remote shell's pid, which every other account on that box can read. So
the startup files went into whatever held the name, and its owner could
rewrite them in the moment before zsh read them.

Now `mkdir -m 700` without `-p`, which fails when the path exists, with
the writes moved inside the `if`. A taken name means nothing is written,
the `[ -s ... ]` guards that were already there see nothing, and the login
falls through to the plain `exec <shell> -l` those guards exist for.

Run rather than reasoned about. Against a directory planted at the name
with mode 777 and an `evil` .zshrc: the fixed script leaves ZDOTDIR empty
and the plant untouched, while the `mkdir -p` version exported the
planted path for zsh to read. Both scripts pass `sh -n`, and the ordinary
path still creates drwx------ and exports ZDOTDIR.
2026-08-23 17:54:04 +08:00
l0ng-ai 4764a35fe5 fix(shell-integration): make a shell's scratch directory, never adopt one
What lands in this directory is sourced by the shell. `setup_zsh` points
ZDOTDIR at it and zsh reads .zshenv, .zprofile, .zshrc and .zlogin out of
it on every pane; bash and nu are pointed at theirs the same way.

`throwaway_dir` built the name from the pid and a counter — which the
reaper depends on, so it is entirely predictable — and then called
`create_dir_all`, which succeeds on a directory that already exists. On
Linux the system temp directory is /tmp, mode 1777, so any account can
take that name first. tty7 would then write the shell's startup files
into a directory somebody else owned, and they could rewrite them in the
moment before the shell read them. No mode was set either, so on a stock
umask the files were readable by everyone regardless.

Now `DirBuilder::create`, which fails if the path exists, with the mode on
the creating syscall rather than a chmod after it — there is no instant
where the directory is present and open. A taken name is stepped over,
not reported: stepping over it is the whole of what an attacker holding
one achieves, and after 64 of them the shell simply starts without tty7's
integration rather than reading files from a directory it does not own.

Verified on a live daemon, not only in a test: a pane's `cd /usr/local`
still moved the daemon's tracked cwd, so integration works, and the
scratch directory that daemon made is drwx------ next to the drwxr-xr-x
ones earlier builds left in the same temp dir.
2026-08-23 17:48:01 +08:00
l0ng-ai 35a06a8c74 fix(clipboard): stage a pasted image only in a directory we own
`write_clipboard_image` did `create_dir_all($TMPDIR/tty7-clipboard)` and
wrote into whatever that turned out to be. On macOS $TMPDIR is a
per-user /var/folders path and this is moot. On Linux it is /tmp, mode
1777: the directory lands 0755 under the stock umask, so any other
account can read the screenshots pasted through it — or create the name
first and be handed everything pasted afterwards, which is also a place
to plant a symlink and have the write land somewhere else.

The remote half of this feature already defends all of it, and says so:
"a staging directory anyone else can enter is one anyone else can read
the pasted screenshots out of", and `staging_dir_is_safe` proves
ownership by chmodding to 0700 and reading the mode back — POSIX lets
only the owner change a mode. The local half, 200 lines up, did nothing.

Same proof, same predicate shape, and the same refusal of symlinks. The
ordering is the part worth stating: `set_permissions` follows links, so
the symlink test has to come before the chmod, not after it. My first
attempt had it after, and re-permissioned the link's target on the way to
refusing it — the test caught that, and pins it now.

Failing closed was already safe: `None` here returns false and the caller
forwards the paste the ordinary way.
2026-08-23 17:41:33 +08:00
l0ng-ai 1ebee808d1 fix(config): close the config directory to other users
It holds `history` — every command with its cwd and exit status — plus
the SSH profiles in `config.json`, `session.json` and `views.json`.
`machine.json` and `appearance.json` are written 0600 and the sockets
are 0600, but those four are not, and the directory around them was made
with plain `create_dir_all`: 0755 under the stock umask of 022, with the
history file 0644 inside it. Another account on the machine could read
the lot.

The rule already existed twice. `daemon::history` closes its own
subdirectory, saying "closing the directory is what makes the mode of
what is inside it moot", and `transport::bind` closes the socket's parent
when it is the config dir. Neither covered the directory holding
everything else, and the daemon reaches it first through the pidfile, the
singleton lock and the TCP endpoint, none of which closed anything.

`ensure_private_dir` closes every directory the call creates, and the
config directory itself even when it already existed — so an install made
by an earlier build is repaired rather than left open for its lifetime.
Directories it did not create and that are not ours are left alone, which
is the distinction `transport::bind` drew with `owns_parent`: $HOME and
~/.config are on this walk on a first run.

Verified against a running daemon rather than only in a test: with umask
022 a fresh config dir came out drwxr-xr-x before and drwx------ after,
and a directory chmodded back to 755 was closed again on the next start.
The unit test caught a hole in the first attempt — closing only the leaf
left the config directory, which `create_dir_all` had just made, exactly
as open as before.
2026-08-23 17:31:37 +08:00
l0ng-ai 5ab9df9aa6 fix(daemon): answer a request whose handler panicked
Surviving a panic is not the same as answering it. The pool now outlives
a panicking job, but `run_job` still skipped `finish`, so the id stayed
in `inflight` and the client waited on a reply that was never coming.

Every other exit answers, including the one in `submit` for a queue too
full to take the request, so "every request gets a reply" is the
invariant the rest of this file already keeps. The catch sits behind
`caught`, a named seam, because a panic reachable on demand is what a
test of this needs and no control request offers one — `caught` can be
driven directly, and an ordinary Err still passes straight through it.
2026-08-23 17:17:12 +08:00
l0ng-ai fda00ff42a fix(host-ops,daemon): a panicking job no longer costs a pool a worker
Both thread pools ran `job()` bare in their worker loop. A panic unwinds
out of `worker`, which skips the `threads -= 1` / `workers -= 1` that
every deliberate exit performs, so the count kept believing in a thread
that was gone.

`wants_another_thread` is `jobs > idle && threads < MAX`. After MAX
panics the count sits at the ceiling with nothing alive behind it: the
pool spawns no more workers and no worker is left to wake, so every later
job is queued and never run. On the UI side that stops the file tree, git
status, saving a file, SFTP and the diffs together; on the daemon side
the connection accepts requests and answers none. Both are silent, both
persist until a restart, and a daemon lives for days.

A host op runs somebody else's code — a git parse, an SFTP read, a
filesystem walk — so a panic there is exactly the event the pools should
survive. It is also what poisons the mutexes both of them already take
poison-tolerantly: the poison was handled, the accounting was not.

Each pool has a test that exhausts its ceiling, because counting workers
cannot distinguish one the pool believes in and has from one it believes
in and has lost. The op itself is still dropped — `off_thread`'s sender
drops unsent, so the landing never runs and the caller's in-flight flag
stays set. That costs one operation rather than every one, and landing
would need the value the panic is the reason we do not have.
2026-08-23 17:13:34 +08:00
l0ng-ai eacfded204 fix(keymap): taking a chord two actions hold displaces both
`assign_keybinding` used `find`, so it unbound the first holder and left
any others. A chord can legitimately be held twice — `secondary-enter`
is Fullscreen in the window and Commit inside the commit box, which
`binding_conflicts` blesses because their scopes differ — and on macOS
that is a shipped default.

Rebinding it therefore left the new action sharing the chord with one
the note had not named. Which holder survived came down to their order
in `default_bindings`: Fullscreen sits at line 475 and Commit at 560, so
the right one was displaced by table position rather than by design, and
reordering the table would have silently swapped it.

Scope is still not consulted here, unlike in the conflict check. That is
the tested intent — a user who assigns a chord means it to be theirs
everywhere, which recording_an_extra_default_chord_displaces_its_owner
pins — so the fix is to displace every holder and name every one of them
in the note, not to start honouring scope.
2026-08-23 17:04:07 +08:00
l0ng-ai 73fb9e2c8c fix(file-tree): escape abandons an inline edit
The tree's rename / new-file / new-folder box subscribed to PressEnter
and Blur and no other key. So the way out of an edit you had changed
your mind about was to click somewhere else, and the other key already
under your hands — Return — commits the rename instead of abandoning it.

Every other box the app opens pairs Escape with Return: sftp_open_edit
says so out loud ("every other box in the app opens focused and answers
Return"), and the switcher, the branch inputs and the graph search all
handle both. The local file tree, the surface people touch most, was the
one that did not.

Both rows an edit can be drawn in are wired, through one free function
rather than a closure each, so they cannot drift apart on which keys
they answer — a test per row, each failing when only its own site loses
the handler.
2026-08-23 16:55:37 +08:00
l0ng-ai 282b387a06 fix(ui): fold the names toasts did not compose either
Same rule, same reason, the surface next door. A branch name, a machine
label, a settings source path, an agent's display name, and the path out
of a terminal hyperlink — which is whatever the program writing to your
terminal chose to emit — all went into a notification raw.

An error message is deliberately left alone. In a toast the error *is*
the content, not a fragment inside a sentence of ours, and git and ssh
write genuinely multi-line errors whose second line is the useful one.
A dialog embeds one mid-question, so there it is still folded; the guard
now carries a different key list per surface and says why.
2026-08-23 16:40:53 +08:00
l0ng-ai 4d91b25b9b fix(ui): fold every name a confirmation dialog did not compose
`terminal::view::one_line` states the rule and gives the reason:
"anything that draws a name it did not compose is exposed to it." Every
row surface followed it. No dialog did.

sftp.rs held both halves fifteen lines apart — the row folded
`entry.name` under a comment about bytes chosen on a machine this window
has no say over, and the delete confirmation for the same entry
interpolated it raw. A dialog is the worse place to lose it: gpui breaks
text on a newline whatever the style says, NSAlert renders one too, and
the dialog is where the destructive action gets authorised. A file named
`notes.txt\n\nThis one is safe to delete.` wrote its own second line into
the question.

Seventeen substitutions across eleven dialogs: delete (file tree, SFTP,
settings), discard changes, replace-on-drop, remove worktree, close
window, and the unsaved-edits prompts on close, quit and relaunch. Also
the machine label and the far end's error text in the remote dialogs,
which are no more ours than a hostname is.

The guard in ui::tests walks the prompt call sites rather than trusting
this sweep to have been complete — it found five of the seventeen after
I thought I was done.
2026-08-23 16:36:33 +08:00