Skip to content

feat(agentop): choose the palette with AGENTOP_THEME and name sessions with r - #2157

Merged
huang195 merged 3 commits into
rossoctl:mainfrom
michaljacovi:agentop-theme-nicknames
Nov 28, 2026
Merged

huang195 merged 3 commits into
rossoctl:mainfrom
michaljacovi:agentop-theme-nicknames

Conversation

@michaljacovi

Copy link
Copy Markdown
Contributor

Two small viewer changes, one commit each.

1. The palette can be chosen (a76dcf3)

lipgloss picks each AdaptiveColor's light or dark half by asking the terminal for its background. Where the terminal can't answer, it assumes dark: the Windows console, Windows Terminal and many SSH sessions can't answer. On a light terminal, the dark palette paints every second table row near-black.

Now the palette can be chosen before the first render:

  • AGENTOP_THEME=light|dark|auto, which wins;
  • otherwise theme: light|dark|auto in agentop's settings file;
  • auto (the default) reads COLORFGBG first (xterm, rxvt and Konsole set it), then leaves the choice to lipgloss as before.

A value agentop doesn't understand is reported on stderr and ignored, and the next source decides. The root usage text and the Troubleshooting section of docs/windows.md say how to set it.

On the light palette the zebra row is #F3F4F6, a soft grey (1.1:1 against white). Every text colour keeps at least 4.4:1 contrast on it.

2. Name a session with r (e26fa22)

r on the sessions pane opens a one-line prompt, pre-filled with the current nickname. Enter saves it, an empty name clears it, and Esc keeps the old one. The nickname is shown instead of the title derived from the first prompt, and the help overlay lists r under SESSIONS. The prompt is drawn on Sessions only, so a pane change that comes from a message (the agents list arriving) closes it.

The nickname is stored only on this machine, as a new nickname field in ~/.cortex/session-metadata.json, and is never sent anywhere. SetNickname is its only writer, so a harvest never sets one:

  • Just before it saves, a harvest takes every nickname from the file as it is at that moment (keepNicknames). A rename or a clear made while the harvest ran therefore wins over the copy it read at the start. On Windows, where the metadata lock is a no-op, that narrows the race to the moment between that read and the save. It also keeps nicknames over read-claude-sessions --merge=false, which can't rebuild them.
  • The viewer's merge of a harvest keeps its own nickname for a session it already knows.

The name is sanitised and capped like a title before it is shown.

Tests

  • TestApplyTheme: the order env, then setting, then COLORFGBG, plus the handling of a bad value.
  • TestZebraRowOnALightPalette.
  • TestRenameSession: open, type, save, Esc, clear, and a failed save.
  • TestSetNicknameSurvivesAHarvest and TestKeepNicknamesTakesTheFilesNicknames.
  • TestAStaleHarvestKeepsTheRename, TestRenamePromptClosesWhenThePaneChanges and TestRenameWithALeftoverColumnPicker.

