Repository navigation
Conversation
… show the conversation Bubble Tea emits tea.View.WindowTitle as OSC 2 only (the title bar). iTerm2 labels tabs from the ICON NAME (OSC 1) and falls back to the job name when none is set, so every mecatui tab read a uniform 'mecatui' and concurrent conversations were indistinguishable. Wrap the program output (both composition sites) in ui.NewTitleMirror, a stateful pass-through term.File that twins every complete OSC 2 sequence with a byte-identical OSC 1. Mirroring at the byte boundary inherits the renderer's change-only emission and exit-time clear for free, keeps the two labels provably identical, and touches no reducer: the Update command stream is byte-identical with and without it. The wrapper forwards Fd/Read/Close so Bubble Tea's TTY detection and colorprofile.Detect (both assert term.File) keep seeing the real descriptor. --terminal-title=off simply does not wrap, leaving the icon name untouched. Relates to #1460 (the system-context-in-title request from that issue is deliberately out of scope here). Co-Authored-By: mecatl <[email protected]>
|
I'm going to take a closer look and review, but one thing I'd like to do is make sure that this has a setting in |
|
I don't know how deep down this rabbit hole you want to go :) This works but installing the filter and parsing things looking for where we set the title feels a little hacky to me. Options:
In addition, right now the window title is kind of long: We could allow people to customize that (and set different things for window vs icon) through extending/reusing the templating system for the status line. https://mecatl.dev/docs/mecatui/status-line. We could give them a super rich set of information to use and maybe have a custom title returned via the optional command executable. Regardless:
Let me know what your thoughts are. |
|
Also, I'm happy to take this over and do the more comprehensive solution. Let me know |
|
@jbeda I’m not strongly confident in the current solution, so feel free to take over and reshape it however you think makes sense. Quick context on the options: option 1 (emitting via the |
|
Sounds good! Putting together a plan now. Thanks! |
|
Closing in favor of the plan in #1616 — the controller covers everything this PR was after. |
Problem
In iTerm2, every mecatui tab is labelled
mecatuiregardless of the conversation, so multiple sessions are indistinguishable (#1460).mecatui already composes a per-conversation title (
cmd/mecatui/ui/wintitle.go), but Bubble Tea emitstea.View.WindowTitleas OSC 2 only — the window title (title bar). iTerm2 honours xterm's title/icon split and labels tabs from the icon name (OSC 1), falling back to the job name when none is set. Terminals that don't distinguish the two (Ghostty, Alacritty, Kitty, WezTerm) show OSC 2 in the tab, which is why this went unnoticed.Fix
ui.NewTitleMirror— a stateful pass-throughterm.Filewrapping the program output at both composition sites (teaProgramOptionsincmd/mecatui/main.go). Every completeOSC 2sequence flowing to the terminal is immediately twinned with anOSC 1carrying the byte-identical payload.Why at the output byte boundary rather than in the Update loop:
Cmd-stream changes. (An earlier draft hooked the centralUpdatewrapper; it broke 5 existing tests that treat the returnedCmdas the complete side-effect set. This design was chosen specifically to avoid that class.)term.File(forwardsFd/Read/Close), because both Bubble Tea's TTY detection (p.output.(term.File)ininitInput) andcolorprofile.Detecttype-assert it; a plainio.Writerwould silently degrade colour rendering.--terminal-title=off/MECATUI_NO_TERMINAL_TITLE=1simply does not install the mirror, so "off" leaves the icon name untouched (whatever the shell set survives).Safety notes: the scanner is purely observational (output = input + injections at sequence boundaries — a malformed/truncated sequence degrades to "no mirror", never a corrupted frame); state survives split
Writes; payloads are capped (titleMirrorPayloadCap); the mirrored text was already escape-sanitised upstream byclampWindowTitle(C0/ESC/DEL stripped), so it cannot smuggle a terminator.Tests
cmd/mecatui/ui/titlemirror_test.go:Writesterm.Fileforwarding (Fd/Close)Gates
task testgreen (root + engine + standalone); fullcmd/mecatui/...suite green with zero pre-existing test perturbationtask lintclean for this diff (the one remaining finding,internal/adapter/privatefile/update_unix.goG115, is pre-existing onmainand untouched here)task docs:checkgreen (386 documents, 0 broken links). Fulltask docsfails locally insdk:install(pnpm under Node v20,ERR_UNKNOWN_BUILTIN_MODULE) — environmental, fails identically on cleanmaingo run ./cmd/mecademoprints a full offline sessionDocs
docs/tui.md(terminal-title section + flag table) and the--terminal-titleflag help now document the dual-sequence behaviour, the iTerm2 profile-title fallback, and the sharpened "off" semantics.Scope
Classification: Routine — an extra escape sequence through the already-gated title path plus docs; no durable contract changed. The system-context-in-title request from #1460 is deliberately out of scope (it changes the composed-title contract/rune budget — Bounded, needs an acceptance plan), so this PR relates to, and does not close, #1460.