ft is a terminal file-tree explorer (a JetBrains-style project pane for a
tmux split) written in Go with Bubble Tea v2. macOS is the supported OS;
the code is structured for Linux to be added behind build tags.
Use go-task (Taskfile.yml; there is no default task):
task vet # go vet ./...
task test # go test ./...
task build # builds ./ft (gitignored)
task install # go install ./cmd/ft -> ~/go/bin/ftAll code must be gofmt-clean and go vet-clean, and tests must pass
before any change is considered done.
Every push to main runs .github/workflows/release.yml. A pull request's
title becomes its merge commit's subject, and .github/scripts/next-version.sh
reads those subjects on main's first-parent line since the last tag: feat
bumps the minor version, fix and perf bump the patch, and type!: or a
BREAKING CHANGE: line is major (minor while the version is 0.x). Anything
else releases nothing. So a pull request title must be a conventional-commit
subject, and its type is a release decision. To release without one, run the
workflow by hand from the Actions tab and pick the bump.
GoReleaser (.goreleaser.yaml) uploads the archives to the GitHub release
itself. Do not add an actions/upload-artifact step: release assets are free,
and Actions artifact storage counts against the account's quota.
Every archive carries LICENSE and THIRD_PARTY_NOTICES.txt, because the
MIT and BSD licences of what is compiled in, Go's standard library included,
ask for their notices to travel with the binary. GoReleaser's before hook runs
.github/scripts/third-party-notices.sh, which reads the import graph at
release time, so the file is never committed and never stale. The hook names
the operating systems to read it for; keep them in step with goos.
The Charm v2 modules use vanity import paths. go get github.com/charmbracelet/bubbletea/v2 FAILS with a module-path mismatch.
Use:
charm.land/bubbletea/v2charm.land/lipgloss/v2charm.land/bubbles/v2
Verify v2 APIs with go doc charm.land/bubbletea/v2 <Symbol> rather than
assuming v1 shapes: View() returns tea.View (AltScreen/MouseMode are set
on it per render), mouse events are typed messages (tea.MouseClickMsg,
tea.MouseWheelMsg), and Key.String() returns text for printable keys
("Y") and names otherwise ("ctrl+c", "up").
cmd/ft/ entrypoint, flag parsing
internal/app/ Bubble Tea model — the heart of the tool
app.go model, Update dispatch, keybinding table (buildBindings)
actions.go navigation, toggles, clipboard, file ops, command exec
view.go rendering: header (clickable toggles), tree, status bar
mouse.go wheel/click/double-click, header hit-testing
fuzzy.go candidate walk (BFS, streamed) + screen-aware ranking
grep.go content-search mode: debounce, hit list, Find narrowing
git.go per-repo status cache plumbing
internal/tree/ pure tree model: lazy nodes, expand/collapse, flatten
internal/fsops/ directory listing + fsnotify watcher (debounced batches)
internal/gitx/ repo discovery, `git status --porcelain -z --ignored` parsing
internal/search/ finder file-type filter (pure) + the ripgrep integration
internal/config/ TOML config, command templates + shell quoting, starter
internal/state/ per-root JSON persistence (expansion, selection, toggles)
internal/icons/ Nerd Font glyphs; table.go is GENERATED — see below
internal/platform/ OS interface; darwin impl (pbcopy, open -R, Finder trash),
linux impl (wl-copy/xclip/xsel, xdg-open, gio/trash-put)
internal/tmux/ every tmux invocation: the self-relaunch decision, the
session names (grammar, list parsing, kill), and the
server-wide pane list that jump routing needs
internal/ipc/ the "ft jump <file>" socket: one listener per instance,
plus the pure routing that picks which instance answers
internal/herdr/ every herdr call: the socket client, and the pure rule
picking which open pane belongs to a checkout
internal/agenthook/ what an agent's lifecycle hook means: event + payload in,
state / bell / notification out (pure; "ft agent-hook")
Design rules that keep this maintainable:
-
internal/treestays free of filesystem and UI dependencies; directory listing is injected viatree.Lister. -
All git information comes from one parsed
git statusper repo, cached in the app model and refreshed via asynctea.Cmds. Never shell out to git per file. That status runs asgit --no-optional-locks status: ft re-reads it after every watched file change, and a plaingit statustakes.git/index.lockon every run (measured), so a lazygit commit or any other index write landing in that window fails with "index.lock: File exists".TestReadStatusLeavesTheIndexAloneis the guard. -
OS-specific behaviour goes behind
platform.Platforminplatform_<goos>.gofiles with build tags — never inlineexec.Commandfor OS integrations elsewhere. -
Each external tool gets one package that owns every invocation of it:
internal/gitxforgit,internal/searchforrg. Argument building and output parsing stay pure and table-tested (search/args.go,search/parse.go); the process spawn lives alone (search/exec.go). The app only sequences git and rg in asynctea.Cmds, because their cost grows with the repository. A tmux call made in answer to a key press may run inline (ctrl+w,X, theTkill, the quit check all do): it takes a few milliseconds, and ft's own input arrives through that same server, so a tmux too stuck to answer has already stopped ft's keys. Only a read on a timer, like the agent poll, goes off the loop. -
The finder's file-type filter is compiled once, in
internal/search, and used by both the walk (Filter.Match) and ripgrep (Filter.Globsbecomes-gargs) — so a filtered file list and a filtered content search can never disagree about which files are in scope. -
Web links (
u/U):internal/gitx/link.goowns remote-URL normalisation and URL building (pure, table-tested);platform.OpenURLowns the browser. -
Commands ship in
internal/config/catalogue.go, never in the starter.starterTOMLis written to~/.filetree/config.tomlon first run and never again, andLoadmerges the file over the catalogue rather than replacing it — so a command added to the starter reaches nobody who has already run ft once. That is a real bug that shipped once already;TestStarterDefinesNoCommandsguards it.[keys]covers commands as well as actions, resolved together byresolveActionKeys, and the commented[keys]reference in the starter is generated from both tables so it cannot go stale. -
internal/tmuxowns every tmux call, the waygitxowns git: the pure half (session.go— name building,list-sessionsparsing) is table-tested, and the process spawns live alone inrun.goandexec.go. The self-relaunch keeps its decision pure the same way:tmux.ShouldWraptakes anEnvstruct so it is table-tested, and thesyscall.Execlives alone ininternal/tmux/exec.go. It runs inmainafter root validation and config load, so startup errors print in the user's terminal instead of dying with the session they would have created. -
internal/herdrowns every herdr call, the waygitxowns git: the pure half (pick.go— which of the open shells answers for a checkout) is table-tested, and the socket work lives alone inherdr.go. It speaks the socket directly rather than shelling out to theherdrCLI, and that is not a preference: focusing a named pane has no CLI form at all (herdr pane focustakes a direction, andherdr apioffers only snapshot and schema), while the socket exposespane.focustaking a pane id. Going straight to the socket also costs no process spawn, which matters because one key press makes several calls. Noteprutil/internal/herdrshells out instead — fine there, because every agent method it needs does have a CLI form. -
A new herdr key is a
programvalue, not a new command.cmd/ft/herdrprogram.goholds the body all of them share: find the place, find the program in it, reuse or create, name the tab, report. A key says only what to look for (Argv0), what to run (Command), what to say to one already running (Reuse, nil when there is nothing to say) and whether it needs a checkout.herdredit.goandherdrlazygit.goare what that looks like. Resist adding a fifth by copying the body. -
Two keys sharing a binary must each claim only their own panes.
alt+grunslazygitandctrl+grunslazygit -f <file>; toRunsthey are the same program, so each would answer for the other.program.Matchis the hook, andRunsWith/RunsWithoutare what it is built from — matching the arguments a pane was started with, which is also what gives blame one tab per file. Give such a key aLabeltoo, or its tabs all carry the binary's name. -
Never label a workspace
ftcreates. herdr derives a workspace's name from its shell's directory and keeps it current, but a label passed toworkspace.createis stored as the workspace'scustom_namein~/.config/herdr/session.json, and a custom name is never replaced.Jonce labelled new workspaces with the directory's basename, which read correctly until the firstcdand then stuck. herdr's own name for a fresh workspace is that same basename, so there is nothing to add. Tabs are the opposite case:hx,lazygitandblame <file>say what a tab runs, and should stick. -
The multi-step herdr work is a subcommand, not a template.
Jrunsft herdr-shell {dir}, the same shape asft jump. Choosing between the open shells takes a pane list, a process check per candidate and a ranking; in a[commands]template that would mean ajqdependency and no tests. Adding more herdr keys should follow this: one line in the catalogue, the logic in Go. Note the template passes{dir}alone and works the checkout out from it:config.NeedsReporefuses any template mentioning{gitroot}outside a repository, and this key has to work in a loose directory too. -
Two herdr send methods, and picking the wrong one corrupts a file.
pane.send_inputhonours the pane's bracketed-paste mode and arrives as a paste;pane.send_textarrives as typing. A program that tells them apart does completely different things with them. Sending:open fileto helix via send_input pastes the literal text into the buffer and leaves the file modified, and nothing opens; via send_text the leading colon reaches helix's command line. Verified against a real helix, not reasoned about. So: send_text to drive a program's key handling, send_input to hand a command to a shell.TestOpenInTypesRatherThanPastesis the guard — do not "simplify" those three calls into one atomic send. -
Process identity comes from
argv0, and the whole foreground list.Nameis what a process calls itself now, and programs rename themselves: a Claude pane reports Name2.1.268with Argv0claude. The foreground group can also hold more than one process, and the wrapper may be listed first — a pane running Claude under caffeinate lists caffeinate ahead of it. Matching the first entry by Name finds the wrapper and misses the program. Seeherdr.ProcessInfo.Runs. -
herdr.Scopeis the boundary, and it has two shapes. Inside a checkout it is the checkout root, which is the whole of the worktree-awareness. Outside one it is the selection's own directory, and membership runs both ways — a shell above the selection or below it. The upward direction is load-bearing: without it, stepping one directory deeper puts the shell you just opened out of scope and earns a second workspace for the same place. A repository spanning the whole home directory is ignored as a boundary (checkoutForincmd/ft/herdrshell.go), because dotfiles-in-~would otherwise make every loose directory one enormous checkout. -
ft jump <file>(internal/ipc) is the one way into a running ft from outside the process, and the only IPC there is. Each instance listens on~/.filetree/run/<pid>.sock; the jump command dials all of them, asks each which root it is on, picks one, and sends the path, whichmainturns into anapp.RevealMsgthroughProgram.Send. Four rules hold it together:- Routing filters on containment, then scores locality (
ipc.Pick, pure and table-tested). An instance whose root does not cover the path cannot show it, so scoring "same tmux window" additively would let the pane beside the editor win every time and then fail, while an instance that could have shown the file was never reached. Filter first; among the survivors, the caller's window beats its session beats neither, and the deepest root wins. Terms are compared in order rather than summed so no amount of path depth outranks being in the right window. - Status is answered off the Bubble Tea event loop, from an
atomic.Pointerthe model publishes to throughSetRootObserver(hooked intoloadRoot, the single funnel every re-root passes through). An ft suspended in an interactive command has a blockedUpdate, and an instance that cannot answer cannot be routed around either — it would time out and stall the editor's keystroke. Program.Sendblocks when the loop is suspended, sorevealVia(cmd/ft/main.go) sends from a goroutine: the deadline has to cover getting the message in, not just getting an answer back. Measured, not reasoned about — waiting on the reply alone hung for the client's full timeout. The reply channel is buffered for the mirror case, a client that has already given up.- A reveal reports whether it actually happened.
selectPathno-ops on a path with no row andExpandRelgives up at a missing segment, sorevealRequestre-checks the selection afterwards and blames the ancestor the row filter is hiding (Flatten skips a filtered directory's whole subtree, so an ordinary file inside a dot-directory has no row either). It never flipsshow_hidden/show_ignoreditself — those are persisted per root. It also refuses outright duringmodePrompt:commitPromptandcreateTargetDirresolve their target fromm.selected()when the prompt is committed, so a jump landing in between would rename or create against a file the user never chose. Sockets are 0600 in a 0700 directory, and are swept by the next jump rather than on a timer — a killed instance leaves a file, and a file nothing answers on is unlinked when it refuses a connect. macOS caps a socket path at 104 bytes, whichServechecks so the failure is a sentence rather than the kernel's "invalid argument".
- Routing filters on containment, then scores locality (
-
treeHeight()is the body;treeVisibleRows()is the tree. The sticky parents (sticky_parents) pin the ancestor chain ofm.rows[m.scroll]above the tree and are paid for out of the body, so anything counting selectable rows —ensureVisible,clampScroll, half-page paging, the finder's centring jump — must usetreeVisibleRows(), while the help and finder screens keep filling all oftreeHeight(). Two consequences are easy to get wrong. The count isDepth-1, notDepth:Flattenputs the root's children at depth 1, and the root is left to the header line. And the window height and the scroll offset now decide each other, soensureVisibleandclampScrollboth settle by iteration rather than clamping once — they are compatible at rest (at anensureVisiblefixed pointclampScrollis a no-op), which is what stopsGon a deep tree oscillating. Clicks go throughrowAtY, which returns the real row index for a pinned line, so selection, double-click and the chevron hit test need no case of their own. A confirmation too long for the status line is the one thing that takes rows from the body without going throughtreeHeight():fitConfirmwraps it andViewdrops that many lines off the bottom of the body (borrowLines). It is short-lived and covers rows no click reaches while it is up, so scrolling and paging never need to know. -
New keybindings are wired in
buildBindings(internal/app/app.go); makethem remappable via the
[keys]action map and list them in the?help overlay (view.go) and README. -
A key with a space in it is a chord (
"n right"), and it is an ordinary entry inm.bindingskeyed by the whole sequence — so[keys], the conflict report and the help page need nothing special. What chords add is ininternal/app/chord.go:m.chordPrefixes(every proper prefix of a bound sequence, computed bysettleChordsafter all claims), andm.chord, the prefix typed so far, consulted at the bottom ofhandleKeyinmodeNormalonly. A prefix displaces a single-key binding on the same key unless that key is navigation, in which case the chord is refused.hjklare tried as arrows inside a chord only when the letter itself completes nothing. Thenshells are actions rather than templates becausetmux.PlanShellhas to read the layout to pick the pane;n space(the popup) is still a catalogue command, which is why a chord can mix the two. -
ctrl+c is the only guaranteed way out, and
handleKeyrewrites it to"esc"before the mode switch whenever the mode is notmodeNormal. So a new mode gets "the first press backs out, the next one quits" for free by handlingesc, and needs no ctrl+c case of its own.quititself ships unbound (likereload, whichF5covers) — the action is still inDefaultActionKeysso[keys]can give it a letter, but nothing does by default, which is what keepsqfree for a command.
internal/icons/table.go is generated from nvim-web-devicons' lua tables —
do not hand-edit. Glyphs are written as \uXXXX/\UXXXXXXXX escapes
because literal PUA glyphs do not survive copy/paste reliably. Devops
entries missing upstream (hcl, terragrunt, helm, …) are added in
icons.go's init by reusing generated glyphs.
-
Config:
~/.filetree/config.toml(TOML; commented starter written on first run frominternal/config/starter.go— keep starter and README in sync with behaviour changes). -
State:
~/.filetree/state/<basename>-<hash8>.json, one per tree root. -
Recent roots (
<):~/.filetree/state/<basename>-<hash8>.roots.json, keyed by the launch root (launchRoot:homeRoot, else the current root) so every root reached from one project shares one list.recordRootis called fromloadRoot, the same funnel the root observer uses, and skips the scratch and worktrees view dirs. Picking the launch root must go throughleaveView, notenterView, orhomeRootends up naming the root you are standing on. -
Jump sockets:
~/.filetree/run/<pid>.sock, one per running instance. -
Command templates:
{path} {relpath} {dir} {root} {name}plus mark vars{marked} {marked1} {marked2}are substituted shell-quoted; unknown{tokens}pass through untouched (tmux formats like"{last}"depend on this; also why{marked1}must be replaced before{marked}— the Replacer tries patterns in argument order). Commands run via/bin/sh -cwith mode "interactive" (tea.ExecProcess suspends the TUI) or "background". -
The scratch view (
s/S) is plain re-rooting:loadRoot(internal/app) swaps tree+state; per-root state files make each root remember its own expansion.homeRoot(session-only) powers the Esc/toggle-key return; Esc is layered — marks clear first, then the view returns. -
Every re-root goes through
switchRoot(internal/app/actions.go): saveState on the way out,loadRooton the way in. Saving first is why the return trip needs no work — each root's expansion lives in its own state file, keyed by that root, so the two sides of a switch cannot overwrite each other.enterViewremembers the project root once; a second view does not overwrite it. That rule is what makes>(root-here) replace the root rather than stack, so one Esc comes home from any depth — and it is whyhomeRootis a slot and not a stack.>carries the open dirs in viatree.RebaseRels, which renames them for the new root (expansion is stored root-relative, so "sub/a/b" up here is "a/b" down there); the seed applies only to a root with no expansion of its own, so a subtree you have been in before opens the way you left it.shift+enteris bound to the same action in the fixed navigation set, but only arrives where the terminal reports modified keys — inside tmux that needsset -s extended-keys on, a server option that is off by default, so never rely on it in a test. Bubble Tea already requests Kitty level 1 and modifyOtherKeys=2 unconditionally; there is no program option to add. -
Worktrees (
w/W) reuse the same re-rooting:<[worktrees] dir>/<repo basename>/<branch or pr-N>.internal/gitx/worktree.goowns every git invocation (add/remove/fetch, linked-worktree detection, input parsing); the app only sequences them in asynctea.Cmds.don a worktree root becomesgit worktree remove(pendingOp kindopWorktree, with anfforce re-prompt when git refuses a dirty tree). -
Every session ft creates is named
<[sessions] prefix><kind>/<rest>, kind first.agentis<repo>/<branch>/<tool>fromtmux.SessionNameandm.repoIdentFor(internal/app/sessions.go) — the main repo of a linked worktree, so every worktree files under one name. Every other kind (tree,shell,lazygit,blame,diff) istmux.PlaceName: one path, rendered bytmux.Slugasstorekey.Namedoes it, basename plus a hash. Kind first is what letsParseNameread a name without counting its slashes, and what makes a query inTnarrow to one kind. The prefix is the only filter, so a name from before this convention still lists — unparsed, name only. "." and ":" are rewritten to "_" in a name because tmux does that silently otherwise, which would stopnew-session -Afinding what it created.- The popups build their own names in the catalogue out of
{prefix}and a key (-s {prefix}shell/{dirkey}), which composes because the value is quoted and the literal between them is not — the same trick as{session}/claude.{repokey}is inrepoTokensand the other two are not: a shell popup must keep working outside a repository. -Aon every one of them. A named session that already exists makes a barenew-sessionfail with "duplicate session", inside a popup that closes too fast to read it. The tree is the exception and cannot use-A(that would attach this terminal to the other tree), somainpicks a free name withtmux.UniqueNamebeforeWrapexecs — after the exec there is no process left to recover in.- The picker is a fourth
finderSource(srcTmux), not a new mode — see the bookmark view for the pattern; its ctrl+w/ctrl+s/ctrl+x are hardcoded in the modeFuzzy switch and listed infinderReservedKeys(ctrl+s is shared with the bookmark view, which the switch tells apart byfinderSrc), and the status bar lists them fromsessionHintswhile the view is open. It lists this tree too, fromtmux.SelfSession($TMUX_PANE):attachSession,paneSessionandkillSessionall refuse that row, because attaching shows the tree inside its own popup and killing it kills ft, andsortTmuxSessionsputs it last so the row nothing acts on does not lead a list ordered by activity.
- The popups build their own names in the catalogue out of
-
A session shown in a pane is a nested client, and that costs two things.
ctrl+wsplits the window and runstmux attach-sessionin the new pane (tmux.SplitAttach);X(detach-pane) sends it away again. tmux has no primitive for putting a session in a pane, and the two alternatives are worse:join-panemoves the agent's only pane, which destroys its window and therefore its session, so it stops being listable byTexactly while you are using it;link-windowgives you a whole window, which is what the popup already does. Nesting keeps the name, which is the identity everything else routes on. Two rules hold it together:- Unsetting
$TMUXis required and insufficient. tmux refuses to nest ("sessions should be nested with care"), and unsetting$TMUXalone sends the nested tmux to the default socket, where the session does not exist ("set $TMUX to force").AttachCommandtherefore passes the socket back with-S, recovered from$TMUXbytmux.SocketPath—$TMUXis<socket>,<pid>,<session index>. This is the same hazardAttachPopupavoids by never unsetting$TMUXat all, so the two must not be merged. - Which pane is showing what is read from tmux, never remembered. A
session attached in a pane is a client on that pane's tty, so
tmux.PaneShowingmatcheslist-clientsagainstlist-panesin ft's own window ($TMUX_PANE, captured once intoModel.selfPane). Nothing is stored, so it is still right after an ft restart, or for a pane opened by hand. It is also what makesctrl+wfocus an already-open pane instead of attaching a second client to it.ctrl+sis the same nested client in a different place: the bottom half of the pane to ft's right (tmux.PaneRightOf: last-active, then largest), split with-vdand no-f, so ft's column is untouched and needs no width restore; with nothing to the right it falls back toctrl+w's split. Because that stacks sessions,tmux.PaneShowingreturns the newest matching pane (highest id, compared numerically), which is what makesXdetach the one you opened last. The split is-fdh, like the pane commands in the catalogue:-dleaves the focus in ft, since opening an agent is not the same as wanting to type at it, and a secondctrl+won a session already on screen is what moves you into its pane. A full-width split (-f) takes its columns from every pane in the window,
so a 40-column ft beside an editor comes back at 18 and the tree stops being readable. Both
ctrl+wandXtherefore read ft's width immediately before the disruptive call and re-apply it after — reading rather than remembering, so a user resize is honoured. It is skipped when ft filled more than half the window, where there was no sidebar to preserve and restoring the old width would squeeze the pane just opened down to a single column. - Unsetting
-
An agent's state lives on its tmux session, written only by its own hooks.
ft agent-hook <prompt|tool|notify|stop|end>(cmd/ft/agenthook.go) sets the session option@ft_agentto"<state> <unix>"from$TMUX_PANE, andListreads it back as one morelist-sessionsfield — so the tree,Tand the status bar never keep state of their own, and an ft restart loses nothing.internal/agenthook.Decideis the whole event table; the command only sequences tmux andplatform.Notifyaround it (hookEnv, tested with fakes). Four decisions hold it together:- "Unseen" is tmux's bell flag, not ft's bookkeeping. The hook writes BEL
to the pane's tty; tmux raises
session_alertsonly for a session nobody is viewing and clears it on attach.Session.NeedsYouis waiting, or that flag — except whileworking, because the flag outlives an answer given without attaching. Notesession_alertsis<window index><flags>(0!), never words: the first version matched"bell"and never fired. - Passthrough is not the mechanism.
allow-passthroughonly reaches a terminal from a pane that is on screen; a detached session has none. The desktop banner therefore comes from the hook (osascript, text passed as argv so a payload cannot become script), and only whensession_attachedis 0. - A state outlives its agent, so it is ignored at a shell.
AgentNowdrops the state when the foreground command is a shell — the agent keys run<tool>; exec $SHELL, so that means the agent has exited, whether or not itsendhook ran. - The poll is one chain.
pollSessionsreads off the event loop and each result schedules the next tick (agentPollInterval, 2s), so a slow tmux never stacks reads. A failed read keeps the last count rather than showing "all clear", and an openTre-sorts with the cursor following the session by name.
- "Unseen" is tmux's bell flag, not ft's bookkeeping. The hook writes BEL
to the pane's tty; tmux raises
-
Quit ends the session only when ft made it, and the kill is
main's last act.tmux.Wrapstarts the inner ft with-owns-session(tmux.OwnerFlag, hidden from the usage text), andmainturns that into the session's id, read at startup (SetOwnedSession). The session name cannot be the test: a second ft run from a split inside a tree session reads the sametreekind, and would end its parent. The id is kept rather than re-read at quit because the pane can be moved (join-pane) into a session of yours, andtmux.CheckQuit(pure, table-tested) refuses when it has.CheckQuitalso calls a pane busy unless it is at a shell, dead, or a nestedtmuxclient — actrl+wpane only detaches, so its agent survives — and counts the session's other attached clients. Either one stages anopQuitSessionconfirmation, the one mode wherehandleKeydoes not rewrite ctrl+c to esc, and where the quit action's own key also answers: the second press is the answer.quit_closes_sessionis read at quit time (closesOnQuit), not at startup, so a config reload counts. The model only records the verdict (ClosesSession);mainkills by id after the program has stopped, the IPC socket has closed and state is saved, becausekill-sessionhangs up ft along with every other pane. Agent and popup sessions are separate sessions and are never touched. -
The tab title reaches the terminal through tmux, not around it.
tea.View.WindowTitlealone stops at tmux: it becomes the pane'spane_title, andset-titlesis off by default. Sotmux.Wrapchainsset-option set-titles onand aset-titles-stringoftmux.TitleFormatonto thenew-session(session options, so nothing else changes), and the model publishes the same string to the session option@ft_title(publishTitle, internal/app/title.go). The option rather than#{pane_title}because the string is evaluated against the active pane — focusing the editor split would hand the tab to helix. Writes are one chain, like the session poll: the title changes twice in quick succession at startup (name, then branch), and two concurrentset-options can land out of order.mainunsets the option on exit, since the session can outlive ft. -
Not every tmux subcommand takes the
=exact-match prefixtarget()adds.attach-session,kill-session,detach-client,join-paneandresize-panedo;set-option,display-messageandcapture-paneresolve-tdifferently and fail withno such session: =....PaneWidthspasses a bare pane id for exactly this reason. -
The status-bar branch (
⎇ …) is cached per repo inm.branches, filled by the same async cmds that read git status — so it refreshes wherever status does, and nowhere else. -
Marks (space bar) live only in the app model (
marked/markOrder, path-keyed, session-only). Copy/move of marked items goes throughinternal/fsops/transfer.go— destructive steps (overwrite, cross-device move source) always go via the injected Trash, never unlink. Delete (d) is mark-aware (falls back to the selection) and ancestor-dedupes the list first so a marked dir plus its marked children can't race.
Unit tests cover tree/gitx/config/state/search/fuzzy logic. Tests that need
ripgrep skip when it is absent (search.Available). For end-to-end checks,
drive the real binary:
- Plain pty:
script -q /tmp/out sh -c 'stty rows 30 cols 90; ./ft <dir>'with keystrokes piped on stdin. Ascriptpty starts 0x0 — without thesttythe app renders nothing. - tmux integration (hand-off commands, splits): create a detached session
(
tmux new-session -d -s t -x 200 -y 50 './ft <dir>'), drive withtmux send-keys, assert withtmux list-panes/tmux capture-pane -p. - Jump routing needs two sessions plus a shell pane to call from, and the
assertion is which tree moved.
capture-pane -pdrops colour, so the cursor is invisible in it — usecapture-pane -p -eand look for the selection background (^[[48;5;24m) on the row you expected. The two cases worth the setup are an instance in the caller's window losing to one elsewhere that actually contains the path, and a jump aimed at an instance suspended inhx(which must not stall the caller, and must land when the instance comes back). - When asserting "file opened in helix", grep the statusline (
NOR+ filename), not just the filename — pasted-garbage bugs also contain the filename in the buffer. - A disposable fixture repo with modified/untracked/ignored files is the standard way to exercise git colouring; create it under /tmp, not in this repo.
Known input gotcha (documented in the starter config): keys sent to helix
via tmux send-keys must deliver Escape in its own send, then sleep
~150ms, or ESC coalesces with the next byte and parses as an Alt-chord.
Anything that builds a shell string for tmux has to be exercised on macOS.
tmux runs display-popup and send-keys commands through default-shell,
which is /bin/zsh on a stock macOS and /bin/sh or bash in a Linux
container — so a whole class of bug is invisible off the supported OS. The one
that shipped: ShellQuote treated = as safe, the session picker's =
exact-match target reached zsh bare, zsh applied equals expansion (a word
starting with = becomes the path of the command it names), and
attach-session failed with the popup closing too fast to read the error.
Every other shell leaves =foo alone. Prefer passing tmux targets as direct
argv (exec.Command("tmux", "kill-session", "-t", target)) where there is no
template to honour — that path was never affected.
Two things worth measuring rather than reasoning about, both of which were
guessed wrong first: display-popup blocks its caller until the popup
closes (display-popup -E "sleep 4" takes four seconds), and a popup is not a
pane, so attaching from inside one passes tmux's nested-session check even
though $TMUX is set.