Skip to content

feat(expose): add pane output taps#371

Merged
TraderSamwise merged 6 commits into
masterfrom
feat/expose-pipe-pane-taps
Jul 21, 2026
Merged

feat(expose): add pane output taps#371
TraderSamwise merged 6 commits into
masterfrom
feat/expose-pipe-pane-taps

Conversation

@TraderSamwise

@TraderSamwise TraderSamwise commented Jul 20, 2026

Copy link
Copy Markdown
Owner

Summary

  • add tmux runtime helpers for starting/stopping pane pipes and quoting file sinks
  • add a demand-driven Exposé pane output tap manager with bounded per-window tap files
  • wire the project service to start/track/stop taps only for switchable-agent preview demand

Verification

  • yarn vitest run src/tmux/runtime-manager.test.ts src/expose-pane-output-tap.test.ts src/metadata-server.test.ts
  • yarn typecheck
  • yarn lint
  • yarn build
  • yarn test
  • pre-push verify: yarn typecheck && yarn lint && yarn test

Summary by CodeRabbit

  • New Features
    • Added live pane-output “tap” capture to provide agent preview output when warm cache isn’t available.
    • Integrated tap-backed previews into the metadata server switchable-agents flow.
    • Preview snapshots now support bounded retention, size-limited reads, and automatic log maintenance/compaction.
  • Bug Fixes
    • Avoids repiping when a pane is already piped and improves handling for ownership changes, pending starts, and restarts.
  • Tests
    • Added comprehensive coverage for tap lifecycle scenarios and tmux pane piping command/quoting behavior.

@vercel

vercel Bot commented Jul 20, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
app Ready Ready Preview, Comment Jul 21, 2026 2:53am

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 57fc204d-a2c5-47ac-ac61-68f63081ff50

📥 Commits

Reviewing files that changed from the base of the PR and between 02c322a and 6fc0149.

📒 Files selected for processing (2)
  • src/expose-pane-output-tap.test.ts
  • src/expose-pane-output-tap.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/expose-pane-output-tap.ts
  • src/expose-pane-output-tap.test.ts

📝 Walkthrough

Walkthrough

Adds tmux pane-piping helpers, a bounded pane-output tap with ownership-aware expiration cleanup, and MetadataServer integration that tracks switchable-agent output alongside preview caching.

Changes

Pane output tap

