Repository navigation
Make Argo ec ps a single argocd app list call - #260
Conversation
ec ps on the Argo CD backend made one `argocd app list` plus one `argocd app manifests --source live` per service, only to read the live workload's creationTimestamp for the `deployed` column. It now builds every column from the one app list, as argocd-monitor does, so ps and the monitor TUI cost one call however many services there are. Columns now follow argocd-monitor: name, health (replaces ready), sync, version, last sync (status.operationState.finishedAt, replaces deployed) and description. A new --wide option adds properties, the Application's labels minus argocd.argoproj.io/instance and STOPPED. A stopped service shows as "Healthy (Stopped)" and is excluded by --running-only, as before. `ec monitor` shows the same columns. `ec restart` still shows up in last sync: deleting the StatefulSet makes Argo CD's self-heal run a sync operation, which rewrites operationState.finishedAt (checked live on t11-beamline). The K8S backend keeps its two calls and maps onto the new columns: health is Healthy or Degraded from readyReplicas, last sync is the StatefulSet creationTimestamp, sync and properties are empty. Also fix the monitor's sort-column cycling, which stopped at the fourth column. Closes #256 Co-Authored-By: Claude Opus 5 <[email protected]>
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (13)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe service table schema now uses health, sync, last sync, description, version, and properties columns. ChangesService status flow
Priority: ➖ Normal Estimated code review effort: 4 (Complex) | ~45 minutes Change: Feature · Severity of issue fixed: Medium Sequence Diagram(s)sequenceDiagram
participant CLI
participant ArgoCommands
participant ArgoCD
participant Monitor
CLI->>ArgoCommands: request ps with wide option
ArgoCommands->>ArgoCD: fetch application list once
ArgoCD-->>ArgoCommands: return application records
ArgoCommands-->>CLI: return service rows
CLI->>Monitor: pass rows and wide option
Monitor-->>CLI: render status table
Suggested reviewers: Merge Risk: 🟡 Moderate · up to Argo status now uses the application operation timestamp, so ec ps and ec monitor may show stale activity after ec restart if self-healing does not update that field. Verify this behavior or explicitly accept the uncertainty before merging. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Out of Scope Changes checkExplanation [ Resolution Split the shared schema, K8S/Demo mapping, monitor, CLI Full details: Docstring CoverageExplanation Docstring coverage is 20.29% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 69 functions across 11 files. (2 skipped: 2 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
The monitor's IocTable never used ec ps's column selection: it always included properties (no --wide option existed) and stripped description out into an unlabelled DataTable row label instead of a real column, a bug the previous test enshrined as expected behaviour. Now monitor shows name, health, sync, version, last sync, description by default, matching ec ps, and --wide adds properties, matching ec ps --wide. Also left/centre-justify columns and headers to left (matching ec ps's rich Table), mark the sorted column's header with a single ascending arrow (the table only ever sorts ascending), and colour "Healthy (Stopped)" red instead of grey, matching argocd-monitor's separate red "Stopped" badge. Co-Authored-By: Claude Opus 5 <[email protected]>
Add ascending/descending sort direction: the sorted header shows ▲ or ▼, the new 'd' key (or clicking the current sort header) toggles direction, 'o' still cycles columns but always resets to ascending, and direction now survives the monitor's polling refreshes (previously hardcoded to ascending on every refresh). Fix two column-width bugs surfaced while building that: a refreshed cell that grows (e.g. health becoming "Healthy (Stopped)") no longer gets clipped to the old column width (DataTable.update_cell needs update_width=True, which defaults to False); and every header now reserves room for " <arrow>" up front, so a column whose data is no wider than its label (e.g. version) no longer clips the arrow the moment it becomes the sort column. Also override MonitorApp._set_pointer_shape as a no-op: Textual writes its Kitty pointer-shape OSC 22 escape unconditionally on mouse events, and a terminal that doesn't consume it prints the raw escape as text over the Header icon. Since it's a private API, tighten the textual dependency bound to <9 and add a test that pins the method's presence. Co-Authored-By: Claude Opus 5 <[email protected]>
The rightmost column's header showed the raw Unicode glyph
Emoji.exclaim (U+2755) used as its internal id - a symbol some
terminal fonts fall back to rendering as a bare "!", easily mistaken
for a stray/broken column. It's a deliberate busy/action indicator
(update_indicator_threadsafe fills it with a road-works or hourglass
icon while start/stop/restart is queued or running, empty otherwise),
present since before this branch, not new column-selection fallout.
Give it a plain "status" heading instead of the raw glyph, and exclude
it from the sort cycle ('o') and from header-click sorting: it isn't
per-service data, so sorting by it was never meaningful. The sort-cycle
tests now assert every column 'o' visits has a real text header and
that the indicator column keeps its fixed label throughout.
Co-Authored-By: Claude Opus 5 <[email protected]>
…tead Health/sync already make the busy/action indicator column redundant, so drop it entirely: the "!" indicator column (INDICATOR_COLUMN/HEADING), update_indicator_threadsafe and its lock/state, the Emoji enum it was the only consumer of, and the sort-cycle/header-click exclusion that existed only to skip it. In its place, start/stop/restart now trigger an on-demand table refresh once the command returns (0.5s delay), plus a follow-up 3s later since Argo can take a moment longer to reflect the change. Both go through the same refresh path the poll loop uses (IocTable._refresh_once, now shared via refresh_now()), guarded by a lock so an on-demand refresh can't overlap the poll loop or another on-demand refresh. Co-Authored-By: Claude Opus 5 <[email protected]>
…n the new refresh test Assigning a plain function to app.set_timer failed pyright's type check (Timer-returning signature); monkeypatch.setattr avoids the mismatch while testing the same thing. Co-Authored-By: Claude Opus 5 <[email protected]>
…tion refresh to 1s Sorting by a column that's off-screen (o, a header click, or - in principle - d if it ever changes the sort column) now scrolls the table horizontally, only as far as needed, so the column and its arrow are fully visible. Mirrors DataTable's own private column-cursor reveal logic (_get_column_region/_get_fixed_offset + the public scroll_to_region), under the same textual<9 pin that already protects _set_pointer_shape. Never touches the row cursor or vertical scroll. Also: ACTION_REFRESH_DELAY (the first post-action refresh) moves from 0.5s to 1s based on live feedback that 0.5s was too soon; the 3s follow-up is unchanged. Co-Authored-By: Claude Opus 5 <[email protected]>
Closes #256, following the decisions in issuecomment-5775011831 and issuecomment-5775064203. This covers the Argo CD backend only.
What changes
ec pson the Argo CD backend used to make oneargocd app listplus oneargocd app manifests --source livefor each service. The manifest fetch was only there to read the live workload'screationTimestampfor thedeployedcolumn. Now every column comes from the singleargocd app list, as argocd-monitor does.ec psand each refresh ofec monitorcost one call, however many services there are.The columns follow argocd-monitor:
metadata.namestatus.health.status, replacingready.(Stopped)is appended when theSTOPPEDlabel is set, where argocd-monitor shows a Stopped badgestatus.sync.status(new)spec.source.targetRevisionstatus.operationState.finishedAt, replacingdeployed. Empty when there has been no operationepics-containers.github.io/descriptionannotation from #255. Empty when unset-w/--wide. The Application's labels minus argocd-monitor'sHIDDEN_LABELS(argocd.argoproj.io/instance,STOPPED), with theargocd.argoproj.io/prefix stripped--running-onlynow means health is exactlyHealthy, so stopped services are still excluded, as they were withready.ec monitorshows the same columns asec ps:descriptionis a real, sortable column (previously it was shoved into the TextualDataTable's row-label slot and never appeared as a column at all — a pre-existing bug, not something this PR introduced but now fixed alongside it), and the new-w/--wideaddsproperties, matchingec ps --wide. The health and sync cells are coloured, and the logs key is gated onHealthy. This PR also fixes the sort key, which cycled through only the first four columns.Healthywhen a replica is ready andDegradedotherwise, sync is empty, last sync is the StatefulSet'screationTimestamp(the olddeployed), and properties is empty.docs/reference/cli.mddocuments the columns and--widefor bothec psandec monitor.ec monitorfollow-up: columns, colour and sort directionFollow-up commits on this branch fix several
ec monitor-only issues foundwhile dogfooding the
ec pscolumn rework above:ec ps.IocTablenever used theec pscolumn-selection logic — it always included
properties(there was no--wideformonitorat all) and strippeddescriptionout of the columnlist into the
DataTable's row-label slot instead of showing it as acolumn.
ec monitornow showsname, health, sync, version, last sync, descriptionby default, and-w/--wide(mirroringec ps -w) addsproperties.Healthy (Stopped)is now red, not grey, matching argocd-monitor'sseparate red "Stopped" badge next to the health badge.
ec ps's Rich table.header shows
▲(ascending) or▼(descending):ocycles the sort key through the visible columns (in display order,wrapping around, including
description, andpropertiesonly with--wide) and always resets to ascending.dkey toggles the current sort column's direction withoutchanging which column is sorted.
sort column, ascending; clicking the header that's already the sort
column toggles its direction (same as
d).polling refreshes, instead of resetting to ascending on every refresh.
oskippeddescriptionanddropped the arrow entirely for a couple of presses. It didn't reproduce
against this branch's own column fix above —
self.columns(used bothto build headers and to drive the cycle) was already the single,
correctly
--wide-filtered list — but the cycling code has beenrewritten as part of adding direction, so I kept it in mind while doing
so and covered it directly with
test_monitor_sort_cycle_default_columns/
test_monitor_sort_cycle_wide_columns.tests/test_monitor.pycovers each of these: the default and--widecolumn sets, left-justification of headers and cells, the stopped-red
colour, a full
ocycle in both column sets (exactly one arrow, alwaysascending, wrapping back to
name), thedtoggle (arrow flips and roworder reverses), a header click on another column, a header click on the
current column (toggles), and direction surviving a polling refresh.
Two more
ec monitor-only fixes found while poking at the above:IocTable.populate_tablecalled
DataTable.update_cellwithoutupdate_width=True(it defaults toFalse), so a cell that grows on refresh — the running example beinghealthgoing from"Healthy"to"Healthy (Stopped)"when a service isstopped while the monitor is open — got its new text clipped to the old
column width instead of the column resizing, as it would for a freshly
added row. Fixed by passing
update_width=True.test_monitor_column_widens_on_refreshdrives a row from"Healthy"to"Healthy (Stopped)"throughpopulate_table(the same pathdo_pollinguses) and asserts the column's width grew to fit.once, from the header
Textpassed toadd_column(); moving the sort keylater just swaps a column's
labelin place (_apply_sort) withoutrecomputing its width. So a column whose data is no wider than its label —
version's demo data ("1.0.25", 6 chars) is narrower thanversionitself (7 chars) — got its
▲/▼cut off the moment it became the sortcolumn, because the column was never sized for it. Fixed by having every
header reserve
" <arrow>"'s width up front (_SORT_SUFFIX_WIDTH),whether or not it's currently sorted, rather than only recomputing on
demand — simpler, and it also stops columns jumping width as the sort
moves.
test_monitor_sort_arrow_does_not_clip_headersorts byversionin both directions and asserts the column is at least
len("version ▲")/len("version ▼")wide.ec monitor: removed the "!" status column, refresh after actions insteadThe rightmost column was a busy/action indicator that predates this branch
entirely (present already on
main):update_indicator_threadsafefilleda service's cell with a road-works or hourglass icon while
start/stop/restartwas queued or running, and cleared it back toempty once the action finished. Its header was the raw Unicode glyph used
as its internal id,
Emoji.exclaim(U+2755) — some terminal fonts don'thave a glyph for it and fall back to a bare
!, reading as a stray,broken column with no data. An earlier commit on this branch just relabelled
it
"status"and excluded it from sorting; on reflection,healthandsyncalready make it redundant, so it's removed outright instead —INDICATOR_COLUMN/INDICATOR_HEADING,update_indicator_threadsafeandits lock/state, the sort-cycle/header-click exclusion that only existed to
skip it, and the
Emojienum it was the sole consumer of.In its place,
start/stop/restartnow trigger a table refresh once thecommand returns, instead of only ever finding out on the next poll tick
(up to 1s later, and Argo itself can lag a bit longer than that): a first
refresh
ACTION_REFRESH_DELAY(1s — started at 0.5s, moved out after liveuse showed that was too soon) after the command returns, plus a follow-up
ACTION_REFRESH_FOLLOW_UP_DELAY(3s) later in case Argo hasn't caught upyet. Both go through the same refresh path the poll loop already used —
IocTable.do_polling's body is now_refresh_once, shared via the newrefresh_now()— guarded by a lock so an on-demand refresh can't overlapthe poll loop or another on-demand refresh; a refresh already in flight is
skipped, not queued.
test_monitor_sort_cycle_default_columns/_wide_columnsnow assert theocycle visits exactly the visible data columns (no more indicatorexclusion to test).
test_monitor_action_schedules_refreshdrives a realstart action through the confirm dialog and asserts the two refreshes are
scheduled at
ACTION_REFRESH_DELAY/ACTION_REFRESH_FOLLOW_UP_DELAYagainst
refresh_now, independent of the (untouched, still-running) 1spoll timer.
ec monitor: stop leaking]22;textonto the header iconTextual's
App._set_pointer_shape(textual/app.py, private API) writesthe Kitty pointer-shape escape
ESC ] 22 ; <shape> BELunconditionally onmouse events, with no terminal-capability check, right after parking the
cursor at (0, 0) for the frame. A terminal that doesn't consume OSC 22
prints it as literal text over the Header's icon cell instead — e.g.
clicking anywhere in the table left
]22;textstuck top-left, neverrepainted because that cell's content doesn't otherwise change.
MonitorAppnow overrides_set_pointer_shapeto a no-op. Since it's aprivate API,
pyproject.toml'stextualbound is now>=7.4,<9(was>=7.4) so a future Textual major can't silently change or drop the methodunder the override;
uv.lockis updated to match (still resolving 7.4.0,no dependency bump).
test_monitor_pointer_shape_override_point_existsasserts
Appstill has_set_pointer_shape, so a rename fails the testsuite instead of silently reintroducing the leak.
test_monitor_click_does_not_leak_osc22spies on the test driver'swrite, drives a real click throughPilot, and asserts nothingcontaining
\x1b]22;was ever written; run against the code without theoverride, the same test does see the escape sequence.
ec monitor: scroll a newly-sorted column into viewSorting is
--wide-able and now direction-aware (see above), but a narrowterminal can still leave the new sort column - and its
▲/▼arrow -off-screen: the table never auto-scrolled to it, so cycling
opast thevisible width silently sorted by a column you couldn't see. Now, whenever
a column becomes the sort column (
o, a header click, ordin the casethan just the direction), the table scrolls horizontally, only as far as
needed, so the whole column including its header is visible. Never moves
the row cursor or the vertical scroll.
DataTablehas no public "scroll to column" API.IocTable._apply_sortnow calls the new
_scroll_sort_column_into_view, which mirrors whatDataTable's own (private)_scroll_cursor_into_viewdoes for a"column"-type cursor: build the sort column's region from
_get_column_region/_get_fixed_offsetand hand it to the publicscroll_to_region, which only scrolls if the region isn't already fullyvisible - so a
dpress, or ano/click landing on an already-visiblecolumn, is a no-op. This is the same private surface
_set_pointer_shapeabove already relies on, protected by the same
textual<9pin.test_monitor_sort_scrolls_offscreen_column_into_viewruns the app at anarrow 30-column terminal, confirms
versionstarts off-screen, cyclesoto it, and assertsscroll_xmoved and the column's region is nowfully inside the viewport - while the row cursor and
scroll_yareunchanged.
test_monitor_sort_does_not_scroll_when_column_already_visibleruns at the normal 80-column width (every other test's default, where all
columns already fit) and asserts a full
ocycle plus adpress nevermoves
scroll_x.Does
ec restartstill show inlast sync? Yes, tested liveec restartrunsargocd app delete-resource --kind StatefulSet --all. The olddeployedcolumn only caught it through the live StatefulSet'screationTimestamp. To checklast sync, I deleted one StatefulSet on t11-beamline (argus) the same way (kubectl delete statefulset bl11t-ea-test-01, 2026-09-22T11:02:12Z) and watched the Application:status.operationState.finishedAt2026-09-22T09:03:19Z2026-09-22T11:02:13ZinitiatedBy.automated: true,autoHealAttemptsCount: 1,resources: [apps/StatefulSet bl11t-ea-test-01]status.historydeployedAt 2026-09-22T11:02:13Z2026-09-21T14:11:59Z2026-09-22T11:02:13Z(new uid)bl11t-ea-test-01-02026-09-21T14:11:59Z2026-09-22T11:02:18ZArgo CD's self-heal recreates the StatefulSet with a sync operation, and that operation rewrites
operationState.finishedAt. So a restart does show inlast sync.ec restartdepends on self-heal anyway: without it the StatefulSet would never come back.Two other cases:
finishedAtnor the olddeployed, so nothing is lost there.status.reconciledAt. It changes every few minutes for every app, so it can't stand in for "last activity".Evidence
tests/test_argocd.py::test_ps_makes_one_argocd_call[1|5|50]asserts that the argocd calls are exactlyargocd app get <target>(the target check everyeccommand makes) and oneargocd app list. The mocked shell fails the test on any further call.test_ps,test_ps_wideandtest_ps_running_onlycheck exact tables. The fixture covers an umbrella app (skipped), a stopped service, labels, an app with no operation yet, and OutOfSync/Progressing. Rich's console width is set explicitly (COLUMNS=200) instead of matching ellipses.tests/test_monitor.pyrunsMonitorAppheadless on the demo backend. It checks the column set (default and--wide, no more status column), cell values, left-justification, sort cycling and direction (key presses, header clicks, surviving a refresh), column auto-width on refresh and on a tight sort-arrow header, the stopped-red colour, that no OSC 22 escape reaches the driver, that a real start action schedules the two post-action refreshes at the right delays, and that sorting scrolls an off-screen column into view (narrow terminal) but never scrolls when the column's already visible (normal width).ruff checkandruff format --checkare clean.pyright: 0 errors, 0 warnings. The docs build is clean.argocdCLI, so this rendering feedskubectl get applications -o json(the same objectsargocd app listreturns) throughec ps:bl11t-ea-test-01shows the restart above. Thet11umbrella app is skipped. No t11 Application has labels, so--wideshows an empty properties column there.Upgrade note
ec pscolumnsreadyanddeployedare replaced byhealth,syncandlast sync. Scripts that parseec psoutput need updating.ec monitor's columns now matchec ps:descriptionis a real column shown by default, and the new-w/--wide(mirroringec ps -w) addsproperties. Sorting (o, or a header click) now has a direction, shown as▲/▼; the newdkey (or clicking the current sort column's header) toggles it.ec monitor's "!" busy/action status column is gone; health/sync already covered it.start/stop/restartnow refresh the table 1s and, again, 3s after the command returns instead.ec monitornow scrolls the table horizontally, if needed, to keep a newly-sorted column fully in view.textual's dependency bound tightens from>=7.4to>=7.4,<9, to protect the private-API overrides (pointer-shape suppression, sort-column scroll-into-view) above. No version bump — still resolves to 7.4.0.🤖 Generated with Claude Code