Known limits:

  • Enter saves on the UI goroutine. On unix, if another harvest holds the metadata lock, the viewer waits for it (up to the lock's 30 s timeout, after which the rename fails with a message).
  • On Windows the metadata lock is a no-op, as it already is for the harvest. TestHarvest_ConcurrentRunsLoseNothing and TestHarvest_UnreadableMetadataIsRefusedNotRebuilt fail on Windows on main too, with "Access is denied" on the rename.
  • TestRunOptionsWiringEndpointBypass was skipped locally: it hangs intermittently on Windows on main too (bubbletea's stdin reader blocks after a cancelled context). Not related to this change.
  • Other tests that fail locally on Windows fail on main too, for file modes, symlinks or path separators: the yank tests and TestServerNotice_NamesTheConfigFileAsAgentopServerDoes.

Assisted-By: Claude (Anthropic AI) [email protected]

@michaljacovi
michaljacovi requested a review from a team as a code owner November 26, 2026 20:09
@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d833cff8-b075-46d9-a52b-b649acd042e0
Commits

Reviewing files that changed from the base of the PR and between ea5cf05 and aeeadf5.

Files selected for processing: 16

  • cmd/agentop/main.go
  • cmd/agentop/tui/app.go
  • cmd/agentop/tui/help_overlay.go
  • cmd/agentop/tui/key_grammar_test.go
  • cmd/agentop/tui/keys.go
  • cmd/agentop/tui/rename.go
  • cmd/agentop/tui/rename_test.go
  • cmd/agentop/tui/sessions_title.go
  • cmd/agentop/tui/settings.go
  • cmd/agentop/tui/theme.go
  • cmd/agentop/tui/theme_test.go
  • core/observe/claude/harvest.go
  • core/observe/claude/lock_unix_test.go
  • core/observe/claude/metadata.go
  • core/observe/claude/nickname_test.go
  • docs/windows.md
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions github-actions Bot added the ready-for-ai-review Request automated AI code review from clawgenti label Nov 26, 2026

@clawgenti clawgenti left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Clawgenti Code Review — COMMENT

Two cleanly separated commits. The rename half carries the risk and its central claim holds end to end: I seeded {Title:"old", Nickname:"Mine"}, ran Harvest{Merge:true} and then Harvest{Merge:false} against an empty config dir, and read the file back — Nickname:Mine both times (the rebuild reduces the entry to {Nickname:"Mine"}, which is the documented intent). SetNickname is the only writer, the viewer's own merge keeps its copy for a known session, and sessionTitleFor puts the nickname ahead of both the harvested and the served title. The theme half is small and its precedence is what the body says: env, then the setting, then COLORFGBG, then lipgloss.

No must-fix findings; three suggestions and two nits inline.

What I verified at head e26fa22 (go1.26.10, linux):

  • go vet ./cmd/agentop/... ./core/observe/claude/ clean, gofmt -l clean, go test ./core/observe/claude/ and go test ./cmd/agentop/tui/ pass.
  • Palette contrast computed (WCAG 2.x relative luminance), not eyeballed, against colorZebraBg.Light #F3F4F6: #6B7280 = 4.39:1, #9CA3AF = 2.31:1, accent/ok/warn/error/inbound/outbound = 4.56–6.44:1. The zebra row itself is 1.10:1 against white, as the body says.
  • Rename-survives-harvest probe described above; the throwaway probe file was deleted afterwards.

Author: @michaljacovi (CONTRIBUTOR association; collaborator permission admin — maintainer)
Areas reviewed: Go (cmd/agentop/tui, cmd/agentop/main.go, core/observe/claude), tests, docs
Agent/IDE config (.claude/.vscode): none
Commits: 2, all signed-off: yes
CI status: failing — Go CI (authbridge agentop) ended at exactly 5m00s on this head (the same leg took 4m01s on base 2cb6e04 and 4m04s on #2156's head 9edc282), which reads like the test step hitting a limit, but GitHub's job-log blob host is unreachable from my sandbox, so I could not read the failure and cannot say whether this PR causes it. verify-pr-title fails (agentop: is not a conventional prefix) and Python Tests (sparc-service) fails on main too. Worth a re-run before merge.
Not checked:

  • Windows behaviour — no Windows host here: the documented Windows-only test failures, and lockMetadata being a no-op there (the body states this limit itself).
  • lipgloss's own terminal query (the auto fallback after COLORFGBG) — no TTY in this sandbox.

Generated by repoman github-pr-review@af425c8.

func (m *model) sessionTitleFor(id, served string) string {
// A NICKNAME WINS OVER BOTH: the person named this session themselves (`r`). Sanitised and
// capped like the harvested title, for the same reasons, since the file is hand-editable.
if nick := m.sessionsData[id].Nickname; !titleIsBlank(sanitizeLabel(nick)) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

suggestion: sanitizeLabel runs three times for one row here. titleIsBlank already sanitises (blankSanitized(sanitizeLabel(title)), session_metadata.go:472-474), so titleIsBlank(sanitizeLabel(nick)) sanitises twice, and the capTitleRunes(sanitizeLabel(nick)) on the next line makes three — each a fresh b.Grow(len(s)) copy, per row per rebuild. That is the cost blankSanitized's own doc says to avoid ("Callers holding a sanitised string should say so rather than pay for the round trip"), and the comment further down this function makes the same argument for the served title.

Suggested fix:

if nick := sanitizeLabel(m.sessionsData[id].Nickname); !blankSanitized(nick) {
    return capTitleRunes(nick)
}

Same answer on every input (sanitizeLabel is idempotent), one copy instead of three.

mergeHarvest(existing, meta)
meta = existing
}
keepNicknames(path, meta)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

suggestion: This line makes the "nothing to lose" premise of the lock above untrue for --merge=false. The lock is skipped when Merge is false ("that path replaces the file by definition", lines 213-214), but a rebuild now reads the file's nicknames and writes them back, so it is no longer a pure replacement: a rename that lands between keepNicknames's ReadMetadata and the SaveMetadata a few lines below is dropped, and no later harvest can recover it — the file is the only copy.

Concrete case: agentop experimental read-claude-sessions --merge=false (0.7-1.2 s, per the Options comment) running while someone presses Enter on a rename in the viewer. The rename takes the lock; the rebuild never waits for it and never holds it.

I did confirm with a probe that the rebuild path does preserve a nickname present when it reads (seeded {Title:"old", Nickname:"Mine"}, Harvest{Merge:false} → {Nickname:"Mine"}), so the hole is the window, not the mechanism.

Suggested fix: take lockMetadata for the rebuild too — or just around keepNicknames + SaveMetadata when the file already holds a nickname — and update the comment above so it still says what is true.

if _, err := ApplyTheme("light", "", ""); err != nil {
t.Fatal(err)
}
if colorZebraBg.Light != "#F3F4F6" || lipgloss.HasDarkBackground() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

suggestion: This asserts the literal colorZebraBg.Light == "#F3F4F6", which nothing in the code can change, and leaves the body's actual claim — "Every text colour keeps at least 4.4:1 contrast on it" — untested. Measured against #F3F4F6: colorMuted #6B7280 is 4.39:1 (below 4.4, though it rounds to it), and colorDim #9CA3AF is 2.31:1 — and colorDim is real ink on zebra rows: tableGlyphs draws the CTX track ░, the BYTES arrows and the tool/subagent marks with it inside cells (styles.go:152-153), so on an alt row that is 2.31:1 grey on #F3F4F6. accent/ok/warn/error/inbound/outbound are the ones that hold (4.56-6.44).

Suggested fix: either narrow the sentence to the inks it is true for, or darken colorDim.Light for the light palette. A small table test that computes the WCAG ratio for each palette entry against colorZebraBg.Light would pin whichever you choose — that is the assertion this test reads as if it were meant to make.

}
entry := meta[id]
entry.Nickname = name
if name == "" && entry.Title == "" && entry.LogFile == "" && len(entry.Subagents) == 0 {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: "An entry with nothing else in it" is decided by three of the struct's six fields. SessionMetadata also carries AgentType, AgentConfigDir and LogModTime (metadata.go:60-97), so an entry holding only one of those — Title, LogFile and Subagents all empty is the whole test — would be deleted, nickname and all. Today ReadSessions always sets LogFile, so a harvest cannot produce such an entry; this is the hand-maintained list drifting the next time a field is added.

Suggested fix: extend the condition with entry.AgentType == "" && entry.AgentConfigDir == "" && entry.LogModTime.IsZero(), or compare against a zero entry with Nickname cleared.

Comment thread cmd/agentop/tui/keys.go
// means reset (events) or refresh (pickers).
// colPicker is the Events pane's and can be left set after a message drops to Sessions, so it
// does not gate this (as with `/`).
if msg.String() == "r" && m.pane == paneSessions && m.editState.phase == editPhaseDone {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: This block sits between the T handler's doc comment (lines 210-211) and the T handler itself (line 223), so the comment explaining T now reads as if it explains r, and the T block below is left with no comment of its own. In this file the comments are the design record, so the adjacency is worth keeping: put the r block after the T block, or lift the T comment down onto its if.

@michaljacovi michaljacovi changed the title agentop: choose the palette (AGENTOP_THEME), and name sessions with r feat(agentop): choose the palette with AGENTOP_THEME and name sessions with r Nov 26, 2026

@clawgenti clawgenti left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Clawgenti Code Review — COMMENT

Re-review at head e57fc29, after commit 3. The earlier review on this PR was at e26fa22; the other four of its inline comments (two suggestions, two nits) still stand at this head and are not repeated here. Commit 3 closes the one that mattered: --merge=false used to skip the lock while keepNicknames still read the file's nicknames and wrote them back, so a rename landing in that window was lost with no way to recover it. The lock is now taken for a rebuild too, and keepNicknames runs under it — the claim holds. No must-fix findings; three suggestions inline.

Verified at head e57fc29 (go1.26.10, linux):

  • go vet ./cmd/agentop/... ./core/observe/claude/ clean, gofmt -l clean, go test ./core/observe/claude/ (3.2s) and go test ./cmd/agentop/tui/ (53.9s) pass.
  • Positive control on the new test: restoring if opts.Merge { around the lock turns TestHarvest_RebuildTakesTheLock red — a rebuild did not try the lock: LockTimedOut is false with the lock held. So the test does pin commit 3.
  • Rebuild probe (deleted afterwards): file {s1:{Title:"old",Nickname:"Mine"}, s9:{Title:"gone",Nickname:"Orphan"}} plus one transcript titled fresh title, then Harvest{Merge:false} → on disk s1 = {Title:"fresh title", Nickname:"Mine"}, s9 nickname-only; Result{Total:2, Harvested:1, Rebuilt:false}.

Two things the body does not yet say: it still describes two commits, and commit 3 changes what read-claude-sessions --merge=false does when the lock is held — it now waits (up to the 30 s timeout) and can report LockTimedOut/LockFailed, where before it reported neither. Worth a sentence in the "keepNicknames" bullet.

Author: @michaljacovi (CONTRIBUTOR association; collaborator permission admin — maintainer)
Areas reviewed: Go (core/observe/claude, cmd/agentop/tui, cmd/agentop/main.go), tests, docs
Agent/IDE config (.claude/.vscode): none
Commits: 3, all signed-off: yes
CI status: passing at e57fc29 — Go CI (authbridge agentop) is now pass at 3m48s (it hit 5m00s at e26fa22), DCO pass. Python Tests (sparc-service) fails, but it fails on base 2cb6e04 too (same job, failure at 19:16Z on that SHA), so it is not this PR.
Not checked:

  • Windows behaviour — no Windows host here; the lock is a no-op there and keepNicknames only narrows the race, which the body states as a known limit.
  • The live TUI paths (the prompt on a real terminal, a rename racing a real harvest) — no TTY in this sandbox; the property is covered by the package's own tests instead.

Generated by repoman github-pr-review@af425c8.

// but it carries every nickname over from the file (keepNicknames), so a rename landing
// between that read and the save would be lost without it.
// The error is recorded, not returned: proceeding unlocked is the deliberate fallback, so a
// caller that wants to report the risk can, and one that does not still harvests.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

suggestion: This line makes the LockFailed doc stale: it still says the field is empty when locking was "not attempted (no Merge)" (line 157). The lock is now attempted on both paths, so the only ways it ends up empty are a successful lock and a no-op platform. Worth fixing now, because LockFailed is exactly what the CLI keys its "harvested anyway" warning on (cmd/agentop/cmd_experimental.go:202-203), and a reader looking there after a --merge=false run would conclude no lock was tried.

mergeHarvest(existing, meta)
meta = existing
}
keepNicknames(path, meta)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

suggestion: keepNicknames can add entries a rebuild never harvested — nickname-only ones for sessions whose transcript is gone — and it does so just before res.Total = len(meta), so on a rebuild Total exceeds Harvested with nothing accounting for the difference. Probe at this head: a file holding {s1:{Title:"old",Nickname:"Mine"}, s9:{Title:"gone",Nickname:"Orphan"}} plus one transcript titled fresh title gives Result{Total:2, Harvested:1, Rebuilt:false}, with Kept:0 (Merge-only by its own doc) and Recovered:0. That breaks two documented statements: the identity on Kept (line 117, Total = Harvested + Kept + Recovered) and Meta's "just this harvest otherwise" (line 163). The visible effect is on the non-merge branch of read-claude-sessions, which prints only Wrote %d session(s) from res.Total (cmd/agentop/cmd_experimental.go:230): one transcript, "Wrote 2 session(s)". Suggested fix: either give it a counter (KeptNicknames) so the identity holds, or say it in words on Meta and Kept — "on a rebuild, Total can also count entries kept for their nickname alone".

if got := gone["s1"]; got.Nickname != "" || got.Title != "t" {
t.Errorf("after the file was deleted: %+v, want the title without the nickname", got)
}
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

suggestion: Commit 3 has two halves and nothing joins them. This test pins keepNicknames in isolation and TestHarvest_RebuildTakesTheLock pins that a rebuild calls the lock, but no test runs a rebuild over a file that holds a nickname — which is the whole reason the rebuild now takes the lock. Mutation at this head: deleting the keepNicknames(path, meta) call (harvest.go:291) leaves the entire core/observe/claude suite green; only a throwaway Harvest{Merge:false} probe caught it (s1 nickname = "", want Mine). Suggested fix: one test here that writes {s1: {Title:"old", Nickname:"Mine"}}, harvests a transcript for s1 with Merge:false, and asserts the file comes back with the harvest's new title and Nickname:"Mine" — the pairing the lock exists to protect, pinned end to end.

@clawgenti clawgenti left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review at e57fc29 - APPROVE

Both features do what the PR says. I built the head locally and drove both through probe tests. ApplyTheme resolves env, then the setting, then COLORFGBG, and SetHasDarkBackground pins lipgloss's default renderer before the first render. r opens, saves, clears and cancels as described. A nickname survives Merge, Incremental and --merge=false harvests, and the third commit closes the rebuild-without-lock gap raised on e26fa22. I found no must-fix issues. There are four suggestions inline and two doc gaps below.

Verified (go1.26.10, linux):

  • go vet and gofmt -l are clean on cmd/agentop/... and core/observe/claude. go test ./core/observe/claude/ and go test ./cmd/agentop/tui/... pass.
  • go test ./cmd/agentop fails only TestServiceInstall_RefusesABrokenConfig, and that test fails the same way on base 9c6a8d7. The sandbox has no systemd user bus, so this is an environment issue and not caused by the PR.
  • Decoders: UserSettings.Theme decodes theme: true, theme: 0 and an empty theme: as strings without failing the YAML parse. nickname is an omitempty string read by plain json.Unmarshal, so older binaries ignore it.
  • Rename prompt probe: typing U+202E (RTL override) and U+200B (zero-width space) puts both into the file and into the flash (see inline). With 40 sessions in a 20-row terminal, the prompt pushes the highlighted bottom row out of view (see inline).

Docs not updated (outside the diff, so not inline):

  • cmd/agentop/README.md L1163 still says "Nothing else feeds a setting: there is no environment variable (no AGENTOP_* ...)". AGENTOP_THEME now does, and the settings schema table above that line has no theme row.
  • The README key table (L863) lists r only for namespaces and pods. It needs a sessions row for rename, to match the help overlay.

Author: michaljacovi (CONTRIBUTOR association; collaborator permission admin, so maintainer)
Areas reviewed: Go (cmd/agentop, cmd/agentop/tui, core/observe/claude), tests, docs
Agent/IDE config (.claude/.vscode): none
Commits: 3, all signed-off: yes
CI status: two jobs fail, and neither is caused by this PR. Python Tests (sparc-service) also fails on main (2cb6e04), and this PR touches no Python. Go CI (core peerproc, macOS) was cancelled at the 10-minute job limit, also on main. The Go jobs that cover this diff (authbridge agentop, core, Windows build) pass with no annotations.
Not checked: Windows behaviour (no host here), and lipgloss's live OSC 11 query (no TTY).

Comment thread cmd/agentop/tui/theme.go
}
break // auto: stop at the first source that names it
}
if dark, ok := darkFromColorFGBG(fgbg); ok {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

suggestion: On unix this reverses the precedence that auto had before. termenv v0.16.0 (termenv_unix.go:102-118) already reads COLORFGBG, but only after the OSC 11 query fails. Here, COLORFGBG pins the palette before the query can run. COLORFGBG is set once when the shell starts, so it goes stale while OSC 11 does not: iTerm2 exports it from the profile at session start, and its automatic light/dark switching leaves the value behind. A tmux server started from a dark terminal and attached from a light one has the same problem. Those users never asked for a theme, and they would now get the wrong palette by default. On Windows, termenv's backgroundColor() just returns ANSIColor(0), and that is the case this PR targets. Consider reading COLORFGBG only when runtime.GOOS == "windows" and leaving unix to lipgloss as before (or adjust the help text if the inversion is intended).

if err != nil {
return err
}
name = strings.TrimSpace(name)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

suggestion: This only trims and caps the nickname, so format characters are written to the file. I typed ab\u202ecd\u200bef into the prompt, and the file holds "ab\u202ecd\u200bef". bubbles' textinput sanitiser drops C0/C1 controls but keeps bidi overrides and zero-width characters. scrub.go states that this file's contract is "plain text with nothing hidden in it, which has to be true of the FILE, not of one reader". The viewer's sanitizeLabel covers its own table, but not other readers of the file. Consider running the nickname through scrubRunes (or clipTitle, if stripping markup is acceptable) before the cap.

Comment thread cmd/agentop/tui/rename.go
if name == "" {
m.setFlash("nickname cleared")
} else {
m.setFlash("renamed to " + name)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

suggestion: The same probe shows the raw name in the flash: "renamed to ab\u202ecd\u200bef...". fitFlashLine does not sanitise, so an RTL override reaches the footer. Use the sanitised name here, for example capTitleRunes(sanitizeLabel(name)), which is what sessionTitleFor shows. That also keeps the flash and the table in agreement.

Comment thread cmd/agentop/tui/app.go
body = m.searchPromptView() + "\n" + body
}
if m.renameID != "" && m.pane == paneSessions {
body = m.renameInput.View() + "\n" + body

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

suggestion: layout() saves a row for the search prompt (layout.go:37, bodyH--, and framePane adds it back), but not for this prompt, so boxFrame cuts off the last table row while you type. I tested with 40 sessions in a 20-row terminal and the cursor on the bottom visible row (sess-39). With the prompt open, the last visible row is sess-38, so the session being renamed is off screen. Saving the row the same way as search (bodyH-- when m.renameID != "" && m.pane == paneSessions, frameH++ in framePane, and a layout() call on open and close) would fix it.

Comment thread cmd/agentop/tui/app.go
// started before a rename or a clear carries the old one, so a known session keeps
// the viewer's own.
if known, ok := m.sessionsData[id]; ok {
meta.Nickname = known.Nickname

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

suggestion: This guards against a harvest that went stale while this viewer renamed. It also hides renames made anywhere else for as long as the viewer runs. Example: two agentop observe windows are open and you rename a session in A. B's next harvest returns res.Meta with A's nickname (keepNicknames read it from disk), but B already knows the session, so it keeps its empty nickname until it restarts. A hand edit, which sessionTitleFor says is supported, is ignored the same way. TestAStaleHarvestKeepsTheRename's s2 case pins this behaviour. Since res.Meta already carries the file's nicknames as they were at save time, it would be enough to override only the ids this viewer renamed after the harvest was dispatched. For example, keep a renamedSince set that is cleared when a harvest starts.

}
for id, e := range latest {
if _, ok := meta[id]; !ok && e.Nickname != "" {
meta[id] = SessionMetadata{Nickname: e.Nickname}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: Under --merge=false this keeps a {nickname}-only stub for every session the rebuild did not see. read-claude-sessions --help (cmd_experimental.go:54-61) still says a rebuild "drops every entry this run did not see" and "is what prunes it". Once a session's transcript is gone and Cortex no longer serves it, nothing can remove its stub: the viewer cannot select it to clear the name, and a rebuild keeps it. Either update the help text, or drop stubs for ids the rebuild did not see and keep only nicknames on entries that are still in meta.

lipgloss picks each AdaptiveColor's light or dark half by asking the
terminal for its background. Where the terminal cannot answer (the Windows
console, Windows Terminal, many SSH sessions) it assumes dark, so on a light
terminal every second table row is painted near-black.

The palette can now be chosen before the first render:
- AGENTOP_THEME=light|dark|auto, which wins;
- else `theme: light|dark|auto` in agentop's settings file;
- auto, the default, reads COLORFGBG first (xterm, rxvt, Konsole), then
  leaves it to lipgloss as before.
A value it does not understand is reported on stderr and ignored: the
next source decides.

The root usage and docs/windows.md (Troubleshooting) say how to set it.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Michal Jacovi <[email protected]>
`r` opens a one-line prompt, pre-filled with the current nickname. Enter
saves it, an empty name clears it, and Esc keeps the old one. The nickname
is shown instead of the title derived from the first prompt.

It is stored only on this machine, as a new `nickname` field on the
session's entry in ~/.cortex/session-metadata.json, and never sent
anywhere. SetNickname is its only writer, so a harvest never sets one:
- just before it saves, a harvest takes every nickname from the file as
  it is then (keepNicknames), so a rename or a clear made while it ran
  wins over the copy it read at the start. That is what keeps a rename on
  Windows, where the metadata lock is a no-op, and it keeps nicknames over
  `read-claude-sessions --merge=false` too;
- the viewer's merge of a harvest keeps its own nickname for a session it
  already knows, for the same reason.
Clearing the nickname of a session that has no other metadata removes the
entry rather than leaving an empty one.

The prompt is drawn on Sessions only, so a pane change that comes from a
message (the agents list arriving) closes it rather than leaving keys
going into a hidden box. The help overlay lists `r` under SESSIONS.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Michal Jacovi <[email protected]>
A harvest took the metadata lock only under Merge, on the footing that a
rebuild (read-claude-sessions --merge=false) replaces the file and so has
nothing to lose. Since keepNicknames, a rebuild carries every nickname
over from the file just before it saves, so a rename landing between that
read and the save would be lost. Take the lock in both modes.

TestHarvest_RebuildTakesTheLock holds the lock and checks that a rebuild
waits for it and reports the timeout, as a merge does.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Michal Jacovi <[email protected]>
@huang195
huang195 force-pushed the agentop-theme-nicknames branch from e57fc29 to aeeadf5 Compare November 28, 2026 19:57

@huang195 huang195 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The theme order (env, then setting, then COLORFGBG) and the nickname merge are correct. keepNicknames under the lock closes the stale-harvest race on unix, and the viewer's merge closes it on screen. The nickname correctly stays out of sessionHasTitle, so the harvest backoff does not change.

Docs (suggestion): cmd/agentop/README.md around line 1163 says "Nothing else feeds a setting: there is no environment variable (no AGENTOP_*…)". AGENTOP_THEME now overrides theme:, so that sentence is false. That section also does not list theme:. The key table near line 863 and the table in docs/using-agentop.md near line 263 have no r row for Sessions.

Nits: The PR body gives the commit hashes a76dcf35 and e26fa22d, but the commits are now 40647f2 and 910a334. The body does not mention the third commit (aeeadf5, the lock for a rebuild). The commit subjects use agentop:, not a conventional prefix.

Agent/IDE config (.claude/.vscode): none
Commits: 3, all signed off
CI: all checks pass

Comment thread cmd/agentop/tui/rename.go
case tea.KeyEnter:
id, name := m.renameID, strings.TrimSpace(m.renameInput.Value())
m.renameID = ""
if err := saveNickname(id, name); err != nil {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

suggestion: saveNickname runs on the UI goroutine and takes the metadata lock. The viewer's own startup harvest (harvestCmd) holds that lock for the full transcript scan, which takes about 0.7 s on a large ~/.claude. Thus Enter during that scan freezes the frame until the scan ends, and for up to 30 s when a different process holds the lock. Run the save in a tea.Cmd and apply the nickname when its message arrives. Then the frame does not freeze.

Comment thread cmd/agentop/tui/keys.go

// `T` opens the Timeline for one session, from the same panes `u` opens Usage from. On
// Sessions it is the highlighted row: unlike Usage, a timeline has no all-sessions view.
// `r` names the highlighted session (rename.go). Sessions pane only: elsewhere r already

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: The new r block sits between the T comment ("T opens the Timeline…") and the T code. The T comment now describes the r block. Move the r block above that comment.

}

// The nickname is stored beside the harvested entry and survives a harvest that rewrites it.
func TestSetNicknameSurvivesAHarvest(t *testing.T) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: TestSetNicknameSurvivesAHarvest runs no harvest. It tests only claude.SetNickname, so it belongs in core/observe/claude/nickname_test.go. Rename it to describe what it tests, or add a Harvest call between the set and the read.

@huang195
huang195 merged commit 5de570d into rossoctl:main Nov 28, 2026
41 checks passed
@github-project-automation github-project-automation Bot moved this from New/ToDo to Done in Rossoctl Issue Prioritization Nov 28, 2026
huang195 pushed a commit that referenced this pull request Nov 29, 2026
saveNickname takes the metadata lock, and the viewer's own startup harvest holds it for its
whole scan (about 0.7 s on a large ~/.claude), so Enter in the rename prompt during that scan
froze the frame until the scan ended, and for up to 30 s when another process held the lock
(from the review of #2157, rename.go:48).

Enter now closes the prompt and returns a command that saves; the nickname is shown, or the
failure flashed, when its message arrives. A harvest that lands in between keeps the
viewer's old nickname, as before, and the save's message then sets the new one.

Also from that review: the `r` block in keys.go moves above the `T` comment, which it had
split from its code, and TestSetNicknameSurvivesAHarvest, which runs no harvest, is renamed
TestSetNicknameKeepsTheHarvestedTitle.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Michal Jacovi <[email protected]>
huang195 added a commit that referenced this pull request Nov 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-ai-review Request automated AI code review from clawgenti

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants