Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
21a80a6
fix(orchestration): never press Enter on text the person typed into t…
radut Nov 5, 2026
e33cddb
feat(orchestration): deliver mail to Claude terminals as their own tu…
radut Nov 5, 2026
93f751a
fix(orchestration): hold typed delivery five seconds after a keystrok…
radut Nov 5, 2026
176da48
fix(orchestration): settle a pointer whose channel lookup throws, and…
radut Nov 5, 2026
21ccece
fix(orchestration): hand back mail the Claude plugin polled for a ses…
radut Nov 5, 2026
3c93946
fix(orchestration): release mail that never reached the agent, and en…
radut Nov 5, 2026
4e586ba
fix(orchestration): ack polled Claude mail as not submitted when the …
radut Nov 5, 2026
88634b9
Merge remote-tracking branch 'origin/main' into orchestration-pointer…
radut Nov 5, 2026
854558f
Merge remote-tracking branch 'origin/main' into orchestration-pointer…
radut Nov 5, 2026
7c7464e
Merge remote-tracking branch 'origin/main' into orchestration-pointer…
radut Nov 6, 2026
86ec26d
Merge remote-tracking branch 'origin/main' into orchestration-pointer…
radut Nov 6, 2026
e320f39
Merge remote-tracking branch 'origin/main' into HEAD
radut Nov 7, 2026
515d48c
Merge origin/main into orchestration-pointer-typing-race
radut Nov 8, 2026
c25dbc0
Merge origin/main into orchestration-pointer-typing-race
radut Nov 8, 2026
3a6e6aa
Merge remote-tracking branch 'origin/main' into HEAD
radut Nov 9, 2026
0c616fa
fix: follow the hook server and run facts to their new folders
radut Nov 9, 2026
2240a1c
Merge remote-tracking branch 'origin/main' into HEAD
radut Nov 9, 2026
759fc52
Merge remote-tracking branch 'origin/main' into orchestration-pointer…
radut Nov 11, 2026
4d529d4
test(orchestration): drop casts from the parked-pointer and mail-hook…
radut Nov 11, 2026
082b7f0
Merge remote-tracking branch 'origin/main' into HEAD
radut Nov 13, 2026
942dbc1
test(orchestration): build the parked-pointer and typing tests from r…
radut Nov 13, 2026
d1499ce
Merge remote-tracking branch 'origin/main' into HEAD
radut Nov 14, 2026
ad67c08
Merge upstream main 8e693efda41 into orchestration-pointer-typing-race
radut Nov 15, 2026
b426d5e
Merge remote-tracking branch 'origin/main' into orchestration-pointer…
radut Nov 18, 2026
af502ab
Merge upstream main into orchestration-pointer-typing-race
radut Nov 18, 2026
b70717f
Merge remote-tracking branch 'origin/main' into orchestration-pointer…
radut Nov 22, 2026
986dcfd
Merge remote-tracking branch 'origin/main' into fix/orchestration-poi…
radut Nov 22, 2026
9410241
Merge remote-tracking branch 'origin/main' into orchestration-pointer…
radut Nov 23, 2026
56374ab
Merge remote-tracking branch 'origin/main' into fix/orchestration-poi…
radut Nov 23, 2026
88ee049
fix(orchestration): keep runtime-service-state under the line limit
radut Nov 23, 2026
cafb183
Merge orchestration-pointer-typing-race-r7 into orchestration-pointer…
radut Nov 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/runtime/construction/runtime-service-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,12 @@ export abstract class OrcaRuntimeWithStopRequestedPtyIds extends OrcaRuntimeWith
getTerminal: (ptyId) => this.getOrchestrationMailboxTerminal(ptyId),
isAgentSettledForDelivery: (ptyId) => this.checkDeliverySettledAndArmRecheck(ptyId),
isPtyAwaitingUserInput: (ptyId) => this.isPtyAwaitingUserInput(ptyId),
readLastDrivingInputAt: (ptyId) => this.terminalRunFacts.readLastDrivingInputAt(ptyId),
getMessageWaiters: (mailboxHandle) => this.messageWaiters.get(mailboxHandle),
getCliCommand: (terminalHandle) => this.getTerminalOrchestrationCliCommand(terminalHandle),
resolveSubmitTarget: (ptyId) => this.resolveOrchestrationPointerSubmitTarget(ptyId),
isLeafPtyProvenAbsent: (ptyId) => this.isLeafPtyProvenAbsent(ptyId),
redriveMailbox: (mailboxHandle, reservedTypes) =>
this.deliverPendingMessagesForHandle(mailboxHandle, reservedTypes),
redriveMailbox: (handle, types) => this.deliverPendingMessagesForHandle(handle, types),
writePty: (ptyId, data) => this.writeOrchestrationPointerPty(ptyId, data)
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export type PointerDeliveryDependencies<TWaiter extends OrchestrationMessageWait
/** Whether the terminal may take the pointer plus Enter now: at rest, or mid-turn (input queues). */
isAgentSettledForDelivery: (ptyId: string) => boolean
isPtyAwaitingUserInput: (ptyId: string) => boolean
/** When the person last typed into the PTY; Orca's own writes don't count. */
readLastDrivingInputAt?: (ptyId: string) => number | null
getMessageWaiters: (mailboxHandle: string) => ReadonlySet<TWaiter> | undefined
getCliCommand: (terminalHandle: string) => OrchestrationCliCommand
resolveSubmitTarget: (ptyId: string) => OrchestrationMailboxPointerSubmitTarget | null
Expand Down
2 changes: 2 additions & 0 deletions src/main/runtime/orchestration/mailbox-pointer-stage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export function stageOrchestrationMailboxPointer<TWaiter extends OrchestrationMe
args.settle(ptyId, flight)
}
try {
flight.pointerWriteStartedAt = Date.now()
const writeResult = args.deps.writePty(
ptyId,
formatMessagePointer(
Expand Down Expand Up @@ -144,6 +145,7 @@ function finishPointerWriteAndStageEnter<TWaiter extends OrchestrationMessageWai
resolveSubmitTarget: args.deps.resolveSubmitTarget,
isLeafPtyProvenAbsent: args.deps.isLeafPtyProvenAbsent,
isPtyAwaitingUserInput: args.deps.isPtyAwaitingUserInput,
readLastDrivingInputAt: args.deps.readLastDrivingInputAt,
writePty: args.deps.writePty,
settle: args.settle,
redrive: args.redrive
Expand Down
2 changes: 2 additions & 0 deletions src/main/runtime/orchestration/mailbox-pointer-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export type OrchestrationMailboxDeliveryFlight = {
idleObservedWhileDeferred: boolean
/** The incarnation that staged this flight, so retirement can name the rows it owns. */
processIncarnation?: string
/** When the pointer write began: typing after it lands in the same composer line. */
pointerWriteStartedAt?: number
}

/** A mailbox waiting behind a terminal's in-flight pointer, with the types its waiters reserve. */
Expand Down
63 changes: 63 additions & 0 deletions src/main/runtime/orchestration/mailbox-pointer-submit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,69 @@ describe('orchestration mailbox pointer submit', () => {
)
})

it('presses no Enter when the person typed after the pointer was written', async () => {
const db = new OrchestrationDb(':memory:')
const message = db.insertMessage({
runId: 'run_legacy_local',
from: 'a',
to: 'run:run-1',
subject: 'mid-typing'
})
const ptyId = 'pty-typing'
const mailboxHandle = 'run:run-1'
const terminal = {
ptyId,
handle: 'term-typing',
paneKeys: ['tab-1:leaf-1'],
lastAgentStatus: 'idle' as const,
lastAgentStatusObservedLive: true
}
const target = { terminal, processIncarnation: 'inc-typing' }
const reservation = { ptyId, processIncarnation: target.processIncarnation }
const state = new OrchestrationMailboxPointerState()
const flight = state.beginFlight(ptyId)
state.setWatermark(mailboxHandle, 1, ptyId)
expect(db.stageMailboxPointerEnter([message.id], reservation)).toBe(true)
expect(db.markMailboxPointerWriteAttempted([message.id], reservation)).toBe(true)
flight.pointerWriteStartedAt = 1_000
const writePty = vi.fn(settledWriteStub())
const redrive = vi.fn()
const settle = vi.fn(() => state.settleFlight(ptyId, flight))

submitOrchestrationMailboxPointer(
{
mailboxOwner: { resolve: () => mailboxHandle } as never,
state,
getDb: () => db,
resolveSubmitTarget: () => target,
isLeafPtyProvenAbsent: async () => false,
isPtyAwaitingUserInput: () => false,
readLastDrivingInputAt: () => 1_200,
writePty,
settle,
redrive
},
{
mailboxHandle,
messages: [{ id: message.id, type: 'status' }],
newestSequence: 1,
ptyId,
flight,
expectedTarget: target
}
)

await vi.waitFor(() => expect(settle).toHaveBeenCalledOnce())
expect(writePty).not.toHaveBeenCalled()
expect(db.getMessageById(message.id)).toMatchObject({
delivered_at: null,
pointer_enter_pending: 0,
pointer_pty_id: null
})
expect(redrive).toHaveBeenCalledWith(mailboxHandle, true)
db.close()
})

it('holds the Enter while a dialog is open and submits once the agent is idle again', async () => {
const ptyId = 'pty-question'
const mailboxHandle = 'run:run-1'
Expand Down
9 changes: 9 additions & 0 deletions src/main/runtime/orchestration/mailbox-pointer-submit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type PointerSubmitDependencies = {
resolveSubmitTarget: (ptyId: string) => OrchestrationMailboxPointerSubmitTarget | null
isLeafPtyProvenAbsent: (ptyId: string) => Promise<boolean>
isPtyAwaitingUserInput: (ptyId: string) => boolean
readLastDrivingInputAt?: (ptyId: string) => number | null
writePty: (ptyId: string, data: string) => WriteSettlement | Promise<WriteSettlement>
settle: (ptyId: string, flight: OrchestrationMailboxDeliveryFlight) => void
redrive: (mailboxHandle: string, force?: boolean) => void
Expand Down Expand Up @@ -75,8 +76,16 @@ export function submitOrchestrationMailboxPointer(
const sameMailbox =
terminal && deps.mailboxOwner.resolve(terminal, input.mailboxHandle) === input.mailboxHandle
const queueSafe = !!terminal && isMailboxTerminalTakingInput(terminal)
const typedSincePointer =
input.flight.pointerWriteStartedAt !== undefined &&
(deps.readLastDrivingInputAt?.(input.ptyId) ?? -Infinity) >=
input.flight.pointerWriteStartedAt
if (!terminal || !sameMailbox) {
clearAndRedrive = true
} else if (typedSincePointer) {
// The person typed into the line holding the pointer: Enter would send their words with
// it. Release the mail; the redrive is held while their draft stands.
clearAndRedrive = true
} else if (
(terminal.lastAgentStatusObservedLive && terminal.lastAgentStatus === null) ||
deps.isPtyAwaitingUserInput(input.ptyId)
Expand Down
5 changes: 5 additions & 0 deletions src/main/runtime/terminal/wait/terminal-wait-settlements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import { isMailboxTerminalTakingInput } from '../../orchestration/mailbox-owner'
import type { OrcaRuntimeWithResolveWaiter } from '../../orca-runtime-resolve-waiter'

const DIALOG_HOLD_RECHECK_MS = 2000
/** A person typing a few seconds ago may be mid-word in a composer the draft reader can't see. */
const TYPING_PAUSE_HOLD_MS = 2000

export abstract class OrcaRuntimeWithResolveExitWaiters extends OrcaRuntimeWithBindPtyIncarnationHandle {
protected abstract resolveWaiter(
Expand Down Expand Up @@ -150,6 +152,9 @@ export abstract class OrcaRuntimeWithResolveExitWaiters extends OrcaRuntimeWithB
return true
}
const lastInputAt = this.terminalRunFacts.readLastDrivingInputAt(ptyId)
if (lastInputAt !== null && Date.now() - lastInputAt < TYPING_PAUSE_HOLD_MS) {
return true
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
const state = this.readWholeScreenModel(ptyId)
return (
lastInputAt !== null &&
Expand Down