Skip to content

fix(ide): derive saved-document name from operation and fix frozen tab title#3897

Merged
jasonbahl merged 2 commits into
mainfrom
fix/ide-derive-save-title-and-tab-name
Jun 9, 2026
Merged

fix(ide): derive saved-document name from operation and fix frozen tab title#3897
jasonbahl merged 2 commits into
mainfrom
fix/ide-derive-save-title-and-tab-name

Conversation

@jasonbahl

Copy link
Copy Markdown
Collaborator

What & why

Two related fixes to how the IDE derives titles from the GraphQL operation when the Smart Cache saved-documents feature is available.

1. Save dialog prefills the Document Name from the operation

Clicking Save draft on a new draft opened the modal with an empty Document name field. It now prefills from the operation name — the same value the tab shows — so saving query GetPosts { … } opens the modal pre-filled with GetPosts. Anonymous queries ({ posts { … } }) prefill the first field (posts), matching the tab. Empty/unparseable queries leave the field blank so the e.g. Recent Posts by Author placeholder still shows. The name remains editable before saving.

2. Fix the frozen tab title ("G" instead of "GetPosts")

A temp draft could freeze its tab title to the first character of the operation name whenever a body brace already followed the name being typed — an autoclosed {}, or the body typed before the name. The active tab derives its title live from the query only while the stored title is still auto; the autosave hook persisted a derived title synchronously on every keystroke for temp drafts, and deriveStableDocTitle matched on the first character (query G{"G"), flipping the title out of the auto state and stranding the tab at "G".

Temp drafts no longer persist a derived title — they're local-only, the tab already derives live from the query while the title is auto, and the first explicit save sets a real title. The settle-on-debounce title freeze is preserved for real (non-temp) documents, where the 2s debounce guarantees the op name has settled.

Scope note

This fixes new drafts going forward. A draft whose title was already frozen to a single character in a prior session keeps that persisted title until renamed.

Tests

  • Unit (useAutoSave.test.js): a temp draft does not persist a derived title mid-type (the query G{} regression).
  • e2e (tabs.spec.js): the tab title tracks the full op name when a body brace precedes the name — reproduces the exact freeze condition.
  • e2e (save-flow.spec.js): the SaveDialog prefills the Document name from the operation.

All 420 unit tests pass; both new e2e specs pass locally against wp-env (Smart Cache + IDE active).

…b title

Two related fixes to how the IDE derives titles from the GraphQL operation
when Smart Cache saved documents are available.

Save dialog: the first-save "Document name" field was hardcoded empty. It
now prefills from the operation name (matching the tab), e.g. saving
`query GetPosts { ... }` opens the modal pre-filled with "GetPosts".
Empty/unparseable queries leave the field blank so the placeholder shows.

Tab title: a temp draft froze its title to the first character of the op
name (e.g. "G" instead of "GetPosts") whenever a body brace already
followed the name being typed (autoclosed `{}`, or body typed first). The
sticky-title persist ran synchronously per keystroke for temp drafts, and
`deriveStableDocTitle` matched on the first character. Temp drafts no
longer persist a derived title — the tab already derives live from the
query while the title is auto, and the first explicit save sets a real
title. The settle-on-debounce freeze is preserved for real documents.

Tests: useAutoSave unit coverage for the regression, plus e2e coverage for
the tab title tracking the full op name and the SaveDialog name prefill.
@vercel

vercel Bot commented Jun 9, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
wpgraphql-com Ready Ready Preview, Comment Jun 9, 2026 4:51pm

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

▶ Preview in WordPress Playground

Open in WordPress Playground

Boots a fresh WordPress, installs WPGraphQL + this PR's IDE build, lands you at the IDE.

Built from 9ceafd478be08c1886e2b389798df776bdf42eaa. Auto-updates when you push.

Codify the testing policy in the root CLAUDE.md: every reproducible bug
fix ships with a test that fails before the fix and passes after, and we
reach for the broadest user-facing layer that can reproduce the bug first
(e2e / Codeception functional/acceptance/integration) before dropping to a
unit test. Unit tests remain valued, but in addition to — not instead of —
the surface-level test, since the priority is proving the software works
as a whole.
@jasonbahl jasonbahl merged commit d493b52 into main Jun 9, 2026
45 checks passed
@jasonbahl jasonbahl deleted the fix/ide-derive-save-title-and-tab-name branch June 9, 2026 18:28
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.

2 participants