#648

perf(mux-activity): look up promoted agents' directories in one call (OPS-302) [skip-cr]

Openwiiiimmwants to merge intofrom

Closes OPS-302 — https://linear.app/stealth-company/issue/OPS-302/mux-activity-look-up-promoted-agents-working-directories-in-one-call

[skip-cr]

Summary

Under Herdr and Luvus, a catalogue-promoted agent whose session log has a reader (Claude Code, Codex, OpenCode) asked for its own working directory with a separate call. On macOS each call is its own lsof with a 5-second timeout. Both paths now collect those pids first and make one host::agent_cwds call per poll, as Rex already does.

 herdr poll
-  for pane in panes
-    foreground, detect agent
-    agent_cwds(&[pid])            # one lsof per promoted agent
-    build row
+  for pane in panes
+    foreground, detect agent      # looked[]
+  agent_cwds(&cwd_wanted(looked)) # one call; nothing when empty
+  for pane in looked
+    build row from the shared map

 luvus poll
-  for agent in listed
-    pid; agent_cwds(&[pid])
+  pids = listed.map(pid)
+  agent_cwds(pids where needs_agent_cwd)   # one call
+  for (agent, pid) in listed.zip(pids)

The per-row text is unchanged. A pid missing from the map shows agent cwd was not acquired, an unreadable directory shows agent cwd: …, and a missing pid still says "agent process not found".

Evidence

  • Before: herdr.rs and luvus.rs each called agent_cwds(&[pid]) inside their per-agent loop.
  • After: grep -rn "agent_cwds(&\[" widgets/src core/src finds nothing.
  • New tests:
    • herdr::one_poll_asks_once_for_every_promoted_agent_whose_log_needs_its_directory: only log readers with a pid are asked about, each once, sorted; the result is empty when no row needs one.
    • herdr::a_promoted_agent_left_out_of_the_lookup_still_says_why: the per-row text is unchanged.
    • luvus::only_a_promoted_log_reader_with_no_session_id_needs_the_agents_directory.
  • Gates: cargo test -p opscope-widgets --bin mux-activity passes 212 of 212, and widgets/tests/check.rs passes 73 of 73.

Merge Danger

Door: two-way

A refactor of when the lookup happens, not what it returns. The same map feeds the same per-row code.

Blast Radius: mux-activity

Only Herdr and Luvus rows that the catalogue promoted, for log-reading agents. Rex is untouched. On Linux each lookup was already a cheap /proc read, so the gain is on macOS.

🤖 Generated with Claude Code

https://claude.ai/code/session_01WLYpDk8aCsupvsMK7YCY3p

Activity

4
coderabbitai[bot]10d ago

IMPORTANT

Review skipped

Ignore keyword(s) in the title.

:no_entry: Ignored keywords: 3

  • skip-ci
  • skip-review
  • skip-cr

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ab64b8b3-88e9-4adc-a00a-47b770a1952e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
chatgpt-codex-connector[bot]10d ago
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

ReviewStatusCommitReview trigger
📝 Code Review✅ Completed 2026-11-18T16:30:33.186251Z59f4b97PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.