Layer / File(s) Summary
Tmux pane piping primitives
src/tmux/runtime-manager.ts, src/tmux/runtime-manager.test.ts
Adds pane pipe start, stop, detection, and file-targeting methods with shell quoting, ownership tokens, and command tests.
Temporary pane-output capture
src/expose-pane-output-tap.ts, src/expose-pane-output-tap.test.ts
Tracks pane targets, captures output into hashed files, adopts owned taps, expires and removes taps, bounds reads, compacts files, and returns tap snapshots.
MetadataServer tap lifecycle wiring
src/metadata-server.ts, src/metadata-server.test.ts
Adds optional tap configuration, starts and stops the tap with the server, tracks switchable-agent items, and falls back to tap previews when cached previews are unavailable.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant SwitchableAgentsControl
  participant MetadataServer
  participant ExposePaneOutputTap
  participant TmuxRuntimeManager
  participant TapFile
  SwitchableAgentsControl->>MetadataServer: request items with includePreview
  MetadataServer->>ExposePaneOutputTap: trackItems(items)
  ExposePaneOutputTap->>TmuxRuntimeManager: pipeTargetToFile(target, filePath, ownership)
  TmuxRuntimeManager->>TapFile: append pane output
  ExposePaneOutputTap-->>MetadataServer: read bounded tap snapshot
  MetadataServer-->>SwitchableAgentsControl: return previewSnapshot
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding pane output taps for the expose feature.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/expose-pipe-pane-taps

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/expose-pane-output-tap.ts`:
- Around line 118-143: Update startTracked and stopTracked to track and verify
ownership of the pane pipe rather than assuming attachment succeeded or remains
unchanged. Make pipe acquisition report a verifiable ownership token atomically,
persist it with the tracked target, and have stopTracked call stopPanePipe only
when that token still identifies this manager’s pipe; otherwise remove only this
manager’s file and leave other consumers’ pipes untouched.

In `@src/metadata-server.ts`:
- Around line 2654-2660: Update the item serialization flow in the
includePreview block to read the captured output via exposePaneOutputTap.read
for each target window, then merge that tap snapshot into the preview payload,
using it as a fallback when exposePreviewCache.get returns no snapshot. Ensure
serializeFastControlItem receives the combined preview data so the captured tap
output is included in the Exposé response.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 59cc0839-cc11-4a19-b0df-afa5c889bd9d

📥 Commits

Reviewing files that changed from the base of the PR and between 9d6dea7 and ea3b15d.

📒 Files selected for processing (6)
  • src/expose-pane-output-tap.test.ts
  • src/expose-pane-output-tap.ts
  • src/metadata-server.test.ts
  • src/metadata-server.ts
  • src/tmux/runtime-manager.test.ts
  • src/tmux/runtime-manager.ts

Comment thread src/expose-pane-output-tap.ts
Comment thread src/metadata-server.ts
@TraderSamwise

Copy link
Copy Markdown
Owner Author

Sub-agent review finding resolved in 5e2e22c: active tap files were previously compacted only on read or renewed demand. The tap manager now runs periodic maintenance compaction while demand is live, with focused coverage for compaction without reads.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
src/expose-pane-output-tap.ts (1)

152-155: 🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift

Do not treat the 10 ms token poll as a failed acquisition.

pipe-pane launches the token-writing shell command asynchronously. If it starts after this poll, cleanup runs first, then the child recreates the token/log and begins piping—but no target is tracked. Later demand sees an already-piped pane, so this orphaned pipe never expires and its output is unbounded. Keep provisional ownership until a safe asynchronous confirmation/cleanup path completes, and add delayed-token coverage.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/expose-pane-output-tap.ts` around lines 152 - 155, Update the ownership
handling around waitForOwnershipToken so a single 10 ms poll timeout does not
immediately delete the files or abandon tracking. Retain provisional ownership
and use a safe asynchronous confirmation/cleanup path that handles a token
written shortly after the initial poll, while preserving cleanup for genuine
acquisition failure; add coverage for delayed token creation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@src/expose-pane-output-tap.ts`:
- Around line 152-155: Update the ownership handling around
waitForOwnershipToken so a single 10 ms poll timeout does not immediately delete
the files or abandon tracking. Retain provisional ownership and use a safe
asynchronous confirmation/cleanup path that handles a token written shortly
after the initial poll, while preserving cleanup for genuine acquisition
failure; add coverage for delayed token creation.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 78bb795d-595b-4627-ac04-cbf63bcfadbb

📥 Commits

Reviewing files that changed from the base of the PR and between ea3b15d and 5e2e22c.

📒 Files selected for processing (6)
  • src/expose-pane-output-tap.test.ts
  • src/expose-pane-output-tap.ts
  • src/metadata-server.test.ts
  • src/metadata-server.ts
  • src/tmux/runtime-manager.test.ts
  • src/tmux/runtime-manager.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/metadata-server.test.ts
  • src/metadata-server.ts

@TraderSamwise

Copy link
Copy Markdown
Owner Author

Sub-agent review finding resolved in 34df134: when a pane is already piped, the tap manager now checks the deterministic Aimux token/log files, adopts a live owned tap after service restart, and removes dead tap files without detaching unrelated pipes. Added regression coverage for restart adoption.

@TraderSamwise

Copy link
Copy Markdown
Owner Author

Sub-agent final-round findings resolved in 02c322a: pending starts are now tracked until the ownership token appears or demand expires, so delayed token reporting can be adopted/stopped safely; the metadata route now starts tap demand only for panes missing warm capture snapshots.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/expose-pane-output-tap.ts`:
- Around line 121-126: The pending-start flow around promotePendingStart must
preserve token ownership: require the live ownership token to equal item.token,
and on a mismatch discard only the pending entry without adopting or stopping
the other tap. Update stopTracked to avoid deleting files when a live different
token owns the target, and add a regression test covering a pending start
encountering another live token, verifying it neither stops nor removes that
tap.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 267e5cb4-0d65-4af6-805e-eaea1b09220f

📥 Commits

Reviewing files that changed from the base of the PR and between 34df134 and 02c322a.

📒 Files selected for processing (4)
  • src/expose-pane-output-tap.test.ts
  • src/expose-pane-output-tap.ts
  • src/metadata-server.test.ts
  • src/metadata-server.ts
💤 Files with no reviewable changes (1)
  • src/metadata-server.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/metadata-server.ts
  • src/expose-pane-output-tap.test.ts

Comment thread src/expose-pane-output-tap.ts Outdated
@TraderSamwise

Copy link
Copy Markdown
Owner Author

Resolved final tap-ownership audit findings in 4a60fcc. Tracked tap reads/renewals now re-check live ownership before returning output, so stale log files cannot keep serving frozen previews after the token disappears. Pending starts also keep their original start deadline when ownership never arrives, then stop and retry instead of renewing forever while Exposé remains open.

@TraderSamwise

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@TraderSamwise
TraderSamwise merged commit 7bd5876 into master Jul 21, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant