Skip to content

feat(thread/github): split Submit for review and Publish into separate header actions - #4416

Merged
guitavano merged 3 commits into
mainfrom
guitavano/save-review-publish-flow
Jul 9, 2026
Merged

guitavano merged 3 commits into
mainfrom
guitavano/save-review-publish-flow

Conversation

@guitavano

@guitavano guitavano commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Reworks the sandbox git header so the review/publish actions are two distinct buttons instead of one state-driven "Save changes" button.

  • Primary button always reads Submit for review whenever there is local work (dirty tree or unpushed commits). Opens a dialog with a single Submit for review action (push + open PR).
  • Dedicated green Publish button sits alongside it. Opens the dialog in a new publish-only mode showing a single green Publish to production button. Still gated by isDecoOnlyDiff — code changes stay disabled with the "use Submit for review" tooltip; only .deco/ (CMS) diffs can publish directly.

Each header button now maps to a modal with exactly one action, instead of the old modal that showed Submit + Publish together.

Changes

  • panel-state.ts — dirty-tree and unpushed-with-open-PR states now return Submit for review (create-pr) rather than Save changes (commit-and-push).
  • header-actions.tsx — persistent side Publish button; opens dialog with publish-only intent and passes openPullRequest={null} in that mode so the diff resolves against base/working tree correctly.
  • publish-dialog.tsx — new publish-only intent (single green button); Submit-for-review footer trimmed to just the Submit button; description copy split per mode; show the working-tree diff when there are uncommitted changes so the diff isn't empty for a freshly-edited tree.
  • sandbox-git-api.ts — export hasGitLocalWork for the diff-selection logic.
  • panel-state.test.ts — updated the 6 cases that asserted the old Save changes / commit-and-push behavior.

Testing

  • bun run --cwd=apps/mesh check — passes
  • bun test apps/mesh/src/web/components/thread/github/ — 101 pass / 0 fail
  • bun run fmt + bun run lint — clean (0 errors)

Not exercised end-to-end in the real app (requires an attached GitHub repo + running sandbox).

Notes

The old Save changes machinery (commit-and-push action, isSaveChangesFlow footer branches, handleSaveChanges) is now unreachable but left in place; can be removed in a follow-up cleanup once the new UX is confirmed.

🤖 Generated with Claude Code


Summary by cubic

Split the header into two actions: a primary Submit for review for local work and a green Publish for CMS-only publishes. Publish-only now gates on a combined base…HEAD + working-tree diff, allowing direct publish for .deco/-only payloads (even when mixed) and blocking any code changes.

  • New Features
    • Separate header buttons: primary always shows “Submit for review”; a green “Publish” appears with local work.
    • New publish-only dialog intent with a single “Publish to production”, gated by canPublishDirectly over a combined diff via combinePublishDiffs (allows .deco/-only; blocks any code).
    • Submit-for-review dialog shows a single “Submit for review”.
    • Diff selection: shouldUseBaseDiff shows the working-tree diff when dirty; otherwise uses base…head. Publish-only fetches both and unions them for gating.
    • Panel state: dirty/unpushed-with-open-PR now map to “Submit for review” (create-pr); showPublishSide is owned by panel-state.
    • Helpers/tests: export hasGitLocalWork; add combinePublishDiffs; test hasGitLocalWork, shouldUseBaseDiff, canPublishDirectly, and combinePublishDiffs; remove unreachable “Save changes” flow; update unit tests and labels.

Written for commit 10fc200. Summary will update on new commits.

Review in cubic

guitavano and others added 3 commits July 9, 2026 17:05
…e header actions

Replace the single "Save changes" header button with a two-action model:
the primary button now always reads "Submit for review" whenever there is
local work, and a dedicated green "Publish" button sits alongside it.

- panel-state: dirty tree and unpushed-with-PR states now map to
  "Submit for review" (create-pr) instead of "Save changes" (commit-and-push)
- header-actions: persistent side "Publish" button opens the dialog in a new
  publish-only mode; ignores an existing open PR so the diff resolves
- publish-dialog: add "publish-only" intent (single green "Publish to
  production" button, gated by isDecoOnlyDiff); the Submit-for-review modal
  now shows only the Submit button; show working-tree diff when there are
  uncommitted changes so the diff isn't empty
- sandbox-git-api: export hasGitLocalWork for the diff-selection logic
- update panel-state tests for the new labels/actions

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…ead Save-changes flow

Follow-up to the Submit-for-review / Publish split, addressing review findings:

- fix(security): block direct publish when the branch has BOTH commits ahead of
  base AND uncommitted work. Publish squash-merges base…HEAD plus the working
  tree, but the deco-only gate can only inspect one diff (the daemon has no
  combined base→working-tree diff), so committed code could slip past the gate
  via a deco-only working-tree edit. Now refused with a clear tooltip.
- extract shouldUseBaseDiff() and canPublishDirectly() as pure helpers in
  sandbox-git-api.ts and unit-test them (+ hasGitLocalWork); the safety-critical
  gate logic is no longer inlined in the component
- remove the now-unreachable "Save changes" flow: commit-and-push action, the
  "publish" dialog intent, handleSaveChanges, isSaveChangesFlow branches, and
  the related state — every producer now emits create-pr
- move showPublishSide into the panel-state descriptor (single source of truth
  for header state) instead of re-deriving it in header-actions; assert it in
  panel-state tests
- collapse duplicated description copy, drop the vestigial flex wrapper and the
  always-false isSubmittingForReview prop on the lone PublishButton
- refresh stale "Save changes" comments/doc-strings and the side-button tooltip

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…combined diff

Replace the blanket "commit your changes first" block (mixed committed +
uncommitted work) with a combined-diff gate. In publish-only mode the dialog
now fetches BOTH the base…head committed diff and the working-tree diff and
shows/gates their union — the full payload a direct publish squash-merges.

- deco commit + uncommitted deco edit now publishes directly (was wrongly
  blocked), since the whole payload is deco-only
- code anywhere in the payload (committed or uncommitted) is still blocked with
  the normal "use Submit for review" message — the gate sees committed code
  even when the working tree is deco-only, so the security hole stays closed
- add combinePublishDiffs() pure helper; simplify canPublishDirectly() to gate
  the full payload; drop PUBLISH_MIXED_WORK_TOOLTIP; update unit tests

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@guitavano
guitavano merged commit dee7a16 into main Jul 9, 2026
14 checks passed
@guitavano
guitavano deleted the guitavano/save-review-publish-flow branch July 9, 2026 21:06
decocms Bot pushed a commit that referenced this pull request Jul 9, 2026
PR: #4416 feat(thread/github): split Submit for review and Publish into separate header actions
Bump type: minor

- decocms (apps/mesh/package.json): 3.115.1 -> 3.116.0

Deploy-Scope: web
tlgimenes pushed a commit that referenced this pull request Jul 16, 2026
…TS.md (#4475)

Mined ~300 merged PRs for the delta between the first PR proposal and the
work added before merge. The dominant shape: a first draft ships the happy
path, then a hardening pass (often a different engineer who takes over the
branch and merges — the vibecoder→engineer handoff) adds the same categories
every time. Encoded those 9 categories as an actionable first-pass checklist,
each citing a real PR (#4008, #4230, #4365, #4409, #4426, #4445, #4357, #4355,
#4449, #4350, #4373, #4416, #4446, #4461, #4134, #4469).

Covers: variant/edge-case handling, tenant/permission scoping, concurrency &
silent-data-loss, test-per-fix + invert-bug-tests + real-PG, dead-code/knip,
lifecycle symmetry + state reset, kill-switch/GC/git-exclude for risky infra,
input validation vs over-engineering, compile-time type-safety.

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
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