Skip to content

Name the iTerm2 overlay pane so the tab keeps its label - #309

Merged
umputun merged 3 commits into
umputun:masterfrom
chris-peterson:fix-iterm-titles
Aug 5, 2026
Merged

umputun merged 3 commits into
umputun:masterfrom
chris-peterson:fix-iterm-titles

Conversation

@chris-peterson

@chris-peterson chris-peterson commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Context

The iTerm2 overlay opens as a split pane, and that pane is created with no name of its own. A tab's label comes from its active session, so once the overlay takes focus the tab falls back to the profile's title for the duration of the review and stops saying which session it belongs to. #307 carries the measurements.

tmux (-T), zellij (--name), herdr (--label), kitty (--title) and the emacs frame name already label their overlay from OVERLAY_TITLE. iTerm2 is not the only backend that doesn't — wezterm, cmux, ghostty and agterm don't either — it is the one whose pane visibly relabels the tab. This passes the same title into the iTerm2 branch and sets it on the session the split returns. Nothing has to undo it afterwards: the name belongs to the session, so it goes when the pane does.

Reach is narrow: on a stock profile the parent and the overlay render the same title and the tab doesn't change. This shows up for people who name their sessions.

Review guide

  • The fix — set name of newSession to overlayTitle after the split, with $OVERLAY_TITLE appended to the osascript argv, in .claude-plugin/skills/revdiff/scripts/launch-revdiff.sh
  • The same edit in the codex copy, which carries the # source: … (keep in sync) header
  • And in plugins/revdiff-planning/scripts/launch-plan-review.sh — the planning hook splits the same way and computes its own OVERLAY_TITLE (plan: <file>), so plan reviews had the same unlabelled tab
  • Why the title is appended rather than inserted — the osascript arm of app/testdata/plugin-exit-code/fake-overlay-backend.sh dispatches on argument count plus -x "$3", so an earlier position would shift the launch script out from under the stub. Appending leaves the stub's dispatch intact.
  • The test — TestIterm2OverlayNamesSession asserts the split osascript argv ends with the overlay title for all three launchers. The other backends pass OVERLAY_TITLE as a flag that TestShellLaunchersPreserveAnnotationExitCode already runs; iTerm2 hands it to AppleScript through argv, which nothing read, so a dropped argument was invisible. Capture is a new FAKE_OSASCRIPT_ARGS_FILE in the fake backend, mirroring FAKE_AGTERM_ARGS_FILE.

Testing

Ran the launcher for real on iTerm2 3.6.11 / macOS 26.5.2, against a profile whose session name interpolates a session variable:

overlay pane name tab label
master the profile's title, which renders empty here — the probe in #307 shows the pane carrying <b>\(user.probe_var)</b> with the variable missing. On a stock profile it is the default title text. the same, once the overlay takes focus
this branch rd: revdiff [HEAD~1] rd: revdiff [HEAD~1]

The tab label is what the fix restores. My OS window title emptied along with it, but @umputun's never moved, so that part follows from window title components rather than from the session name.

go test ./... passes and the CI shellcheck gate is clean on all three launchers.

A tab's label and the OS window title both come from the tab's active session,
and the overlay pane is created without a name of its own. Where the parent
session's name interpolates variables, the split inherits the name setting but
not the variables behind it, so both surfaces read empty for as long as the
review is up: measured on iTerm2 3.6.11, the overlay's name evaluates to
`<b></b>` while the parent reads `<b>PARENT</b>`.

Every other backend already labels its overlay from OVERLAY_TITLE — tmux via
-T, zellij --name, herdr --label, kitty --title, the emacs frame name. This
passes the same title into the iTerm2 branch and sets it on the session the
split returns, which also reverts on its own when the pane closes, the name
being the session's.

The title goes after the existing argv items on purpose: the test stub's
osascript arm dispatches on argument count and on `$3` being executable, so an
earlier insertion would shift the launch script out from under it.

Fixes #307
@umputun

umputun commented Aug 5, 2026

Copy link
Copy Markdown
Owner

two gaps against what #307 proposed.

plugins/revdiff-planning/scripts/launch-plan-review.sh needs the same edit and doesn't get it here. Its iTerm2 branch at line 385 splits without naming the session, same as the two you fixed, and it computes its own OVERLAY_TITLE at line 73. Your issue lists it. Without that edit plan reviews keep the behavior this PR fixes for diff reviews.

no test. The issue proposed an args-capture assertion in the FAKE_AGTERM_ARGS_FILE style on the iterm2 case, and that still looks right. Nothing in the suite would notice if the title argument were dropped again.

on the results table, I couldn't reproduce either the empty pane name or the window title moving. Measurements are in #307. The pane falls back to the profile's default title rather than rendering empty, and the window title never changed here at all. Worth trimming the claim to what the fix actually restores, the tab label.

The planning hook's launcher splits the same way and computes its own
OVERLAY_TITLE, so plan reviews kept the unlabelled tab this branch fixes
for diff reviews.

Also trims the comment beside the fix: the pane falls back to the
profile's default title rather than rendering empty, and the OS window
title is not the session name, so only the tab label is at stake.
The other backends pass OVERLAY_TITLE as a CLI flag the exit-code matrix
already runs; iTerm2 hands it to AppleScript through argv, which no test
read, so dropping the argument again would go unnoticed.

FAKE_OSASCRIPT_ARGS_FILE records each osascript invocation in the fake
backend, mirroring FAKE_AGTERM_ARGS_FILE, and the new test asserts the
split call ends with the title for all three launchers.

@umputun umputun left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@umputun
umputun merged commit fad239e into umputun:master Aug 5, 2026
@chris-peterson
chris-peterson deleted the fix-iterm-titles branch August 23, 2026 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants