fix(adapters): pipe psmux pane logs through a positional sidecar sink#218
Conversation
…bmad-code-org#217) psmux pipe-pane strips every dash-flag token from the piped command, so the pwsh -EncodedCommand sink died on spawn; and the CopyTo sink parked bytes in a 4 KB buffer with unreliable pipe EOF, so run logs stayed empty. Write the sink source to a sidecar <log>.sink.ps1 and invoke it positionally with a chunked read/write loop that flushes per chunk, so the live-tailed log receives pane bytes incrementally and byte-exact.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
Walkthrough
Changespsmux sink capture
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant PsmuxMultiplexer
participant psmux
participant pwsh
participant LogFile
PsmuxMultiplexer->>PsmuxMultiplexer: Write <log>.sink.ps1
PsmuxMultiplexer->>psmux: Start pipe-pane with positional script path
psmux->>pwsh: Launch sidecar script
pwsh->>LogFile: Append and flush pane bytes
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
On psmux 3.3.7
PsmuxMultiplexer.pipe_panealways produced a 0-byte run log, for two stacked reasons (diagnosed in the #185 live smoke, full evidence in #217 and psmux/psmux#482):pipe-panestrips every dash-flag token from the piped command before spawning it, so thepwsh -NoProfile -EncodedCommand <b64>sink died instantly (upstream pipe-pane strips every dash-flag token from the piped command — pwsh -EncodedCommand sinks can never start (3.3.7) psmux/psmux#482);CopyToraw copy parked bytes in the FileStream's internal 4 KB buffer, and pipe EOF is not reliably delivered on psmux — while the run log is live-tailed for activity-based stall detection.Fix (verified end-to-end on 3.3.7)
Write the sink source to a sidecar
<log>.sink.ps1next to the run log and hand psmux a flagless positional command (pwsh "<sidecar>"); the sink runs a chunked read/write loop that flushes per chunk, so pane bytes land incrementally and byte-exact (multibyte UTF-8 included). Sidecar paths containing PowerShell interpolation syntax ($, backtick) are refused up front with the usual best-effort warning, which now also covers the sidecar write itself.Known accepted costs (per #217): the sink loads the user profile (
-NoProfilecannot survive the flag stripping) and a sidecar.ps1lives next to each run log. Known ceilings are named inline inpipe_pane: spaced/$-bearing paths through psmux's re-parse are untested upstream territory, an AllSigned/Restricted execution policy refuses the unsigned.ps1, and an rc-0 spawn race still yields a silent empty log.Testing
tests/test_psmux_backend.py: 24 passed — pins the flagless positional command shape, the per-chunk flush loop, the interpolation-path rejection, and the warn-don't-raise contract for a failed sidecar write.tests/test_multiplexer.py+tests/test_tui_data.py: no regressions.Closes #217
Summary by CodeRabbit
Bug Fixes
Tests