Skip to content
Source
Sign inSign up
pingdotgg/t3code

Add parent/child thread delegation primitives #1779

Closedratulsarna(GitHub profile, opens in a new tab)wants to merge 5 commits intomain fromrefs/pull/1779/headopened View on GitHub

Summary

  • Add parentThreadId as first-class state on threads, enabling one thread to create and link to a child thread within the same project
  • Enforce creation-time invariants: parent must exist, same project, not deleted, not self-referencing (archived parents are valid)
  • Persist and hydrate parentThreadId end-to-end: contracts → decider → projector → SQLite projection → snapshot query → web store
  • Backward-compatible: historical events and snapshots without the field decode to null

Implementation areas

  • Contracts (packages/contracts): OrchestrationThread, ThreadCreateCommand, bootstrap metadata, ThreadCreatedPayload with decode defaults
  • Decider (apps/server): parent validation with requireThreadNotDeleted helper, ?? null normalization for internal callers
  • Projections (apps/server): migration 020, repository/service schema, pipeline, projector, snapshot query
  • Web store (apps/web): Thread and SidebarThreadSummary types, snapshot sync, event handler, sidebar equality check
  • Bootstrap (apps/server): ws.ts dispatch propagates parentThreadId from bootstrap metadata

Validation

  • bun fmt: pass
  • bun lint: pass
  • bun typecheck: pass (7/7 packages)
  • bun run test: pass (61 files, 659 tests)
  • Per-task bugs lane reviews on all 4 implementation tasks
  • Full branch bugs lane final review

Design decisions

  • parentThreadId lives on the child thread only — no childThreadIds mirror, no relationship table
  • Creation-time linking only (v1) — no reparenting, no cycle walks needed
  • Lifecycle is non-cascading — delete/archive/revert do not propagate across the relationship
  • Separate from existing implementationThreadId / sourceProposedPlan (coexist for now)

Note

Add parent/child thread delegation primitives across contracts, store, and persistence

  • Adds parentThreadId: ThreadId | null to the Thread, SidebarThreadSummary, OrchestrationThread, ThreadCreateCommand, and ThreadCreatedPayload types/schemas in orchestration.ts and types.ts, defaulting to null for historical records.
  • Adds a database migration (020_ProjectionThreadsParentThreadId.ts) to add a nullable parent_thread_id column to projection_threads, and updates the repository upsert/select queries accordingly.
  • Enforces parent-child invariants in the thread.create decider: rejects self-parenting, missing/deleted parents, and cross-project parents; adds requireThreadNotDeleted to commandInvariants.ts.
  • Propagates parentThreadId through the full stack: projector, snapshot query, projection pipeline, client store mapping, sidebar summaries, and thread creation bootstrap in the WebSocket layer.
  • Behavioral Change: sidebarThreadSummariesEqual now includes parentThreadId in its equality check, so sidebar updates will trigger whenever parentThreadId changes.
Macroscope summarized add129b.
    1. Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro

      Run ID: 771fd6f7-dd7c-4cfa-84a8-467140f07d8b

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create PR with unit tests

      Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

      ❤️ Share
      Comment `@coderabbitai help` to get the list of available commands and usage tips.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

Sign in to join this conversation.