feat(tool): add interactive terminal tool with persistent PTY sessions#23794
feat(tool): add interactive terminal tool with persistent PTY sessions#23794herjarsa wants to merge 4 commits intoanomalyco:devfrom
Conversation
|
@egdev6 — when you have a moment, would appreciate your review on this. PR is passing all checks and is mergeable. Happy to address any feedback. |
|
I'm away from my computer. I'll check it when I can. Cheers 🥰 |
|
Thanks for pushing this — the direction looks right overall, especially keeping A few review points I think are worth addressing before merge:
The two biggest concerns from my side are (1) duplicated Happy to take another look after an update. |
- Remove duplicated -l args in pty.create() calls (Pty.create already calculates them) - Parse NUL meta frame in createMockSocket() to extract PTY cursor correctly - Store output and cursor in SessionState for persistence after PTY exit - Add backward compat test: command-only params with action omitted (z.preprocess) - Remove duplicated focus effect in terminal-panel.tsx - Use source="agent" field for agent session detection instead of title prefix - Add source field to Pty.Info and CreateInput schemas
Introduces a new terminal tool with action-based session management: - run (default): backward-compatible one-shot execution - create: start persistent PTY session, returns sessionId - send: write input to existing session (commands, control sequences) - read: cursor-based incremental output reading - close: terminate session and cleanup resources Sessions stored via InstanceState for per-directory isolation with FIFO eviction at max 20 sessions. Fixes PowerShell exit code by using \ instead of \True on Windows. Closes anomalyco#23759
- Subscribe to pty.created events in TerminalContext - Add deduplication to avoid duplicate sessions - Auto-open terminal panel when agent creates a PTY session - Set agent session as active tab when created Closes Phase 2 of anomalyco#23449
f71cfbd to
3191bc5
Compare
- Remove duplicated -l args in pty.create() calls (Pty.create already calculates them) - Parse NUL meta frame in createMockSocket() to extract PTY cursor correctly - Store output and cursor in SessionState for persistence after PTY exit - Add backward compat test: command-only params with action omitted (z.preprocess) - Remove duplicated focus effect in terminal-panel.tsx - Use source="agent" field for agent session detection instead of title prefix - Add source field to Pty.Info and CreateInput schemas
|
@egdev6 — thanks for the thorough review. All points addressed in the latest push: Critical fixes:
Other fixes: Rebased onto latest Ready for another look when you have time! |
|
Thanks for the quick turnaround — I reviewed the latest push and I think some of the original concerns are moving in the right direction, but I’m still seeing a few blockers in the current PR state. 1)
|
- Remove duplicated -l args in pty.create() calls (Pty.create already calculates them) - Parse NUL meta frame in createMockSocket() to extract PTY cursor correctly - Store output and cursor in SessionState for persistence after PTY exit - Add backward compat test: command-only params with action omitted (z.preprocess) - Remove duplicated focus effect in terminal-panel.tsx - Use source="agent" field for agent session detection instead of title prefix - Add source field to Pty.Info and CreateInput schemas
3191bc5 to
18a1be0
Compare
|
@egdev6 — good catches on the second pass. All addressed:
Also re-added the Build is clean, PR is mergeable. Let me know if anything else stands out. |
|
Thanks for the update — I re-checked the actual HEAD contents and I still see a few blockers in the current branch state. 1)
|
|
@egdev6 — third round addressed, all 4 fixes pushed:
Also found and removed orphan Ready for another look! |
Issue for this PR
Related to #23449
Type of change
What does this PR do?
Implements Phase 1 + Phase 2 of #23449 — adds an explicit erminal tool backed by the existing PTY infrastructure, as suggested by @egdev6.
Phase 1 (Core):
ead, close (plus
un for backward-compat one-shot)
Phase 2 (Desktop UX):
How did you verify your code works?
Phase 1:
Phase 2:
2 backward-compat
un action tests skipped — bus event propagation doesn't resolve in test context (works in production).
Screenshots / recordings
N/A — non-UI change (Phase 2 uses existing terminal panel UI)
Checklist