Skip to content

fix(site): hold the save action while a cached permission check refetches - #417

Merged
ibetitsmike merged 3 commits into
mainfrom
mike/issue-413-save-action-cleanups
Nov 22, 2026
Merged

ibetitsmike merged 3 commits into
mainfrom
mike/issue-413-save-action-cleanups

Conversation

@ibetitsmike

Copy link
Copy Markdown
Owner

Coder Agents opened this PR on behalf of @ibetitsmike.

Closes #413.

What and why

The Save workflow dialog added in #411 held its submit only while the organization permission check loaded for the first time. A cached answer that refetches on open counted as resolved, so a grant revoked while the cache looked fresh could still take a submission.

  • useForkWorkflowSave: the hold now follows orgPermissionQuery.isFetching, which covers a first load and a refetch of a cached answer. The prop renames from isPermissionPending to isPermissionChecking because the meaning widened.
  • ForkWorkflowSaveDialog: when the fresh answer denies or fails, effectiveTier settles the submitted tier to personal-only, so a selection made while the answer was in flight does not survive as the submitted tier.
  • Removed hook state no consumer read: saveTarget from the hook return and saved.organizationId.
  • SaveTier is now derived from SavedWorkflowScope["tier"] instead of a re-declared "user" | "organization" union.
  • Corrected the form-adapter comment on formValues (the run does carry phases; they are run state, not the declared list the form wants) and the stale React-Compiler note.

How tested

  • New regression test holds the submit while a cached permission answer refetches in ForkWorkflowRunDetail.test.tsx: seeds a stale cached grant, opens the dialog, asserts the loader and disabled submit while the refetch is in flight and a click sends nothing, resolves the refetch with the grant confirmed, selects Organization, invalidates the query, asserts the submit holds again during the fresh refetch, resolves it with a denial, asserts the radio is gone and the stale selection does not land, re-submits, and asserts only the personal create API was called.
  • Negative control: reverting the hold to the old isPending && !isError expression makes the new test fail (1 failed of 13); restoring isFetching makes all 13 pass.
  • Targeted: pnpm exec vitest run --project unit on ForkWorkflowRunDetail.test.tsx (13/13) and ForkWorkflowTool.test.tsx (24/24). pnpm lint:types (tsc) clean. pnpm exec biome check clean on the three touched files. pnpm format no changes.
  • seedCreatePermission gained an options param with a stale flag that keeps the seeded answer alive but stale (the test client's gcTime: 0 would otherwise evict it before the dialog observes it) and returns the query key.

Pre-commit hook

Pre-commit was opted out in this worktree per the interim rule in #407 (git config --worktree coder.pre-commit false); the hook's own classification would run the site checks this PR already ran by hand:

  • biome check on the three touched files: clean
  • biome format: no changes
  • tsc (pnpm lint:types): clean
  • targeted vitest: 37/37 across the two affected test files

Note on full pnpm lint: it fails at lint:compiler (check-compiler.mjs) on ForkAgentMentionMenu.tsx and ForkHtmlAttachmentViewer.tsx. This is pre-existing on a clean checkout of the parent commit of this branch (verified by stashing and re-checking out), those files and the compiler script are byte-identical to main, and this PR touches neither. All other lint stages pass.

Not exercised

  • No browser or storybook run; the dialog behavior change is covered by the Vitest test only. The existing story CompletedSaveDialogPermissionPending already covers the loader state visually.
  • The full pnpm check suite was not run green because of the pre-existing lint:compiler item above.

…ches

The Save workflow dialog held its submit only while the organization
permission check loaded for the first time. A cached answer that
refetches on open counted as resolved, so a grant revoked while the
cache looked fresh could take a submission.

isPermissionChecking now follows orgPermissionQuery.isFetching, which
covers both a first load and a refetch. When the fresh answer denies or
fails, effectiveTier settles the submitted tier to personal-only, so a
selection made while the answer was in flight does not survive.

Also drops hook state no consumer read (saveTarget and
saved.organizationId) and derives SaveTier from
SavedWorkflowScope["tier"] instead of a re-declared union.

Closes #413.
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-22T00:05:36.692230Z 0af4d87 Manual request
ℹ️ 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: 14126d17f5

ℹ️ 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".

Codex review of 14126d1 flagged that a refetch of a cached denial
held the submit with no loading state, because the loader sat inside the
tier-choice block the cached denial hides. The loader now renders
whenever the permission check is in flight, independent of what the
cached answer shows.
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

@codex review

@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: 3623ba7c95

ℹ️ 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".

@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 0af4d87d9a

ℹ️ 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".

@ibetitsmike
ibetitsmike merged commit 3a54ae8 into main Nov 22, 2026
9 checks passed
@ibetitsmike
ibetitsmike deleted the mike/issue-413-save-action-cleanups branch November 22, 2026 00:18
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

Merged at head 0af4d87d9ac7be29f4af6cdc508fae153dd3093a as 3a54ae8, on main 0287e36ba90beda4f04dfbfabefda092345844b9, with the server running that main.

Gates on this exact head:

  1. The head matched the SHA I verified (--match-head-commit).

  2. Every check run passed. fork-ci run 44964699828 passed on this head.

  3. Codex receipt for this head: fix(site): hold the save action while a cached permission check refetches #417 (comment) ("Didn't find any major issues", Reviewed commit 0af4d87d9a).

  4. No unresolved review thread. Fixed: the loader now shows while a cached denial refetches, the test asserts outcomes instead of only rendered state, the narration comments are gone, and the spies restore in finally. Declined with a reason in each thread: focus kept on the tier radios during a refetch (the loader swap is the site: Save workflow action on the run card #411 design), and the offline paused query (needs mutation-side gating too, and it predates this PR).

  5. 0 commits behind main.

  6. Test evidence I ran in the PR worktree at this head:

    • pnpm exec vitest run --project unit on ForkWorkflowRunDetail.test and components/ForkWorkflows/: 7 files, 68 of 68 passed.
    • Negative control: with the hold set back to the old isPending && !isError, "holds the submit while a cached permission answer refetches" and "shows the checking loader while a cached denial refetches" fail (2 of 14). Reverted, and the worktree was clean afterwards.

    The workstream also ran tsc, biome and format checks, plus an Opus review before the PR. I did not rerun those.

What this changes: the save dialog holds submission while any permission check is in flight, including a refetch of a cached answer. A stale Organization selection falls back to Personal once the choice goes away. It also fixes the form-adapter comment, removes the unused saveTarget and saved.organizationId, and derives SaveTier from SavedWorkflowScope["tier"].

Not exercised: a live server and browser session. Everything above is unit tests.

Pre-commit hook: the workstream used the worktree-only opt-out from #407 and ran the targeted checks above.

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.

Workflows save action: cleanups from #411 review

1 participant