Skip to content

Commit ad604c1

Browse files
fix(app-shell,console): the shell package list, AI chat lists and studio-design reads and writes send the stored bearer token (#37185)
Fixes #37080 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:浏览器里只剩登录令牌(会话 Cookie 被替换、拦截或清掉)的用户,侧边栏、应用头部、命令面板和 Studio 入口里的应用包列表不再消失,AI 对话列表、建议权限绑定、提交历史、草稿面板等也正常加载;只用 Cookie 登录的用户看不到任何变化。 - 为什么做:控制台其它请求都会带上登录令牌,这一批读写漏带,属于"控制台登录状态体验"这一块的缺陷,替所有处于这种登录状态的用户解决,并加了一道测试防止以后再写出漏带令牌的请求。 - 出错会怎样:最坏情况是这些地方重新读不到数据,与修复前一样;不改服务端接受什么、不改登录方式,可以直接撤回。 - 要你做什么:无。 ## What changes Same-server `/api/` reads and writes in app-shell and the console that called the bare global `fetch` with `credentials: 'include'` (the session cookie and nothing else) now go through `createAuthenticatedFetch` from `@object-ui/auth`, exactly as #37077 did for the Setup pages: built per call (`createAuthenticatedFetch()(input, init)`, a local `authFetch` in each module), `credentials: 'include'` kept on every call, so the cookie still rides along and a `401` now reaches the console's session-ended check. No second auth-fetch helper and no new export. Nothing changes in what the server accepts. The measured case: under a bearer-only session, `readPackagesPayload` (`GET /api/v1/packages`, the session's held package list read by the sidebar, the app header, the command palette and the Studio entries) sends the bearer and the list loads (pinned below). ### The family, measured at `origin/main` 63ab479 79 non-test files under `ui/packages/app-shell/src` and `ui/apps/console/src` contain `credentials: 'include'`. Read call by call (AST scan of every `credentials: 'include'` property and the call it is handed to): **Converted here: 64 calls in 39 files.** | File | Calls | |---|---| | `app-shell/.../studio-design/packages-io.ts` | `readPackagesPayload` (`GET /api/v1/packages`, the measured case), `ensureCustomizationPackage`, `duplicatePackage` | | `app-shell/.../studio-design/packageCustomizations-io.ts`, `PackageSwitcher.tsx`, `AutomationsPillar.tsx`, `FlowItemMoreMenu.tsx` | 1 each (customizations read, switcher list, automation status, flow clone) | | `app-shell/src/hooks/useConversationList.ts` | 4 (list, detail, rename, delete) | | `app-shell/src/hooks/useChatConversation.ts` | 3 (read, create, update) | | `app-shell/src/console/ai/buildDebugApi.ts` | 1 (build-debug report) | | `app-shell/src/hooks/useAiUsage.ts` | 1 | | `app-shell/src/services/suggestedBindingsApi.ts` | 4 (list, confirm, dismiss, reopen) | | `app-shell/src/preview/commitHistory.ts` | 2 (timeline, revert) | | `app-shell/src/preview/DraftChangesPanel.tsx`, `UnpublishedAppBar.tsx`, `usePendingDrafts.ts` | 2, 1, 1 | | `app-shell/src/preview/flowDraftChecks.ts` | the default transport (`opts.fetchImpl ?? createAuthenticatedFetch()`) | | `app-shell/src/views/changeOwner.ts` | the fallback transport (`apiFetch ?? createAuthenticatedFetch()`) | | `app-shell/src/views/metadata-admin/` `PackageFormDialog.tsx`, `catalog-activation.ts`, `permission-set-clone.ts`, `sharing-rule-catalog.ts` | 1, 2, 1, 1 | | `app-shell/src/views/metadata-admin/inspectors/` `FlowReferenceField.tsx`, `connector-input-fields.ts` | 2, 1 | | `app-shell/src/views/metadata-admin/previews/` `FlowRunsPanel.tsx`, `useFlowNodePalette.ts`, `PagePreview.tsx` | 1, 1, 2 | | `app-shell/src/views/setup/` `packagedActionLedger.ts`, `packagedFlowLedger.ts` | 2, 1 | | `app-shell/src/hooks/` `useRecordApprovals.ts`, `sharedUserFeeds.ts`, `useInboxBell.ts` | 1 each | | `app-shell/src/console/` `AppNoAccessEmptyState.tsx`, `connect/ConnectAgentWidget.tsx`, `deployment-notice/deploymentNoticeState.ts` | 1, 2, 2 | | `app-shell/src/console/marketplace/marketplaceApi.ts` | 5 same-server calls onto the existing `serverFetch` (`/cloud-connection/install`, `install-namespace`, `installation`, and on the control plane its own `install_package` action and installed-state route) | | `app-shell/src/layout/designModeMenuSave.ts` | 1 (`/api/v1/i18n/locales`) | | `app-shell/src/layout/ContextSelectors.tsx` | 1, with `{ sameOriginOnly: true }`: the endpoint is author-written (`optionsSource.endpoint`) and may name another host | | `console/src/pages/developer/` `AgentConnectSection.tsx`, `IntegrationsPage.tsx` | 2, 1 | | `console/src/pages/auth/DeviceAuthPage.tsx` | 3 (claim, approve, deny: a signed-in act) | Of the card's named ones: `packages-io.ts` `readPackagesPayload`, `useConversationList`, `useChatConversation`, `suggestedBindingsApi` and the studio-design writes (ensure-customization, duplicate, customizations, flow clone) are all converted. `suggestedBindingsApi`, `useRecordApprovals`, `sharedUserFeeds`, `useInboxBell`, `ConnectAgentWidget`, `deploymentNoticeState` and three `marketplaceApi` calls already set the bearer header by hand (`authHeaders` / `bearerAuthHeaders` / `withEnvAuth`), so those were not cookie-only; they are converted anyway for the session-ended check and the one mechanism, and their hand-rolled header is left in place (the wrapper sets the same value). **Already authenticated or injected (not the family): 24 files.** `settings/api.ts`, `AuditLogPage.tsx`, `approvalsApi.ts`, `studioEntry.ts`, `ExcelImportBar.tsx`, `CloudAiModelStatus.tsx`, `useEnvironmentEntitlements.ts`, `storageUsageEndpoint.ts`, `ImpersonationBanner.tsx`, `useImpersonationExit.ts`, `RecordAttachmentsPanel.tsx`, `RecordDetailView.tsx`, `useConsoleActionRuntime.tsx`, `AccessExplainPanel.tsx`, `MetadataTypeActions.tsx`, `PackagesPage.tsx`, `DatasourceResourcePage.tsx`, `personalViews.ts`, `connectorConnections.ts`, `connectorCredentials.ts`, and the injected transports of `myPreferences.ts`, `slackDoors.ts`, `orgEnvironments.ts`, `useLauncherApps.tsx`. `App.tsx` names the string in a comment only. **Left, on the pin's shrink-only list: 21 calls in 15 files**, each with its reason in the pin (`sameServerFetch.bearer.ratchet.test.ts`, `ALLOWED`): - `console/src/LocalizationFetchProvider.tsx` (1) and `console/src/languageSeed.ts` (not counted by the pin: it hands `sharedGetJson` a transport argument that may be `undefined`): the boot read of `/api/v1/auth/me/localization`, shared in flight by a key built from the init with the early request `index.html` sends. A session it cannot see reads `authenticated: false` and falls back to the browser language rather than failing. Its transport is its own decision (Acceptance notes). - `console/src/components/FormPage.tsx` (1): the bare channel is the public form route's on purpose. - `console/src/lib/auth-preflight.ts`, `console/src/lib/early-discovery.ts` (1 each): set the bearer header themselves on purpose. - `console/src/pages/auth/OAuthConsentPage.tsx` (3), `followAuthorize.ts` (1), `handoffClientName.ts` (1): the OAuth hand-off, whose authorize step is a top-level navigation that can only carry the cookie. - `console/src/pages/auth/SetupPage.tsx`, `app-shell/src/console/auth/bootstrapStatus.ts`, `console/src/pages/auth/VerifyEmailPage.tsx`, `app-shell/src/chrome/ConditionalAuthWrapper.tsx`, `app-shell/src/runtime-config.ts` (1 each): read before or without a session. - `app-shell/src/console/ai/AiChatPage.tsx` (1): an open PR (#37123) edits this file; its call moves with that work. - `app-shell/src/console/marketplace/marketplaceApi.ts` (5): each targets `getCloudBase() || SERVER_URL`, the cloud control plane's own origin whenever one is configured, which must never see this runtime's bearer. - `app-shell/src/views/metadata-admin/previews/ActionPreview.tsx` (1): the test request of an `api` action preview, sent to the author-written target; its transport is not decided here. The other two fenced files hold no family call: `RecordDetailView.tsx` and `useConsoleActionRuntime.tsx` already route every `credentials: 'include'` call through their `authFetch`. Neither was edited. ## Tests - `ui/packages/app-shell/src/sameServerFetch.bearer.ratchet.test.ts` (new, the enumeration pin; runs in **Test UI**, app-shell's `unit` project): parses every non-test source file of both trees with the TypeScript parser and refuses a bare cookie-only call (the transport is the global `fetch`, `window.fetch`, `globalThis.fetch`, `self.fetch`, one of those as a `??` / `||` fallback, or `sharedGetJson` without its transport argument; the init carries `credentials: 'include'`, inline or as a `const` of the file, `as const` included). The URL is not judged: a call that must stay bare is a counted row with its reason. Four cases: the scan reads both trees (more than 500 and 100 files); a 13-case detector battery (each bare spelling found, each authenticated one not); every bare call is a counted row; every row is still exact (a file that sheds a call must shrink its row). - `ui/packages/app-shell/src/views/studio-design/packages-io.bearerSession.test.ts` (new): against a server that refuses any request without the bearer, with a token stored, `fetchPackages` loads the list and its one request carries `Authorization: Bearer TOKEN` and `credentials: 'include'`; `fetchListedPackageIds` likewise; the duplicate write, the commit timeline and revert, suggested bindings and the build-debug report carry the bearer. Each with a cookie-only control (no token stored: no `Authorization`, `credentials: 'include'`). Test doubles that moved (118 files, no assertion weakened): - 102 files: hand-rolled `Response` doubles (`{ ok, status, json }`) gain `headers: new Headers()`, the headers a real `Response` carries and the authenticated fetch reads (`set-auth-token`), as #37077 did. The 102nd, `StudioPaletteGroups.surfaceScope-36900` (the command-palette suite that reached `main` after round 0), doubles `GET /api/v1/packages`: without the headers the converted `readPackagesPayload` threw on the double and the palette drew no Packages group. For `fetchInstalledPackageRow-7881` and `StudioDesignSurface.readOnlyPosture-12453` the headers are added at the one stub instead of each answer. - 8 files whose `@object-ui/auth` mock answered `createAuthenticatedFetch: () => vi.fn()` (a transport that answers nothing) now hand the authenticated fetch's requests to the global `fetch` the file already stubs: the four `RecordApprovalsPanel` suites and `RecordDetailView` `editLockedByState-32756`, `phoneFace-27058`, `userActionPredicates`, `harness`. - 5 `RecordDetailView` approval suites whose `authFetchSpy` stands for the action door: approvals reads (now through the authenticated fetch too) are handed to the file's wire double, as before (`approvalRecallGate`, `accessEndedAfterDecision-26589`, `approvalDeclaredActions`, `approvalLock-12220`, `approvalLock-25934`). - `StudioRoute.searchPalette-11863` (console): its auth mock answers the Studio permissions read and hands every other request (the package list) to the wire double. - 3 assertions read the init the wire received (the last two files are also among the 101): `useConversationList` and `BuildDebugDrawer` assert `{ credentials: 'include', headers: expect.any(Headers) }` (exact keys, as before); `DraftChangesPanel.flowChecks-34818` reads `Accept-Language` off a `Headers`. - `RecordDetailView.headerApiInterpolation`: the flow-trigger case asserts exactly one call to the trigger door, filtered by its path, since the page's own reads now share that spy. ## Acceptance notes - Same defect family outside the two trees, not touched (the card scopes the `plugin-*` hooks out unless measured here): `credentials: 'include'` with the bare `fetch` remains in `ui/packages/plugin-chatbot` (`useAgents`, `useAiModels`, `useHitlInChat`, `usePendingActions`), `plugin-detail` (`queueClaim`, `stageChangeStarts`, `useRecordEditable`), `plugin-grid` (`useRecordCrudVerdicts`, `useRowApprovalLocks`), `plugin-dashboard` (`DatasetWidget`), `plugin-charts` (`ObjectChart`), `fields` (`ShareableObjectRefField`, `preferenceOptions`), `components` (`ShareDialog`) and `permissions` (`MePermissionsProvider`). Not each read call by call. - A bare `fetch('/api/…')` with no init at all is cookie-only as well (the default `same-origin` credentials) and is outside the pin's spelling: `views/metadata-admin/widgets.tsx` `fetchFieldSelectorOptions` (`GET /api/v1/objects/:name/fields`). - `LocalizationFetchProvider` and `languageSeed` read `/api/v1/auth/me/localization` cookie-only; under a bearer-only session that read answers anonymously and the console falls back to the browser language instead of the user's own locale. Not measured in a browser; left because the request key is shared with the early request `index.html` sends. - The hand-rolled bearer helpers left beside converted calls (`authHeaders` in `suggestedBindingsApi`, `bearerAuthHeaders`, `withEnvAuth`) are now redundant there; not removed here. ## Verification <details><summary>The measured case and the pins (green at the head)</summary> `packages-io.bearerSession.test.ts` and the ratchet are in the rerun below (all green). The ratchet's detector battery first went red on a real detector issue: at a script's top level `await (x)(…)` parses as a call of `await`, so the `(apiFetch ?? fetch)` case read 0; the cases now run inside an async function. </details> <details><summary>Ablation: one conversion reverted, both pins red</summary> Through `scripts/ablation-replace.mjs` on `packages-io.ts`: anchor `const res = await authFetch('/api/v1/packages', {` hit 1 → 0, blob `d3c93d771344` → `42f8862ba05e`; the ratchet and the bearer-session file run under the lock: ```text FAIL sameServerFetch.bearer.ratchet.test.ts > every bare cookie-only call is a counted row of the shrink-only allow-list + "packages/app-shell/src/views/studio-design/packages-io.ts:398 :: fetch('/api/v1/packages', …)" FAIL packages-io.bearerSession.test.ts > loads the package list, sending the stored bearer beside the cookie FAIL packages-io.bearerSession.test.ts > answers the listed-id read from the same authenticated request Test Files 2 failed (2) Tests 3 failed | 14 passed (17) ``` The cookie-only control stayed green. Restored: blob `d3c93d771344` equal to `HEAD`, `git diff HEAD` empty. </details> <details><summary>Suites</summary> The whole `@object-ui/app-shell` and `@object-ui/console` suites, under the shared verify lock, in six shards (`cd ui && pnpm exec vitest run --maxWorkers=3 --shard=k/6 packages/app-shell apps/console`) at `32505939` (the final source; only test files changed after it). These are the readings BEFORE the doubles moved, and they are how the moved doubles were found: ```text shard 1/6: Test Files 21 failed | 440 passed (461) · Tests 121 failed | 4304 passed (4425) shard 2/6: Test Files 16 failed | 446 passed (462) · Tests 64 failed | 4352 passed | 1 skipped (4417) shard 3/6: Test Files 23 failed | 439 passed (462) · Tests 104 failed | 4111 passed (4215) shard 4/6: Test Files 17 failed | 445 passed | 1 skipped (463) · Tests 87 failed | 4383 passed | 8 skipped (4478) shard 5/6: Test Files 26 failed | 436 passed (462) · Tests 116 failed | 4636 passed (4752) shard 6/6: Test Files 14 failed | 448 passed (462) · Tests 77 failed | 4286 passed (4363) ``` The 117 failing files are exactly the 117 moved doubles. Each was re-run after its fix (the two new pin files with them): `Test Files 116 passed | 3 failed (119)`, then the three fixed again `Test Files 3 passed (3)`. After the last two type fixes `Test Files 2 passed (2)`, and after the collection-time imports the 34 files that gained one `Test Files 34 passed (34)` / `Tests 319 passed (319)`, at `5dde589a8c`. The 2,655 files that passed in the shards were not edited. A full re-run after the fixes was not done locally (NOT MEASURED, reason: about 90 minutes of shared lock); Test UI runs the full affected set on this PR. Type-check through turbo (dependency closure built): `@object-ui/app-shell` and `@object-ui/console` `type-check` `Tasks: 77 successful, 77 total` at `3080a68173`; `@object-ui/app-shell` again at `5dde589a8c` after the last test edits, `Tasks: 69 successful, 69 total`. The first run found two type errors in my test edits (a typed tuple, an object literal against a declared parameter type), fixed in `3080a68173`. `pnpm --dir ui exec vitest run scripts/` after building the seven `@objectstack` packages as Test UI does: `Test Files 172 passed | 2 skipped (174)`, `Tests 5131 passed | 2 skipped (5133)`. </details> <details><summary>Gates</summary> `node scripts/pm/dispatch-gates.mjs --commands` (no paths, merge base `63ab4794`): 39 families. All 39 run locally, each exit captured before any pipe; 37 lock-free families re-run at `5dde589a8c`, all exit 0; `pnpm check:type-check-debt` exit 0 (`0 raw tsc error(s) total, none above its recorded number`); the ui `scripts/` suite above exit 0. Reconciled: `dispatch-gates --ran`: `39 derived famil(ies) accounted for — 39 run, 0 NOT-MEASURED (a DERIVED zero)`. `check:test-source-alias` first went red on the edited suites (exit 1): 34 of them reach a dynamic `import('@objectstack/lint')`, `import('@objectstack/formula')` or `import('@object-ui/plugin-detail')` in the source under test with no collection-time load. Each gained the module-top side-effect import the gate prescribes (`5dde589a8c`), then exit 0. `overlap-check` before every push: at `4a990ef7` it merges cleanly with `origin/main` (`93bd4595`) and with #37204, #37188 and #37148, and exits 1 on textual conflicts with three open Studio PRs that edit the same test files: #37166, #37168, #37169 (in `StudioDesignSurface.*`, `BuilderLanding.*`, `CommandPalette.studioScope-11863`, `StudioRoute.searchPalette-11863`, and #37166/#37169 also in `PackageSwitcher.tsx`, `FlowItemMoreMenu.tsx`). Whichever lands second takes the merge. </details> <details><summary>Round 1: main merged at 3b4f0b9, re-measured at e055596</summary> CI at `5dde589a` was red on two causes, both from `main` moving (the ⌘K palette work): - `check:test-source-alias` exit 1: four edited suites (`StudioDesignSurface` `entryReadsOnce-11797`, `itemDraftLine-12725`, `notFound-26708`, `readOnlyPosture-12453`) now reach `import('@object-ui/plugin-detail')` through the surface's command palette and its record preview. Each gained the prescribed module-top `import '@object-ui/plugin-detail';` (38 files carry a collection-time import in all). Then exit 0. - `StudioPaletteGroups.surfaceScope-36900`: 3 failed, 8 passed; after its package-list double gained `headers` (above), 11 passed. No assertion changed. Readings at `e0555965`, under the shared verify lock: ```text ratchet + bearer-session pin + main's 35 incoming app-shell/console test files + the 5 edited files: Test Files 41 passed (41) · Tests 394 passed (394) whole @object-ui/app-shell + @object-ui/console (cd ui && pnpm exec vitest run --maxWorkers=3 packages/app-shell/ apps/console/): Test Files 1 failed | 2779 passed | 1 skipped (2781) · Tests 2 failed | 26745 passed | 9 skipped (26756) ``` The one failing file is `ReportNewPage-36692.test.tsx`, which this branch does not touch (nor its page); it passed 3 of 3 runs alone (`Tests 6 passed (6)` each). Its second failure received the first case's save call, late: its cases flush by `setTimeout(0)` rounds while the page loads its Han romanizer lazily, so on a loaded box the save can land after the case ends. `@object-ui/app-shell` `type-check` through turbo: `Tasks: 69 successful, 69 total`. `pnpm --dir ui exec vitest run scripts/`: `Test Files 172 passed | 2 skipped (174)`, `Tests 5131 passed | 2 skipped (5133)`. Gates: `dispatch-gates --commands` (merge base `3b4f0b98`): 39 families, all run, each exit captured before any pipe, all exit 0. `check:type-check-debt` first answered exit 3 (its closure build queued behind the suite above and never got the lock: not measured), then exit 0 under the lock (`0 raw tsc error(s) total, none above its recorded number`). `dispatch-gates --ran`: `39 derived famil(ies) accounted for — 39 run, 0 NOT-MEASURED (a DERIVED zero …)`. </details> ## Read first 1. `ui/packages/app-shell/src/sameServerFetch.bearer.ratchet.test.ts`: the detector and the `ALLOWED` rows (each reason is a claim about a call left bare). 2. `ui/packages/app-shell/src/layout/ContextSelectors.tsx`: the one conversion with `sameOriginOnly`, because its URL is author-written. 3. `ui/packages/app-shell/src/console/marketplace/marketplaceApi.ts`: which calls moved onto `serverFetch` and which stay bare because they may target the cloud origin. Two-minute check: `cd ui && pnpm exec vitest run packages/app-shell/src/sameServerFetch.bearer.ratchet.test.ts packages/app-shell/src/views/studio-design/packages-io.bearerSession.test.ts`, expect `Test Files 2 passed (2)`. <details><summary>Round 2: main merged at 93bd459, re-measured at 4a990ef</summary> - #37089 landed on `main` after round 1 and left this PR conflicting in `StudioDesignSurface.notFound-26708` and `StudioDesignSurface.readOnlyPosture-12453`: both sides add the same `import '@object-ui/plugin-detail';` with a different comment. The merge (`48321c62`) keeps one import with `main`'s comment, so against `main` those two files differ only by round 0's doubles. - Main's ten new commits add no `credentials: 'include'` line under `ui/packages/app-shell/src` or `ui/apps/console/src`, and their one new hand-rolled Response double already carries `headers: new Headers()`. - The two changesets (`4a990ef7`) now name every converted door in user terms (flow clone, permission-set clone, page preview, the no-access state and the design-mode language list were missing) and claim only "the other same-server console requests", since the 21 listed calls stay cookie-only. Readings at `4a990ef7`, under the shared verify lock (`packages/spec` moved on `main`: the seven `@objectstack` packages Test UI builds were rebuilt first, and `pnpm --filter @objectstack/spec check:generated` reads `All 14 generated artifacts are up to date`): ```text the ratchet, the bearer-session pin, the 5 test files edited in round 1, every existing test file the merge touched in the two trees, and the suites named for each source file it touched: Test Files 311 passed (311) · Tests 2133 passed (2133) ``` `check:test-source-alias` exit 0. `@object-ui/app-shell` `type-check` through turbo: `Tasks: 69 successful, 69 total`. `dispatch-gates --commands` (merge base `93bd4595`): the same 39 families, all run, each exit captured before any pipe, all exit 0 (`check:type-check-debt`: `0 raw tsc error(s) total, none above its recorded number`; the ui `scripts/` suite `Test Files 172 passed | 2 skipped (174)`). `dispatch-gates --ran`: `39 derived famil(ies) accounted for — 39 run, 0 NOT-MEASURED (a DERIVED zero …)`. The whole app-shell and console suites were not re-run this round (NOT MEASURED, reason: about 70 minutes of shared lock for a merge that changed no source line of this PR); Test UI runs the affected set on this PR. </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01QSeKYmRepQK9DkZeU7F53D)_ <!-- signed: repo:objectstack#4 · os-justin · session_01QSeKYmRepQK9DkZeU7F53D --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 6831e04 commit ad604c1

161 files changed

Lines changed: 1109 additions & 290 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@object-ui/console': patch
3+
---
4+
5+
fix(console): the developer pages and the device sign-in approval send the stored sign-in token, so a session held by its token alone works there too
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
The developer integrations page, the agent-connect section (discovery and creating an API key) and the device sign-in approval (claim, approve, deny) asked this server with the session cookie only, so a session held by its sign-in (bearer) token alone was refused there. They now send the stored token as well, as the other same-server console requests do. The session cookie is still sent, so a cookie session behaves exactly as before, and a refused request now reaches the console's session-ended check. Nothing changes in what the server accepts.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
---
4+
5+
fix(app-shell): the package list, Studio, AI chat and draft screens send the stored sign-in token, so a session held by its token alone keeps its packages, Studio and design entries
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
These screens asked this server for their data with the session cookie only, while the other same-server console requests also send the stored sign-in (bearer) token. A session held by its token alone (a second local runtime on the same host replaced the cookie, the browser blocked it as a third-party cookie, or the cookie jar was cleared) was refused there. The most visible case was the package list behind the sidebar, the app header, the command palette and the Studio entries: every package went missing, and the Studio and design entries with it, with no error shown.
11+
12+
They now send the token as well:
13+
14+
- packages: the package list and the package switcher, creating a package's customization package, duplicating a package, a package's customizations, and the package form;
15+
- Studio: the automation status, cloning a flow, cloning a permission set, the flow picker and connector inputs, a flow's run history and node palette, the page preview, the sharing-rule catalog and catalog activation, and the packaged action and flow ledgers in Setup;
16+
- drafts: the pending drafts, the unpublished-app bar, the draft changes panel and its flow checks, and the commit history with its revert;
17+
- AI: the conversation list and conversations, the build-debug report, AI usage, and suggested bindings;
18+
- the inbox bell, the approval feeds and a record's approvals, and changing a record's owner;
19+
- the shell: the no-access state, the deployment notice, the connect-agent widget, the context selectors (only for requests to this server's own origin), the design-mode language list, and the marketplace's install steps on this server.
20+
21+
The session cookie is still sent, so a cookie session behaves exactly as before, and a refused request now reaches the console's session-ended check. A few requests stay cookie-only for now, among them sign-in, the OAuth hand-off, public forms and calls to the cloud control plane; they are unchanged. Nothing changes in what the server accepts.

‎ui/apps/console/src/components/StudioRoute.searchPalette-11863.test.tsx‎

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,19 @@ function jsonResponse(body: unknown, status = 200): Response {
4242
vi.mock('@object-ui/auth', async (importOriginal) => ({
4343
...(await importOriginal<Record<string, unknown>>()),
4444
useAuth: () => auth,
45-
createAuthenticatedFetch: () => async () =>
46-
jsonResponse({
47-
authenticated: true,
48-
userId: 'u1',
49-
systemPermissions: ['studio.access'],
50-
objects: {},
51-
fields: {},
52-
}),
45+
// The Studio gate's permissions read answers here; every other request (the
46+
// package list included, which goes out through the authenticated fetch too)
47+
// answers from the wire double each case stubs.
48+
createAuthenticatedFetch: () => async (input: RequestInfo | URL, init?: RequestInit) =>
49+
String(input).endsWith('/api/v1/auth/me/permissions')
50+
? jsonResponse({
51+
authenticated: true,
52+
userId: 'u1',
53+
systemPermissions: ['studio.access'],
54+
objects: {},
55+
fields: {},
56+
})
57+
: fetch(input, init),
5358
}));
5459

5560
// `AuthGuard` reaches `useAuth` through the auth package's OWN module graph,

‎ui/apps/console/src/pages/auth/DeviceAuthPage.tsx‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { useEffect, useState } from 'react';
1111
import { Navigate, useLocation, useNavigate, useSearchParams } from 'react-router-dom';
1212
import { CheckCircle2 } from 'lucide-react';
1313
import { toast } from 'sonner';
14-
import { useAuth } from '@object-ui/auth';
14+
import { createAuthenticatedFetch, useAuth } from '@object-ui/auth';
1515
import { useObjectTranslation } from '@object-ui/i18n';
1616
import { getProductName, getLogoUrl } from '@object-ui/app-shell';
1717
import {
@@ -23,6 +23,11 @@ import {
2323
CardTitle,
2424
} from '@object-ui/components';
2525

26+
/** The console's authenticated fetch: the stored bearer token beside the session cookie. */
27+
function authFetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response> {
28+
return createAuthenticatedFetch()(input, init);
29+
}
30+
2631
const AUTH_BASE = `${import.meta.env.VITE_SERVER_URL || ''}/api/v1/auth`;
2732

2833
function PageShell({ children }: { children: React.ReactNode }) {
@@ -200,7 +205,7 @@ export function DeviceAuthPage() {
200205
// accept approve/deny — without it both return 400 "not been claimed
201206
// by a verifying session". Idempotent, so claim right before acting.
202207
const claimDevice = async () => {
203-
await fetch(`${AUTH_BASE}/device?user_code=${encodeURIComponent(code)}`, {
208+
await authFetch(`${AUTH_BASE}/device?user_code=${encodeURIComponent(code)}`, {
204209
credentials: 'include',
205210
}).catch(() => { /* approve below surfaces the real error */ });
206211
};
@@ -210,7 +215,7 @@ export function DeviceAuthPage() {
210215
setSubmitting(true);
211216
try {
212217
await claimDevice();
213-
const res = await fetch(`${AUTH_BASE}/device/approve`, {
218+
const res = await authFetch(`${AUTH_BASE}/device/approve`, {
214219
method: 'POST',
215220
headers: { 'Content-Type': 'application/json' },
216221
credentials: 'include',
@@ -250,7 +255,7 @@ export function DeviceAuthPage() {
250255
setDenying(true);
251256
try {
252257
await claimDevice();
253-
await fetch(`${AUTH_BASE}/device/deny`, {
258+
await authFetch(`${AUTH_BASE}/device/deny`, {
254259
method: 'POST',
255260
headers: { 'Content-Type': 'application/json' },
256261
credentials: 'include',

‎ui/apps/console/src/pages/developer/AgentConnectSection.envelopeUserMessage.test.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ function stubKeysFailure(status: number, body: unknown) {
5959
const url = String(input);
6060
if (url.includes('/api/v1/discovery')) {
6161
return {
62-
ok: true,
62+
headers: new Headers(), ok: true,
6363
status: 200,
6464
json: async () => ({ data: { routes: { mcp: '/api/v1/mcp' } } }),
6565
};
6666
}
6767
return {
68-
ok: status >= 200 && status < 300,
68+
headers: new Headers(), ok: status >= 200 && status < 300,
6969
status,
7070
json: async () => body,
7171
};

‎ui/apps/console/src/pages/developer/AgentConnectSection.keylessSuccess-8782.test.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ interface KeysAnswer {
6868
async function errorTextFor(keys: KeysAnswer): Promise<string> {
6969
const fetchMock = vi.fn(async (url: unknown) => {
7070
if (String(url).includes('/discovery')) {
71-
return { ok: true, status: 200, json: async () => DISCOVERY } as unknown as Response;
71+
return { headers: new Headers(), ok: true, status: 200, json: async () => DISCOVERY } as unknown as Response;
7272
}
7373
return {
74-
ok: keys.status >= 200 && keys.status < 300,
74+
headers: new Headers(), ok: keys.status >= 200 && keys.status < 300,
7575
status: keys.status,
7676
json: async () => {
7777
if (!('body' in keys)) throw new SyntaxError('Unexpected token < in JSON at position 0');

‎ui/apps/console/src/pages/developer/AgentConnectSection.tsx‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ import { useObjectTranslation } from '@object-ui/i18n';
5050

5151
import { SLOT, withSlots } from '../../lib/inlineSlots';
5252
import { renderObjectStackSkill } from './objectstack-skill';
53+
import { createAuthenticatedFetch } from '@object-ui/auth';
54+
55+
/** The console's authenticated fetch: the stored bearer token beside the session cookie. */
56+
function authFetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response> {
57+
return createAuthenticatedFetch()(input, init);
58+
}
5359

5460
interface GeneratedKey {
5561
id?: string;
@@ -109,7 +115,7 @@ export function AgentConnectSection() {
109115
let cancelled = false;
110116
(async () => {
111117
try {
112-
const res = await fetch('/api/v1/discovery', { credentials: 'include' });
118+
const res = await authFetch('/api/v1/discovery', { credentials: 'include' });
113119
const json = await res.json().catch(() => ({}));
114120
const route: string | undefined = json?.data?.routes?.mcp ?? json?.routes?.mcp;
115121
if (cancelled) return;
@@ -135,7 +141,7 @@ export function AgentConnectSection() {
135141
setGenerating(true);
136142
setError(null);
137143
try {
138-
const res = await fetch('/api/v1/keys', {
144+
const res = await authFetch('/api/v1/keys', {
139145
method: 'POST',
140146
credentials: 'include',
141147
headers: { 'content-type': 'application/json' },

‎ui/apps/console/src/pages/developer/IntegrationsPage.tsx‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ import { Terminal, Copy, Check, Plug, Database, KeyRound } from 'lucide-react';
3232

3333
import { AgentConnectSection } from './AgentConnectSection';
3434
import { SLOT, withSlots } from '../../lib/inlineSlots';
35+
import { createAuthenticatedFetch } from '@object-ui/auth';
36+
37+
/** The console's authenticated fetch: the stored bearer token beside the session cookie. */
38+
function authFetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response> {
39+
return createAuthenticatedFetch()(input, init);
40+
}
3541

3642
interface ConsoleObjectMeta {
3743
name: string;
@@ -101,7 +107,7 @@ function IntegrationsPageBody() {
101107
let cancelled = false;
102108
(async () => {
103109
try {
104-
const res = await fetch('/api/v1/meta/object', { credentials: 'include' });
110+
const res = await authFetch('/api/v1/meta/object', { credentials: 'include' });
105111
if (!res.ok) throw new Error(`meta/object ${res.status}`);
106112
const json = await res.json();
107113
const raw = (json?.data ?? json?.items ?? json ?? []) as Array<Record<string, unknown>>;

‎ui/packages/app-shell/src/chrome/CommandPalette.studioScope-11863.test.tsx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ vi.mock('@object-ui/auth', async (importOriginal) => ({
4444

4545
import { CommandPalette } from './CommandPalette';
4646
import { CommandPaletteProvider } from '../context/CommandPaletteProvider';
47+
// The source under test reaches a dynamic `import('@object-ui/plugin-detail')`: pay its load at
48+
// collection, never inside a case's clocked window (`check:test-source-alias`).
49+
import '@object-ui/plugin-detail';
4750

4851
/** `GET /api/v1/packages`: two app packages and a kernel one, in both served shapes. */
4952
const PACKAGES_PAYLOAD = {
@@ -106,7 +109,7 @@ let fetchMock: ReturnType<typeof vi.fn>;
106109
beforeEach(() => {
107110
fetchMock = vi.fn(async (url: string) => {
108111
if (String(url).endsWith('/api/v1/packages')) {
109-
return { ok: true, status: 200, json: async () => PACKAGES_PAYLOAD };
112+
return { headers: new Headers(), ok: true, status: 200, json: async () => PACKAGES_PAYLOAD };
110113
}
111114
throw new Error(`unexpected request: ${url}`);
112115
});

‎ui/packages/app-shell/src/console/AppNoAccessEmptyState.tsx‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ import { useObjectTranslation } from '@object-ui/i18n';
5555
import { useServedAppLabel } from '../hooks/useServedAppLabel.js';
5656
import { useCanAuthorMetadata } from '../hooks/useCanAuthorMetadata.js';
5757
import { studioHomePath } from '../views/studio-design/studioAddress.js';
58+
import { createAuthenticatedFetch } from '@object-ui/auth';
59+
60+
/** The console's authenticated fetch: the stored bearer token beside the session cookie. */
61+
function authFetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response> {
62+
return createAuthenticatedFetch()(input, init);
63+
}
5864

5965
export interface AppNoAccessEmptyStateProps {
6066
/** The active app, as the console's metadata list carries it (`_packageId` as served). */
@@ -95,7 +101,7 @@ function useStoredMenuEmpty(appName: string, packageId: string | null, ask: bool
95101
React.useEffect(() => {
96102
if (!ask || !packageId) return;
97103
let cancelled = false;
98-
fetch(`/api/v1/meta/app/${encodeURIComponent(appName)}/layers?package=${encodeURIComponent(packageId)}`, {
104+
authFetch(`/api/v1/meta/app/${encodeURIComponent(appName)}/layers?package=${encodeURIComponent(packageId)}`, {
99105
credentials: 'include',
100106
headers: { Accept: 'application/json' },
101107
cache: 'no-store',

0 commit comments

Comments
 (0)