Skip to content

refactor(daemon): move session helper fns to sessionState.ts - #126

Merged
rgao-coreweave merged 3 commits into
mainfrom
109-05-session-helpers
Jul 17, 2026
Merged

refactor(daemon): move session helper fns to sessionState.ts#126
rgao-coreweave merged 3 commits into
mainfrom
109-05-session-helpers

Conversation

@rgao-coreweave

@rgao-coreweave rgao-coreweave commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Verbatim move of the session-scoped code out of daemon.ts. No behavior change.

  • This PR's commit: the pure helpers (hashPrompt, computeSubagentTranscriptPath, extractUserMessageContent, lastAssistantTextEndsWith, readSubagentFirstLineWithRetry).
  • Also contains refactor(daemon): move session types + tracking to sessionState.ts #127 (merged into this branch): SessionState, the tracker types, SubagentTracking, newSessionState, resolvePermissionIfPending, and the utils.sha256Hex dedup.

Together these make #128's daemon diff stay on the pipeline swap, and its sessionState.ts diff read as a type swap rather than a new file.

Test plan: npm run check

🤖 Generated with Claude Code

rgao-coreweave commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

@drtangible drtangible left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

rgao-coreweave and others added 3 commits July 17, 2026 13:38
Cast the socket JSON once against the SDK's HookInput and dispatch on the
discriminant, so handlers take typed inputs instead of re-casting every
field (~40 payload[...] as X casts deleted). Fields the SDK types as
required drop their invented fallbacks ('unknown'/'teammate'/'?'); the two
payloads that carry more than the SDK declares (PreCompact summary/counts,
reconstruction source/model) keep documented raw-record reads.

Behavior notes: PostToolUseFailure now trusts the typed `error` field
(drops the undocumented tool_response fallback), and InstructionsLoaded
drops its missing-file_path branch (the type requires it; a bad path still
lands in the unreadable-file catch).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Verbatim move of the session-scoped pure helpers (hashPrompt,
computeSubagentTranscriptPath, extractUserMessageContent,
lastAssistantTextEndsWith, readSubagentFirstLineWithRetry) out of
daemon.ts. No behavior change; shrinks daemon.ts ahead of the SDK
migration so its diff stays on the pipeline.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
)

Verbatim move of SessionState, the tracker types (PendingToolCall,
SubagentTracker, TeamMember, LoadedInstruction), SubagentTracking,
newSessionState, and resolvePermissionIfPending. Also dedupes the
sha256-hex idiom into utils.sha256Hex now that it has two consumers
(hashPrompt + the config fingerprint). No behavior change.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>

rgao-coreweave commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

Merge activity

  • Jul 17, 8:46 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Jul 17, 8:47 PM UTC: Graphite couldn't merge this PR because it failed for an unknown reason (Your organization has enabled SAML SSO. Please re-authorize the Graphite App to access this repository.).

@rgao-coreweave
rgao-coreweave changed the base branch from 109-04-typed-hooks to graphite-base/126 July 17, 2026 20:46
@rgao-coreweave
rgao-coreweave changed the base branch from graphite-base/126 to main July 17, 2026 20:46
@rgao-coreweave
rgao-coreweave merged commit cee8265 into main Jul 17, 2026
6 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 17, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants