Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 44 additions & 3 deletions cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3092,10 +3092,32 @@ def _get_status_bar_snapshot(self) -> Dict[str, Any]:
if len(model_short) > 26:
model_short = f"{model_short[:23]}..."

provider_name = getattr(self, "provider", None) or getattr(self, "requested_provider", None) or ""
codex_credential_label = ""
if provider_name == "openai-codex":
try:
source = getattr(self, "_provider_source", None) or ""
if isinstance(source, str) and source.startswith("pool:"):
codex_credential_label = source.split(":", 1)[1].strip()
if not codex_credential_label:
from agent.credential_pool import load_pool

pool = load_pool("openai-codex")
if pool and pool.has_credentials():
entry = pool.select()

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.

select() is not a read-only lookup: current main refreshes entries, increments least-used counters, and persists round-robin rotation (agent/credential_pool.py:1527-1554). Calling it from the repeatedly-rendered status snapshot can change the active credential; retain the resolved label or use a read-only lookup instead.

if entry is not None:
codex_credential_label = str(getattr(entry, "label", "") or "").strip()
if len(codex_credential_label) > 18:
codex_credential_label = f"{codex_credential_label[:15]}..."
except Exception:
codex_credential_label = ""

elapsed_seconds = max(0.0, (datetime.now() - self.session_start).total_seconds())
snapshot = {
"model_name": model_name,
"model_short": model_short,
"provider": provider_name,
"codex_credential_label": codex_credential_label,
"duration": format_duration_compact(elapsed_seconds),
"prompt_elapsed": self._format_prompt_elapsed(
getattr(self, "_prompt_start_time", None),
Expand Down Expand Up @@ -3358,7 +3380,10 @@ def _build_status_bar_text(self, width: Optional[int] = None) -> str:
text += " · ⚠ YOLO"
return self._trim_status_bar_text(text, width)
if width < 76:
parts = [f"⚕ {snapshot['model_short']}", percent_label]
parts = [f"⚕ {snapshot['model_short']}"]
if snapshot.get("codex_credential_label"):
parts.append(f"Codex:{snapshot['codex_credential_label']}")
parts.append(percent_label)
compressions = snapshot.get("compressions", 0)
if compressions:
parts.append(f"🗜️ {compressions}")
Expand All @@ -3379,6 +3404,8 @@ def _build_status_bar_text(self, width: Optional[int] = None) -> str:

compressions = snapshot.get("compressions", 0)
parts = [f"⚕ {snapshot['model_short']}", context_label, percent_label]
if snapshot.get("codex_credential_label"):
parts.insert(1, f"Codex:{snapshot['codex_credential_label']}")
if compressions:
parts.append(f"🗜️ {compressions}")
bg_count = snapshot.get("active_background_tasks", 0)
Expand Down Expand Up @@ -3428,9 +3455,16 @@ def _get_status_bar_fragments(self):
frags = [
("class:status-bar", " ⚕ "),
("class:status-bar-strong", snapshot["model_short"]),
]
if snapshot.get("codex_credential_label"):
frags.extend([
("class:status-bar-dim", " · "),
("class:status-bar-strong", f"Codex:{snapshot['codex_credential_label']}"),
])
frags.extend([
("class:status-bar-dim", " · "),
(self._status_bar_context_style(percent), percent_label),
]
])
if compressions:
frags.append(("class:status-bar-dim", " · "))
frags.append((self._compression_count_style(compressions), f"🗜️ {compressions}"))
Expand Down Expand Up @@ -3459,13 +3493,20 @@ def _get_status_bar_fragments(self):
frags = [
("class:status-bar", " ⚕ "),
("class:status-bar-strong", snapshot["model_short"]),
]
if snapshot.get("codex_credential_label"):
frags.extend([
("class:status-bar-dim", " │ "),
("class:status-bar-strong", f"Codex:{snapshot['codex_credential_label']}"),
])
frags.extend([
("class:status-bar-dim", " │ "),
("class:status-bar-dim", context_label),
("class:status-bar-dim", " │ "),
(bar_style, self._build_context_bar(percent)),
("class:status-bar-dim", " "),
(bar_style, percent_label),
]
])
if compressions:
frags.append(("class:status-bar-dim", " │ "))
frags.append((self._compression_count_style(compressions), f"🗜️ {compressions}"))
Expand Down
35 changes: 35 additions & 0 deletions tests/cli/test_cli_status_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,41 @@ def test_build_status_bar_text_for_wide_terminal(self):
assert "$0.06" not in text # cost hidden by default
assert "15m" in text

def test_build_status_bar_text_shows_codex_credential_label(self):
cli_obj = _attach_agent(
_make_cli("gpt-5.1-codex"),
prompt_tokens=10_230,
completion_tokens=2_220,
total_tokens=12_450,
api_calls=7,
context_tokens=12_450,
context_length=200_000,
)
cli_obj.provider = "openai-codex"
cli_obj._provider_source = "pool:personal"

text = cli_obj._build_status_bar_text(width=120)

assert "Codex:personal" in text

def test_build_status_bar_text_truncates_long_codex_credential_label(self):
cli_obj = _attach_agent(
_make_cli("gpt-5.1-codex"),
prompt_tokens=10_230,
completion_tokens=2_220,
total_tokens=12_450,
api_calls=7,
context_tokens=12_450,
context_length=200_000,
)
cli_obj.provider = "openai-codex"
cli_obj._provider_source = "pool:very-long-account-label"

text = cli_obj._build_status_bar_text(width=120)

assert "Codex:very-long-accou..." in text
assert "very-long-account-label" not in text

def test_input_height_counts_wide_characters_using_cell_width(self):
cli_obj = _make_cli()

Expand Down