Skip to content

feat: keep state from the pre-split storage layout readable - #512

Draft
0froq wants to merge 3 commits into
devframes:mainfrom
0froq:feat/storage-legacy-import
Draft

0froq wants to merge 3 commits into
devframes:mainfrom
0froq:feat/storage-legacy-import

Conversation

@0froq

@0froq 0froq commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

This description was drafted by an agent from the diff and the commands it ran. froQ has reviewed it.

Description

The Vite DevTools host resolved project and global to the same directory, so project-scope data was machine-wide, and workspace data lived under node_modules where version control never sees it. vitejs/devtools#646 gives each scope its own directory and adds getLegacyStorageDir(scope), which reports where an earlier version kept that scope. This PR makes state written under the old layout reachable from the new one.

Scope Before After
workspace <ws>/node_modules/.vite/devtools <ws>/.vite/devtools
project ~/.vite/devtools <ws>/node_modules/.vite-devtools
global ~/.vite/devtools ~/.vite/devtools

getLegacyStorageDir is not part of DevframeHost, so it is read duck-typed through resolveLegacyStorageDir in devframe/node. Every change below degrades to nothing on a host that reports no legacy path.

Data Inspector wrote private queries from every project on the machine into one file, and a record carries no project field, so the host cannot attribute them. The panel offers an explicit import instead: unclaimed records are listed, the selected ones are claimed into the open project, and claim or discard is recorded in queries.claims.json next to the legacy file, keyed by record id and claiming checkout. The old queries.json is read and never rewritten.

Settings cannot be migrated. Both scopes wrote settings/<ns>.json with per-key last-write-wins, so a key was overwritten and the surviving scope is unknowable. The settings layer reports the namespaces that hold a global file and shows a once-per-machine notice that the scopes are separate now, recorded by a .shared-scope-notice marker in the global settings directory.

The hub's settings.json has no global counterpart, so a checkout without one seeds its initial dock layout once from the legacy file, and writes still go to the project file. The fallback is marked temporary in code and removed in a later release.

Test

Import: no legacy path listed, unclaimed records newest first with the whole-file count, claiming into the current project with the claiming checkout recorded, a claimed record landing beside a same-id workspace query, discard writing nothing to the project store, only unclaimed records left for the next project, and unknown or already-claimed ids ignored.

Notice: which namespaces hold a global settings file, nothing reported before the machine wrote one, the dismissal marker silencing it afterwards, and a host without the capability reporting nothing.

Dock fallback: layout seeded from the legacy file, legacy file ignored once the checkout has its own settings.json, and defaults kept when there is no legacy directory or the file cannot be read.

Manually, with this branch and vitejs/devtools#646 linked in a scratch app, against a seeded ~/.vite/devtools:

Claiming one record and discarding the other left the legacy file untouched and wrote the decisions beside it:

{
  "claims": {
    "old-private-users": { "project": "/…/vitejs-devtools", "at": 1795860759308, "mode": "claim" },
    "old-private-middlewares": { "project": "/…/vitejs-devtools", "at": 1795861203597, "mode": "discard" }
  }
}

Changing one dock category wrote the project file, carrying the layout seeded from ~/.vite/devtools/settings.json, which was left unchanged:

{
  "docksHidden": ["advanced:devframes:plugin:og"],
  "docksCategoriesHidden": ["framework"],
  "docksPinned": ["viteplus"],
  "docksCustomOrder": {},
  "commandShortcuts": {}
}

Screenshots

  1. Data Inspector panel with the "older versions saved private queries" notice above saved queries, including the migrated shared query.
    image

  2. The Import saved queries dialog with two records, one selected.
    image

  3. The saved-queries list after claiming, notice still reporting one unclaimed record.
    image

  4. The same list after discarding, notice gone.
    image

  5. Settings → Advanced with the "settings are now stored per project" notice.
    image

Earlier host versions kept one machine-wide project directory, so every
project's private queries landed in one file and a record carries no project
field. Claiming is explicit and recorded in a sidecar next to the legacy file,
so another checkout is only offered what is still unclaimed.
Project and global settings used to share one file, so the surviving value's
scope is unknowable. Detect any namespace file in the global settings dir,
report it over two built-in RPCs, and record a dismissal marker per machine.
The reference hub UI renders the notice in Settings > Advanced.
A checkout with no settings.json of its own seeds its initial dock layout
from <host.getLegacyStorageDir('project')>/settings.json, so a layout from the
old machine-wide directory survives the storage move. Writes still go to the
project file only. The fallback is temporary and is removed in a later
release.
@vercel

