Skip to content

fix(hub-ui): keep dock selection and restored routes in sync - #497

Open
webfansplz wants to merge 1 commit into
mainfrom
fix/hub-ui-dock-route-restore
Open

webfansplz wants to merge 1 commit into
mainfrom
fix/hub-ui-dock-route-restore

Conversation

@webfansplz

@webfansplz webfansplz commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Problem

The hub remembers the selected dock and the URL its iframe was on (selectedDockId / selectedDockRoute in session storage), so a reload reopens the same dock at the same page.

When the user switches from one iframe dock to another, the new dock ID is saved right away, but the route is only updated after the new iframe mounts. If the page reloads in between, session storage ends up with dock B's ID and dock A's URL. On the next load the hub restores dock B with dock A's URL, so dock B's panel shows dock A's page. Because existing iframe panes are reused, the wrong page stays there until session storage is cleared.

Reproduction

  1. Register two iframe docks, A and B.
  2. Open A, then switch to B and reload immediately.
  3. B is selected, but its iframe loads A's URL.

Fix

  • When the selected dock ID changes, clear the saved route in the same update, so a stale route is never paired with a new dock.
  • When restoring, use the saved route only if its origin and path belong to the selected iframe dock's URL. Otherwise fall back to the dock's default URL. The path check stops at a / boundary, so a dock at /foo/ does not accept a route from /foo-bar/.

Tests

Added regression cases to context.test.ts: switching docks clears the route, valid deep links are restored, and routes from other docks, similarly named paths, other ports or protocols, and invalid URLs are rejected. 5 of them fail without the fix; all 26 tests in the suite pass with it.

pnpm lint, pnpm knip, pnpm typecheck and pnpm build pass. In the full pnpm test, 3 diagnostic type export snapshots fail in devframe, @devframes/plugin-code-server and @devframes/plugin-terminals; this PR doesn't touch those packages.

Copilot AI balanced review requested due to automatic review settings November 18, 2026 07:11
@vercel

vercel Bot commented Nov 18, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated
devframe Ignored Ignored Nov 18, 2026 7:11am UTC

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@github-actions

Copy link
Copy Markdown

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

raw result

💭 analyzed by vercel-ai-gateway/anthropic/claude-sonnet-5
🕰️ 2026-11-18 07:11 UTC
🔗 head f57377b
🤖 automated by pulls.review

{
  "headSha": "f57377b0e8124bac1a4903f73d124da1b87a2836",
  "result": {
    "overallSummary": "Fixes a bug where switching docks (e.g. Vite → Vite Task) and reloading could restore the old dock's saved URL into the new dock's panel. The fix clears the stored route whenever the selected dock ID changes, and on restore only accepts a saved route if it matches the newly selected iframe dock's origin and path (with proper slash-boundary checks to avoid collisions between similarly named docks).",
    "groups": [
      {
        "key": "dock-route-sync",
        "label": "Dock route sync fix",
        "summary": "Clears the previously selected dock's saved route before switching dock IDs, and validates that a restored route's origin/path actually belongs to the selected iframe dock before reusing it, falling back to the dock's default URL otherwise.",
        "category": "core",
        "filePaths": [
          "packages/hub-ui/src/client/state/context.ts"
        ],
        "critical": true,
        "lineNotes": [
          {
            "path": "packages/hub-ui/src/client/state/context.ts",
            "side": "additions",
            "line": 112,
            "text": "Resetting selectedDockRoute to null on dock change is the core fix: prevents a stale route saved under the old dock from leaking into the newly selected dock on reload."
          },
          {
            "path": "packages/hub-ui/src/client/state/context.ts",
            "side": "additions",
            "line": 765,
            "text": "Boot route is only reused if its origin matches and its path equals or is a sub-path of the dock's base path (slash-boundary check), avoiding false matches between similarly named docks like `vite` and `vite-task`."
          }
        ]
      },
      {
        "key": "tests",
        "label": "Dock route persistence tests",
        "summary": "Adds regression tests covering route clearing on dock switch and boot-route restoration validation across same/different origin, path-prefix collisions, and malformed URLs.",
        "category": "tests",
        "filePaths": [
          "packages/hub-ui/src/client/state/context.test.ts"
        ]
      }
    ],
    "schemaVersion": 1,
    "source": "llm",
    "generatedAt": "2026-11-18T07:11:45.164Z",
    "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.

2 participants