Skip to content

fix(platform): keep a later skill draft when a dismissed save lands - #4299

Merged
yannickmonney merged 1 commit into
mainfrom
fix/skill-create-stale-completion
Oct 4, 2026
Merged

yannickmonney merged 1 commit into
mainfrom
fix/skill-create-stale-completion

Conversation

@yannickmonney

Copy link
Copy Markdown
Contributor

What changed

  • Root cause. Cancel and Escape both stay usable while a blank skill's save is pending. Closing the dialog unmounts SkillCreatePane, but its submit still awaits mutateAsync, then calls onCreated. SkillsSettings then switched pane to the saved skill's detail unconditionally. If the member had opened a second Blank skill draft in the meantime, that dialog was unmounted and the draft lost. An upload that lands after its dialog closed did the same: SkillUploadPane aborts only the storage POST on unmount, so the intent and persist steps still reach onUploaded.

  • Fix (skills-settings.tsx). The settings page opens a saved skill only while the dialog that saved it is still the open pane. Each opening creates a new pane object, and a functional setPane checks it (current === from). A save that lands after its dialog was dismissed now:

    • still fires its success toast,
    • still refreshes the library (useSaveSkill's onSuccess is a mutation-level option in useBackendAction, so it runs after unmount),
    • opens nothing: it no longer replaces a later draft or another skill's detail, and no dialog pops up when none is open.

    An ordinary create or upload still opens the saved skill.

  • Disjoint from fix(platform): guard blank skill creation against overwrite #4255. skill-create-pane.tsx is untouched. The branch merges cleanly with fix(platform): guard blank skill creation against overwrite #4255 and fix(skills): protect stale edits with entity tags #4192, and the new tests also pass against fix(platform): guard blank skill creation against overwrite #4255's create pane (createOnly: true).

  • Register. One row in tests/manual/reference/automation.md, next to the other skills rows (mid-table, so it composes with the open register PRs).

Tests

New file app/features/skills/components/skills-settings.dismissed-save.test.tsx. It renders the actual SkillsSettings, SkillCreateDialog and SkillCreatePane, with the save held on a deferred promise. The detail dialog is a stub that names the open skill. The upload dialog is a stub that hands back its onUploaded, the callback the real pane's submit holds from the render that started the upload.

Test main (9e8f87f68) this branch
Keeps the next draft open when a dismissed create lands (second-unsaved-draft / Keep this later draft. survive, toast fires, one save) ❌ Skill audit-new detail replaced the draft ✅
Opens nothing when a dismissed create lands with no dialog open ❌ a dialog appeared ✅
Keeps another skill open when a dismissed upload lands ❌ house-voice detail replaced ✅
Control: Cancel before Create saves nothing and reopens empty ✅ ✅
Control: create landing with its dialog open opens audit-new ✅ ✅
Control: upload landing with its dialog open opens the uploaded skill ✅ ✅

Mutant "never open the saved skill": the two live-landing controls fail, so the controls do discriminate.

Verification (local, light only: jsdom, Node v24.21.0, one worker)

  • vitest run --project client on the new file, skills-settings.test.tsx and skill-create-pane.test.tsx at the pushed head: 13/13 pass. The whole app/features/skills client suite: 14 files, 87/87 pass.
  • Negative control: the new file against main's skills-settings.tsx: 3 failed, 3 passed (the table above).
  • oxlint --type-aware --type-check on both changed TS files: clean (a probe confirmed it reports TS errors). oxfmt --check: clean. bun run lint:manual: ok. Commit hooks passed: conflict markers, oxfmt, local opengrep.
  • Not run here: browser, full stack, whole-workspace typecheck. CI runs those.

Left open

  • Cancel still doesn't roll back a write that was already submitted. The issue says it shouldn't, and it doesn't.
  • The detail pane's onDeleted (= onClose) is also a completion callback. It looks unreachable after dismissal, because the modal delete confirmation blocks closing while the delete is pending. It is not guarded here.
  • Other dialogs show the same pattern: a completion callback switches the parent's view (task-modal.tsx onCreated={onOpenTask}, assignee-picker.tsx, webdav-settings.tsx). They were not audited in this PR.

Closes #3659

Cancel or Escape closes the create dialog while its save is still
pending, but the pane's submit still resolved into onCreated, and the
settings page switched to the saved skill's detail unconditionally. A
second Blank skill draft opened meanwhile was unmounted and lost; an
upload landing after its dialog closed did the same to whatever was
open.

The settings page now opens a saved skill only while the dialog that
saved it is still the open pane (each opening is a fresh pane object,
compared in a functional update). A dismissed save still lands: the
success toast fires and useSaveSkill's mutation-level onSuccess
refreshes the library. Nothing changes in skill-create-pane.tsx, so
the fix stays disjoint from #4255.

The regression test drives the actual settings page, create dialog and
pane with a held save. It fails on main for the later draft, the
no-dialog landing and the upload case; the cancel-before-submit and
live-landing controls pass on both.

Closes #3659
@yannickmonney

Copy link
Copy Markdown
Contributor Author

Independent review of PR #4299 at 817692fc0756d2d9ff20deca44bbdf75994b0cac: accepted.

The reviewer is agent #3 4aec6e61, run 39c9f1d6 (TALE-655), routed by the fleet manager (run 2a1bb357, TALE-359 note c3066307). The author is agent #2 3f9fdcee, run e20976f1. The contract is #3659 / TALE-200. The base is main 9e8f87f68, which was still origin/main at 12:51Z. No blocking findings.

The contract, point by point

  1. A late success after Cancel notifies and refreshes the library, but replaces no dialog and discards no later draft.

    • The guard. skills-settings.tsx:86-89 opens the saved skill only while current === from.
      • Every Add-menu setPane({…}) creates a new pane object, so a reopened dialog never matches an old closure.
      • Both panes call the callback from the render that started the save: the create pane's submit, and the upload pane's submit, which is a useCallback with onUploaded in its deps.
      • So from is the dialog that saved. Nothing behind the modal can call setPane, so from stays identical to the open pane for as long as that dialog is open.
    • The toast. The create pane still toasts Skill created before onCreated (skill-create-pane.tsx:103-104, unchanged), and the regression asserts it.
    • The library refresh.
      • useBackendAction passes useSaveSkill's onSuccess: () => invalidate() to useMutation as a mutation-level option. The saveSkill adapter row has no invalidate of its own.
      • A reviewer probe (not in the PR) runs the real useSaveSkill → useBackendAction → TanStack useMutation → adapter row, with only fetch held. PUT /api/app/skills/audit-new?orgId=org1 is held, the hook unmounts, and the reply then lands. The skills listing configKeys.list('skills','org1') comes back isInvalidated: true.
      • The control: with that onSuccess line deleted, the same probe fails (isInvalidated: false). So the PR's claim holds, and that line is the only refresh.
    • Coverage. SkillsSettings is the only caller of SkillCreateDialog and SkillUploadDialog, so the guard covers every path.
  2. The controls hold on both main and head. Cancel before Create saves nothing and reopens empty. An ordinary create or upload still opens the saved skill.

  3. Composition with fix(platform): guard blank skill creation against overwrite #4255 at c4f113e68 is safe.

  4. The regression fails on main. I ran the head's test file with skills-settings.tsx swapped to 9e8f87f68: 3 failed / 3 passed, exit 1.

    • :152: the Skill audit-new dialog replaced the later draft.
    • :176: a Skill audit-new dialog appeared when no dialog was open.
    • :228: the house-voice detail was replaced.

    The three controls passed. After git checkout -- the worktree was clean, and I ran the head again.

Mutants

Each mutant is a one-line edit to one file, restored afterwards.

Mutant Tests that fail
M1: never open the saved skill (the author's mutant) the 2 live-landing controls (:206, :242)
M2: compare current?.view === from.view the later-draft test (:152)
M3: open whenever any pane is open the later-draft test (:152) and the dismissed upload (:228)
M4: Cancel sends the draft (create pane) the cancel-before-submit control (:189), and the later-draft test

A test pins every branch of the guard, and every control fails under at least one mutant.

Observed runs

All runs used the installed Node v24.21.0, --project client, --maxWorkers=1 and jsdom.

Run Result
Head: new file + skills-settings.test.tsx + skill-create-pane.test.tsx 13/13
Base swap 3 failed / 3 passed
Trial merge with #4255 21/21
Head restored: whole app/features/skills client suite 14 files, 87/87
Probe at head 1/1
Probe with the onSuccess mutant 1 failed

Static checks:

  • oxlint --type-aware --type-check on both changed TS files is clean. The type check is real: a planted openSaved(null, …) gives TS2345 at :366.
  • oxfmt --check is clean.
  • bun run lint:manual reports ok.
  • commitlint on the commit message exits 0.

The register row sits mid-table beside the other skills rows. Its six claims match the six tests one for one, and it names SKILL-F3 and SKILL-F5, whose boxes describe the hand-off to the detail pane.

Not blocking (no change required)

  • Escape isn't exercised. It reaches the same onClose → setPane(null) through Dialog's onOpenChange(false); I checked that by reading the source only.
  • The useSaveSkill mock fixes isPending: false. In the test, Create stays enabled during the held save. That doesn't change the outcome, because the real Cancel is never disabled. No PR test pins the refresh after unmount; the probe above is available if wanted.
  • The upload path is proved through a stub that hands back onUploaded. It matches the real pane: submit's useCallback closes over onUploaded, and useSkillBundleUpload aborts only the storage POST on unmount (use-skill-bundle-upload.ts:35-42), so the intent and persist steps still reach it.
  • The detail pane's onDeleted: I agree with the author's "left open" reading. DeleteDialog refuses to close while deleteSkill.isPending (skill-detail-pane.tsx:356-358). I checked this by reading the source only.
  • The sibling pattern in task-modal.tsx, assignee-picker.tsx and webdav-settings.tsx is outside bug(platform): cancelled skill creation replaces a later draft when its pending save completes #3659. Whether to audit it is the manager's call.

Unrun

  • a real browser or full stack with a slow network
  • a screen reader
  • the visual gate and the manual boxes
  • the whole platform suite and the whole-workspace typecheck
  • SAST and E2E

CI: all five exact-head workflows were queued at 12:51Z: E2E 37201787206, SAST 37201787273, Build 37201787280, Commitlint 37201787296, Checks 37201787353. 226 runs were queued repo-wide. This acceptance doesn't claim green CI and doesn't authorize a merge.

Root's 08:15Z rule (4d56e1f7) applies; no blocking finding is open on this PR. I didn't merge, push or move any card, and I didn't rerun or cancel CI.

Evidence: the logs, mutation-check.sh and the probe are in the TALE-655 delivery box, /agent/output/6e6cdf31-b9d1-4131-8004-09c64a633383/.

@yannickmonney
yannickmonney merged commit 9d52a41 into main Oct 4, 2026
@yannickmonney
yannickmonney deleted the fix/skill-create-stale-completion branch October 4, 2026 17:51
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.

bug(platform): cancelled skill creation replaces a later draft when its pending save completes

1 participant