mirror of
https://github.com/wu736139669/hapi.git
synced 2026-11-18 03:27:08 +00:00
feat(claude): mid-turn Steer for remote Claude sessions (#2259)
* feat(claude): mid-turn Steer for remote Claude sessions Queued messages can now be steered into a running Claude turn, the same as Ctrl+X Ctrl+S in the Claude TUI. The row is written to the live stream-json stdin and Claude folds it in at its next tool boundary. - Spawn Claude with --replay-user-messages and tag every stdin message with a uuid; the echo acks pickup and is never relayed to chat - A result that arrives while a steer is still unacked does not end the turn: Claude runs a follow-up turn for it, so ready waits for that result - Launcher registers steer-queued-message: reserve the row, reject control commands and mode mismatches, ack the hub after the write, mark consumed (steered) on the echo; abort before pickup holds the row indeterminate, an unprompted exit requeues it - Open the shared steer gate and peer/hub wording to Claude (remote only) * fix(claude): retire completed input before a steer follow-up turn - Generalize onCompactResultAccepted to onResultAccepted and fire it when a result arrives with a steer still unacked, so a stream failure during the follow-up turn recovers only the steer instead of replaying the finished prompt - Close the steer target and settle pending steers when query() setup throws, so a retry backoff cannot accept a steer nobody will read
This commit is contained in:
@@ -562,7 +562,7 @@ describe('pingPeer delivery modes', () => {
|
||||
it.each([
|
||||
{ ...active, active: false },
|
||||
{ ...active, thinking: false, agentState: { steeringActive: false } },
|
||||
{ ...active, metadata: { flavor: 'claude' } },
|
||||
{ ...active, metadata: { flavor: 'opencode' } },
|
||||
{ ...active, metadata: { flavor: 'cursor', cursorSessionProtocol: 'stream-json' as const } },
|
||||
{ ...active, metadata: { flavor: 'cursor', cursorSessionId: 'legacy' } },
|
||||
{ ...active, agentState: { controlledByUser: true } }
|
||||
|
||||
@@ -552,7 +552,7 @@ function getSteeringUnavailableReason(session: PingPeerSessionSummary): string |
|
||||
return 'Steering requires an active turn; target is inactive, no message sent. Use queue to resume it'
|
||||
}
|
||||
if (!isSteeringSupportedForSession(session.metadata)) {
|
||||
return 'Steering is only supported for Pi, Codex, and Cursor ACP sessions; no message sent'
|
||||
return 'Steering is only supported for Claude, Pi, Codex, and Cursor ACP sessions; no message sent'
|
||||
}
|
||||
if (session.agentState?.controlledByUser && !session.metadata?.capabilities?.concurrentClients) {
|
||||
return 'Steering is only available for remote sessions; no message sent'
|
||||
|
||||
Reference in New Issue
Block a user