Skip to content

Avoid redundant deep decode in targeted thread detail hydration#2035

Open
r1sk01 wants to merge 1 commit intopingdotgg:mainfrom
r1sk01:fix/remote-thread-history-loading
Open

Avoid redundant deep decode in targeted thread detail hydration#2035
r1sk01 wants to merge 1 commit intopingdotgg:mainfrom
r1sk01:fix/remote-thread-history-loading

Conversation

@r1sk01
Copy link
Copy Markdown

@r1sk01 r1sk01 commented Apr 15, 2026

What Changed

Moves the contract-critical trimmed-string normalisation for targeted thread detail loading into the projection row decoders and removes the final deep OrchestrationThread decode from getThreadDetailById().

Adds a regression test covering targeted thread detail hydration from padded projection rows to confirm the returned thread detail is still normalised.

Why

Remote thread loading was stalling on very large threads because subscribeThread waits for getThreadDetailById() to finish hydrating the full thread before sending the first snapshot, and that path was deep-decoding the entire assembled thread again.

This keeps the fix server-side and narrowly scoped. It preserves the public thread shape while removing redundant work from the hot path that large remote threads hit.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Note

Medium Risk
Changes the decoding/normalization path for getThreadDetailById, which could affect returned thread detail fields if any projection rows contain unexpected whitespace/nulls. Scoped to snapshot-query hydration and covered by a regression test, so risk is moderate.

Overview
Speeds up targeted thread detail hydration by removing the final deep OrchestrationThread decode in ProjectionSnapshotQuery.getThreadDetailById, returning the assembled thread object directly.

Moves contract-level trimming/normalization into the projection row decoders by decoding thread title/branch/worktreePath, activity kind/summary, and session providerName/lastError as TrimmedNonEmptyString (or NullOr), and adds a test ensuring padded DB values are returned normalized.

Reviewed by Cursor Bugbot for commit 05f7106. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Remove redundant deep decode in getThreadDetailById and normalize thread field trimming

  • Adds field-level trimming and non-empty validation to thread row schemas: title via TrimmedNonEmptyString, branch/worktreePath as nullable trimmed strings, and activity.kind/activity.summary/session.providerName/session.lastError trimmed at decode time.
  • Removes the decodeThread step in getThreadDetailById, which previously re-decoded the fully assembled OrchestrationThread object; the method now returns Option.some(thread) directly with a satisfies type assertion.
  • Adds an integration-style test in ProjectionSnapshotQuery.test.ts that seeds rows with whitespace and asserts trimmed output from getThreadDetailById.
  • Behavioral Change: decode errors that previously surfaced as toPersistenceDecodeError at the thread assembly step will no longer occur; validation is now enforced earlier at the row-schema level.

Macroscope summarized 05f7106.

Co-authored-by: OpenAI Codex <codex@openai.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 15, 2026

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: aa10c3fa-1812-42f2-be86-a5d15f738387

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.

@github-actions github-actions bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Apr 15, 2026
@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp bot commented Apr 15, 2026

Approvability

Verdict: Approved

Performance optimization that moves string normalization (trimming) from a final deep decode step to row-level schema transforms, eliminating redundant validation. The change is mechanical with no new behavior, and includes a test verifying the trimming works correctly.

You can customize Macroscope's approvability policy. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant