feat(#59): menu bar status item for busy AI agents (gated behind spawnterm.agent_menubar)#64
Merged
Merged
Conversation
Import upstream gnachman#670 ("Menu bar status item for busy AI agents") behind the new spawnterm.agent_menubar capability flag (default OFF). When the flag is OFF, behavior is identical to stock iTerm2: the controller only shows a status item for the legacy "excluded from Dock + status bar icon" combination and never draws a busy-count badge. When the flag is ON, the independent menu bar item (gated additionally by the ShowMenuBarItem Advanced setting) and the orange busy-agent count badge become available. The flag is the master switch, wired in the three synced places (spawnterm-flag, spawnterm_flag.py, iTermSpawnTermCapabilities) plus the docs, and gated inside AIMenuBarStatusController.refreshOnMain. Adapted from upstream gnachman#670. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Owner
Author
|
Review by tech-lead — code APPROVED by inspection; build UNVERIFIED (environment). Import do upstream gnachman#670 adaptado (reject de RLog↔DLog em iTermApplication.m resolvido à mão; case
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #59
Summary
Imports upstream gnachman#670 ("Menu bar status item for busy AI agents") into the fork, gated behind a new spawnTerm capability flag so it is OFF by default and stock behavior is unchanged.
When enabled, an
NSStatusItemappears in the system menu bar. Idle, it shows the templateStatusItemglyph. When one or more AI agents are working, it renders an orange icon with a count badge (1–9, or+for 10 or more). The busy set is the union of OSC 21337 tab indicators (terminal Claude Code sessions) and ChatBroker agent-typing chats, deduped by namespaced id, so a terminal session and a built-in AI chat each contribute one. Clicking opens the existing status bar menu.Feature flag (master switch)
New flag
spawnterm.agent_menubar(default OFF), wired in the three synced places plus docs:spawnterm/flags/spawnterm-flag— added toKNOWN_FLAGSspawnterm/flags/spawnterm_flag.py— added toKNOWN_FLAGSwith descriptionsources/Settings/iTermSpawnTermCapabilities.m—capabilityIdentifiers+displayNameForCapability:→ "AI Agent Menu Bar"spawnterm/docs/feature-flags.md— schema row + exampleParity test (
spawnterm/flags/tests/test_flags.sh) still PASS=26, FAIL=0 (it counts assertions, not flags; shell/Pythonlistand byte-for-byte writer parity both hold with the 13th flag).Where activation is gated
Gating lives inside
AIMenuBarStatusController.refreshOnMain()(the single funnel that every trigger — app launch, defaults change, session-status observer, ChatBroker subscription — flows through), so the flag governs the item no matter what wakes the controller:flagOn = iTermSpawnTermCapabilities.isEnabledForCapability:@"agent_menubar"is the master switch.flagOn && iTermAdvancedSettingsModel.showMenuBarItem().statusBarIcon) is preserved regardless of the flag, and the busy-count badge is only drawn whenflagOn. So with the flag OFF the result is byte-for-byte stock behavior.Upstream's own
showMenuBarItemAdvanced setting is kept and AND-ed with our flag (flag is master).Provenance / patch apply
Applied
gh pr diff 670 --patch(3 commits) withgit apply --reject:AIMenuBarStatusController.swiftviatools/add_file_to_xcodeproj.rb ... iTerm2SharedARC(canonical, fork-local UUIDs) per repo convention.persistUserVarsToSidecar(Tier 4.C — user-var sidecar persistence (fork-direct) #51) did not materialize; both entries are present.RLogwhere upstream hadDLog. Resolved by hand: removed the inlineNSStatusItemcreation and replaced it with[[iTermAIMenuBarStatusController sharedInstance] refresh].ShowMenuBarItem, commit 2 removed it in favor of the Advanced setting) — file unchanged.Adaptations to compile under the fork
AIMenuBarStatusController.swift: added the fork's thirdChatBroker.Update.turnLifecyclecase to the subscription switch (upstream had only two); wrapped the main-actor-isolatedTypingStatusModel.instance.chatIDs(forParticipant:)read inMainActor.assumeIsolated; added the flag gate +showBadge:plumbing.#import "iTermSpawnTermCapabilities.h"tosources/iTerm2SharedARC-Bridging-Header.hso the Swift gate can call the capabilities class.Build status (honest)
Not verified by a clean compile in this environment.
tools/build.sh Developmentaborts in the dependency phase, before the main iTerm2 target compiles, because theCNoisesubmodule vendor sources are not checked out (Companion/CompanionCore/Sources/CNoise/vendor/src/protocol/*.c"File not found",noise/protocol.hnot found). This is a pre-existing environment limitation unrelated to this change — no error in the log references any file touched here.Verified correct-by-inspection instead: every imported symbol exists in our tree — the
@objc(sharedInstance) static letsingleton pattern (matchesImageRegistry,FocusOrder, etc.),iTermApplicationDelegate.statusBarMenu()(protocol method the delegate class conforms to),iTermPreferences.boolForKey:,iTermAdvancedSettingsModel.showMenuBarItem()/.statusBarIcon(),SessionStatusController.instance.statusesvalues'hasIndicator/sessionID, andTypingStatusModel.chatIDs(forParticipant:).Files changed
sources/AppKit/AIMenuBarStatusController.swift(new)sources/AITerm/ChatListModel.swiftsources/AppKit/iTermApplication.msources/AppKit/iTermApplicationDelegate.msources/Settings/iTermAdvancedSettingsModel.{h,m}sources/Settings/iTermSpawnTermCapabilities.msources/iTerm2SharedARC-Bridging-Header.hiTerm2.xcodeproj/project.pbxprojspawnterm/flags/spawnterm-flag,spawnterm/flags/spawnterm_flag.py,spawnterm/docs/feature-flags.mddocs/notes-3.7.txtNo submodule, ThirdParty, or version-stamp changes.
🤖 Generated with Claude Code