vercel Bot commented Nov 28, 2026

Copy link
Copy Markdown

@0froq is attempting to deploy a commit to the NuxtLabs Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

Copy link
Copy Markdown

👁️‍🗨️ Review this pull request with grouped, summarized diffs at:
👉 https://pulls.review/gh/devframes/devframe/512?from=github-actions[bot]

raw result

💭 analyzed by vercel-ai-gateway/anthropic/claude-sonnet-5
🕰️ 2026-11-28 11:17 UTC
🔗 head 9887bac
🤖 automated by pulls.review

{
  "headSha": "9887bacc066c08dedc3c26e5b25e6d43b3655087",
  "result": {
    "overallSummary": "Vite DevTools now gives `project` and `global` storage scopes separate directories, which leaves state written under the old shared layout stranded. This PR makes that old state reachable through a new optional host capability, `getLegacyStorageDir(scope)` (read via `resolveLegacyStorageDir`), and uses it in three places: Data Inspector offers an explicit claim/discard import for unattributed private queries, the settings layer shows a one-time notice that project and global settings are no longer merged, and the hub seeds its dock layout once from the legacy project file. All three fallbacks are read-only against the legacy data and degrade to no-op on a host that reports nothing.",
    "groups": [
      {
        "key": "data-inspector-legacy-import",
        "label": "Data Inspector legacy import",
        "summary": "Adds an explicit import flow for Data Inspector's saved queries: records left by a pre-split install (one machine-wide file, no project attribution) are listed, and the user claims them into the open project or discards them, with the decision recorded in a sidecar claims file so other projects on the machine aren't offered the same records again.",
        "category": "data",
        "filePaths": [
          "plugins/data-inspector/README.md",
          "plugins/data-inspector/app/App.vue",
          "plugins/data-inspector/app/components/SavedQueriesPanel.vue",
          "plugins/data-inspector/app/composables/legacy-queries.ts",
          "plugins/data-inspector/app/composables/rpc.ts",
          "plugins/data-inspector/src/node/legacy-queries.ts",
          "plugins/data-inspector/src/node/saved-queries.ts",
          "plugins/data-inspector/src/node/engine/contract.ts",
          "plugins/data-inspector/src/node/rpc/index.ts",
          "plugins/data-inspector/src/node/rpc/functions/saved.ts"
        ],
        "critical": true,
        "fileNotes": [
          {
            "path": "plugins/data-inspector/src/node/legacy-queries.ts",
            "text": "Core migration logic: reads the legacy queries.json read-only and keeps claim/discard state in a separate queries.claims.json so the legacy file is never rewritten and a record is offered to only one project.",
            "critical": true
          },
          {
            "path": "plugins/data-inspector/src/node/saved-queries.ts",
            "text": "`importSavedQueries` deliberately bypasses `saveQuery`'s cross-scope move so an imported project-scope record can't overwrite a same-id workspace query."
          }
        ]
      },
      {
        "key": "settings-notice-backend",
        "label": "Settings legacy-scope notice (backend)",
        "summary": "Adds the optional, duck-typed `getLegacyStorageDir(scope)` host capability (`resolveLegacyStorageDir`) and, on top of it, a one-time notice reporting which settings namespaces still hold a file from before `project` and `global` scopes were split; dismissal is recorded once per machine via a marker file. Nothing is migrated since per-key last-write-wins makes the original scope unrecoverable.",
        "category": "core",
        "filePaths": [
          "docs/content/1.guide/7.scoped-context.md",
          "docs/content/6.errors/DF0087.md",
          "docs/content/6.errors/index.md",
          "docs/content/8.references/4.node-api.md",
          "packages/devframe/src/node/context.ts",
          "packages/devframe/src/node/diagnostics.ts",
          "packages/devframe/src/node/index.ts",
          "packages/devframe/src/node/legacy-storage.ts",
          "packages/devframe/src/node/settings-legacy-notice.ts",
          "packages/devframe/src/node/settings.ts",
          "packages/devframe/src/node/rpc/settings-legacy-notice.ts"
        ],
        "fileNotes": [
          {
            "path": "packages/devframe/src/node/legacy-storage.ts",
            "text": "Shared infrastructure consumed by this group, the hub dock fallback, and the Data Inspector import: a throwing or non-string `getLegacyStorageDir` is treated as \"no legacy data\" rather than propagated, so a buggy host degrades silently."
          },
          {
            "path": "packages/devframe/src/node/settings-legacy-notice.ts",
            "text": "Detects legacy state by presence of any `*.json` file in the global settings dir, not by content, so it can't tell a genuinely new global setting from a leftover pre-split file — only a heuristic."
          }
        ]
      },
      {
        "key": "settings-notice-ui",
        "label": "Settings notice UI & copy",
        "summary": "Surfaces the one-time shared-scope settings notice in Settings > Advanced, with a dismiss action calling the new RPC, and adds the translated copy for every supported locale.",
        "category": "ui",
        "filePaths": [
          "packages/hub-ui/src/client/components/views-builtin/SettingsAdvanced.vue",
          "packages/hub-ui/src/client/i18n/locales/de.json",
          "packages/hub-ui/src/client/i18n/locales/en.json",
          "packages/hub-ui/src/client/i18n/locales/es.json",
          "packages/hub-ui/src/client/i18n/locales/fr.json",
          "packages/hub-ui/src/client/i18n/locales/ja.json",
          "packages/hub-ui/src/client/i18n/locales/ko.json",
          "packages/hub-ui/src/client/i18n/locales/pt-BR.json",
          "packages/hub-ui/src/client/i18n/locales/ru.json",
          "packages/hub-ui/src/client/i18n/locales/zh-CN.json",
          "packages/hub-ui/src/client/i18n/locales/zh-TW.json"
        ],
        "fileNotes": [
          {
            "path": "packages/hub-ui/src/client/components/views-builtin/SettingsAdvanced.vue",
            "text": "Uses `rpc.callOptional`, so the card silently stays hidden against a server that doesn't register the new built-in RPCs."
          }
        ]
      },
      {
        "key": "hub-dock-fallback",
        "label": "Hub dock settings fallback",
        "summary": "Since the hub's dock `settings.json` has no global counterpart to fall back to, a checkout without its own settings file seeds the initial dock layout once from the legacy project-scope file; the fallback is explicitly marked temporary and only ever read, never rewritten.",
        "category": "core",
        "filePaths": [
          "docs/content/1.guide/16.hub.md",
          "docs/content/6.errors/DF8112.md",
          "packages/hub/src/node/diagnostics.ts",
          "packages/hub/src/node/host-docks.ts"
        ],
        "fileNotes": [
          {
            "path": "packages/hub/src/node/host-docks.ts",
            "text": "`readLegacyUserSettings` only applies when the project's own `settings.json` doesn't exist yet; an unreadable or corrupt legacy file falls back to defaults with a warning rather than failing init."
          }
        ]
      },
      {
        "key": "tests",
        "label": "Tests, stories & snapshots",
        "summary": "Test coverage for the three features above (legacy storage resolution, settings notice, dock fallback, saved-query import), plus a Storybook fixture/story for the import dialog and the generated type snapshots reflecting the new public APIs.",
        "category": "tests",
        "filePaths": [
          "packages/devframe/src/node/__tests__/settings-legacy-notice.test.ts",
          "packages/hub/src/node/__tests__/host-docks.test.ts",
          "plugins/data-inspector/app/components/_fixtures.ts",
          "plugins/data-inspector/app/components/SavedQueriesPanel.stories.ts",
          "plugins/data-inspector/test/legacy-queries.test.ts",
          "tests/__snapshots__/tsnapi/@devframes/plugin-data-inspector/engine.snapshot.d.ts",
          "tests/__snapshots__/tsnapi/@devframes/plugin-data-inspector/node.snapshot.d.ts",
          "tests/__snapshots__/tsnapi/devframe/internal.snapshot.d.ts",
          "tests/__snapshots__/tsnapi/devframe/node.snapshot.d.ts",
          "tests/__snapshots__/tsnapi/devframe/node.snapshot.js"
        ]
      }
    ],
    "schemaVersion": 1,
    "source": "llm",
    "generatedAt": "2026-11-28T11:17:38.845Z",
    "model": "vercel-ai-gateway/anthropic/claude-sonnet-5",
    "locale": "en"
  }
}

This branch has not been deployed

No deployments
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