Skip to content

fix(builder): re-enable Preview after patient-column changes - #28

Merged
matthewpeterkort merged 4 commits into
mainfrom
fix/patient-columns-preview-enable
Sep 3, 2026
Merged

matthewpeterkort merged 4 commits into
mainfrom
fix/patient-columns-preview-enable

Conversation

@matthewpeterkort

@matthewpeterkort matthewpeterkort commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Why

Changing a patient column while Preview was in flight left the old preview request loading. The toolbar derives its busy state from that request, so Preview could remain disabled after the column command completed. Stale preview recovery could also resume after the edit and start more work.

Changing the row limit exposed a related overlap bug in the shared mutation hook. Settlement of the aborted preview cleared its single loading boolean while the replacement preview was still active.

Scope

  • Own and abort the active preview request when commands or Explorer selection invalidate it.
  • Use a preview generation to prevent stale responses, errors, and recovery work from mutating current Builder state.
  • Preserve current-preview retry and receipt-recovery behavior.
  • Track concurrent mutation loading by pending request count so older settlements cannot clear a newer request's busy state.
  • Add regression coverage for the original race, deferred catalog recovery, successful re-preview, legitimate disabled states, and overlapping row-limit previews.

Blast Radius

Preview request ownership remains local to Explorer Builder. The shared mutation hook now reports aggregate loading across concurrent calls, which is the intended contract for all mutation consumers. Preview eligibility rules, compile ownership, and command serialization remain intact.

Verification

  • npm test in ui: 19 files passed, 98 tests passed
  • npm run build in ui: production package and demo builds passed
  • Built Loom demo patient-column race: the edit aborted the stale request, Preview re-enabled, and no alert appeared
  • Built Loom demo row-limit race: changing 25 to 50 aborted the first preview, Preview stayed disabled while the replacement ran, then enabled after it completed
  • Sol medium final review: no remaining correctness blocker

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-03T18:43:31.168485Z f742742 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f742742098

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

const executePreview = useCallback(
async (request: PreviewRequest, receiptId: string) => {
const generation = ++previewGeneration.current;
activePreview.current?.abort();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep loading state tied to the replacement preview

When a user changes the row limit while a preview is in flight, the enabled selector calls preview(limit) and reaches this abort immediately before starting the replacement request. The custom useMutation uses one boolean and sets it to false whenever any invocation settles (react.tsx lines 141–146), so the aborted request's asynchronous rejection clears previewStatus.isLoading after the replacement has set it to true. The toolbar therefore becomes enabled while the new preview is still running, recreating the incorrect busy state and allowing additional edits or previews; track loading by request identity/count, or disable limit changes while busy.

Useful? React with 👍 / 👎.

@matthewpeterkort
matthewpeterkort merged commit f6d8ece into main Sep 3, 2026
5 checks passed
@matthewpeterkort
matthewpeterkort deleted the fix/patient-columns-preview-enable branch September 3, 2026 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant