fix(provider): port upstream git and session management fixes#61
Merged
Conversation
Co-authored-by: Julius Marminge <julius0216@outlook.com> Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: Heinz Gericke <115458264+heinzgericke@users.noreply.github.com>
…ingdotgg#1995) Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: Julius Marminge <julius0216@outlook.com>
…compacting field - Cast task_progress / task_notification message.usage at the normalizeClaudeTokenUsage call sites. Upstream pingdotgg#1943 tightened the parameter to NonNullableUsage | undefined on SDK 0.2.77 where task_*.usage was loosely typed; SDK 0.2.111 strictly types it as { total_tokens, tool_uses, duration_ms }. Runtime logic already guards each field with typeof checks, so the cast is safe. - Add compacting: false to ProviderCommandReactor.test.ts session fixture. MarCode's OrchestrationSession requires compacting, but the upstream pingdotgg#1938 test block doesn't set it.
The upstream pingdotgg#1995 test used the t3code/ temporary worktree prefix; MarCode's isTemporaryWorktreeBranch only recognizes marcode/, so the test would fail on our prefix without this adjustment.
…derivation Approval / user-input notifications worked, but the turn-end branch of deriveTurnNotificationTriggers was gated on a single brittle check (thread.session?.orchestrationStatus !== "running"), which silently drops the trigger whenever the stored session has already moved off of "running" by the time the completion event is derived. Two real-world scenarios hit this: - Replay / reconnect: a single batch carries both the turn.started (running) and turn.completed (ready) events. getThread reflects the pre-batch state (often "stopped" or "ready"), so the completion notification is dropped. - Out-of-band session writes: snapshot syncs or other paths that land a fresh session ahead of the derivation can race the notification check. Widen the "was running" signal to also accept an in-batch transition to "running", a tracked activeTurnId, or a latestTurn still marked "running". The original orchestrationStatus check is preserved as the primary path. Tests cover all three additional cases plus a negative regression for threads that never ran.
The prior widened session-set check still missed turn-end notifications in practice. The session-set signal is apparently unreliable in the user's environment — possibly lost to subscription races, snapshot overwrites, or missed batches. Add thread.turn-diff-completed as a fallback completion signal. This event is dispatched by CheckpointReactor strictly in response to an actual turn.completed runtime event, so its presence is a strong guarantee that a turn ended. It is already in the thread-detail subscription stream and flows through the same applyRecoveredEventBatch path. Deduplication: a completion fired via the primary session-set path in the same batch marks the thread in completionFiredThreadIds, preventing the turn-diff-completed branch from firing a second notification for the same turn. Both paths honor the 5-second user-stop suppression window and the in-batch userInitiated guard. Tests cover: fallback firing when session-set is absent, dedup when both signals arrive together, and suppression respect on the fallback path. Also renames the in-batch running-transition tracker to make its intent clearer in the guarded-completion branch.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
isTemporaryWorktreeBranch,WORKTREE_BRANCH_PREFIX) to@marcode/shared/gitfor cross-module usemarcode/prefix in resolveLiveThreadBranchUpdateTesting
bun run testpasses in all packagesbun fmt,bun lint,bun typecheckall pass