Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
c6b38da
fix(app-shell,console): route the cookie-only same-server reads and w…
claude Nov 24, 2026
4ba5b1e
test(app-shell): pin the bearer-only package list and the cookie-only…
claude Nov 24, 2026
54151e8
fix(app-shell): the page preview's record reads go through the authen…
claude Nov 24, 2026
3250593
test(app-shell): run the detector battery inside an async function (WIP)
claude Nov 24, 2026
8d613ff
test(app-shell): Response doubles carry headers, as the authenticated…
claude Nov 24, 2026
c41a911
test(app-shell,console): Response doubles carry headers (WIP, shard 2…
claude Nov 24, 2026
87234ce
test(app-shell): doubles move with the converted calls (WIP, shard 3 …
claude Nov 24, 2026
c207055
test(app-shell): doubles move with the converted calls (WIP, shard 4 …
claude Nov 24, 2026
72cebf2
test(app-shell,console): doubles move with the converted calls (WIP, …
claude Nov 24, 2026
25b9ce2
test(app-shell,console): doubles move with the converted calls (WIP, …
claude Nov 24, 2026
2d7fd8f
test(app-shell): the read-only posture double carries headers at its …
claude Nov 25, 2026
5e2d177
test(app-shell): the last doubles move with the converted calls (head…
claude Nov 25, 2026
3080a68
test(app-shell): type the narrowed trigger calls; the installed-row d…
claude Nov 25, 2026
5dde589
test(app-shell): the edited suites pay their dynamic lint/formula/plu…
claude Nov 25, 2026
3db4a10
Merge remote-tracking branch 'origin/main' into claude/issue-37080-be…
claude Nov 25, 2026
cff1b9d
test(app-shell): the four edited StudioDesignSurface suites pay the p…
claude Nov 25, 2026
e055596
test(app-shell): the palette suite's package-list double answers the …
claude Nov 25, 2026
48321c6
Merge remote-tracking branch 'origin/main' into claude/issue-37080-be…
claude Nov 25, 2026
4a990ef
chore(changeset): the bearer-read changesets name every converted doo…
claude Nov 25, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .changeset/37080-console-reads-bearer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@object-ui/console': patch
---

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

Clause-②: no
Metadata-protocol: none

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.
21 changes: 21 additions & 0 deletions .changeset/37080-shell-reads-bearer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
'@object-ui/app-shell': patch
---

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

Clause-②: no
Metadata-protocol: none

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.

They now send the token as well:

- 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;
- 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;
- drafts: the pending drafts, the unpublished-app bar, the draft changes panel and its flow checks, and the commit history with its revert;
- AI: the conversation list and conversations, the build-debug report, AI usage, and suggested bindings;
- the inbox bell, the approval feeds and a record's approvals, and changing a record's owner;
- 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.

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.
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,19 @@ function jsonResponse(body: unknown, status = 200): Response {
vi.mock('@object-ui/auth', async (importOriginal) => ({
...(await importOriginal<Record<string, unknown>>()),
useAuth: () => auth,
createAuthenticatedFetch: () => async () =>
jsonResponse({
authenticated: true,
userId: 'u1',
systemPermissions: ['studio.access'],
objects: {},
fields: {},
}),
// The Studio gate's permissions read answers here; every other request (the
// package list included, which goes out through the authenticated fetch too)
// answers from the wire double each case stubs.
createAuthenticatedFetch: () => async (input: RequestInfo | URL, init?: RequestInit) =>
String(input).endsWith('/api/v1/auth/me/permissions')
? jsonResponse({
authenticated: true,
userId: 'u1',
systemPermissions: ['studio.access'],
objects: {},
fields: {},
})
: fetch(input, init),
}));

// `AuthGuard` reaches `useAuth` through the auth package's OWN module graph,
Expand Down
13 changes: 9 additions & 4 deletions ui/apps/console/src/pages/auth/DeviceAuthPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { useEffect, useState } from 'react';
import { Navigate, useLocation, useNavigate, useSearchParams } from 'react-router-dom';
import { CheckCircle2 } from 'lucide-react';
import { toast } from 'sonner';
import { useAuth } from '@object-ui/auth';
import { createAuthenticatedFetch, useAuth } from '@object-ui/auth';
import { useObjectTranslation } from '@object-ui/i18n';
import { getProductName, getLogoUrl } from '@object-ui/app-shell';
import {
Expand All @@ -23,6 +23,11 @@ import {
CardTitle,
} from '@object-ui/components';

/** The console's authenticated fetch: the stored bearer token beside the session cookie. */
function authFetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response> {
return createAuthenticatedFetch()(input, init);
}

const AUTH_BASE = `${import.meta.env.VITE_SERVER_URL || ''}/api/v1/auth`;

function PageShell({ children }: { children: React.ReactNode }) {
Expand Down Expand Up @@ -200,7 +205,7 @@ export function DeviceAuthPage() {
// accept approve/deny — without it both return 400 "not been claimed
// by a verifying session". Idempotent, so claim right before acting.
const claimDevice = async () => {
await fetch(`${AUTH_BASE}/device?user_code=${encodeURIComponent(code)}`, {
await authFetch(`${AUTH_BASE}/device?user_code=${encodeURIComponent(code)}`, {
credentials: 'include',
}).catch(() => { /* approve below surfaces the real error */ });
};
Expand All @@ -210,7 +215,7 @@ export function DeviceAuthPage() {
setSubmitting(true);
try {
await claimDevice();
const res = await fetch(`${AUTH_BASE}/device/approve`, {
const res = await authFetch(`${AUTH_BASE}/device/approve`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
credentials: 'include',
Expand Down Expand Up @@ -250,7 +255,7 @@ export function DeviceAuthPage() {
setDenying(true);
try {
await claimDevice();
await fetch(`${AUTH_BASE}/device/deny`, {
await authFetch(`${AUTH_BASE}/device/deny`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
credentials: 'include',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ function stubKeysFailure(status: number, body: unknown) {
const url = String(input);
if (url.includes('/api/v1/discovery')) {
return {
ok: true,
headers: new Headers(), ok: true,
status: 200,
json: async () => ({ data: { routes: { mcp: '/api/v1/mcp' } } }),
};
}
return {
ok: status >= 200 && status < 300,
headers: new Headers(), ok: status >= 200 && status < 300,
status,
json: async () => body,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ interface KeysAnswer {
async function errorTextFor(keys: KeysAnswer): Promise<string> {
const fetchMock = vi.fn(async (url: unknown) => {
if (String(url).includes('/discovery')) {
return { ok: true, status: 200, json: async () => DISCOVERY } as unknown as Response;
return { headers: new Headers(), ok: true, status: 200, json: async () => DISCOVERY } as unknown as Response;
}
return {
ok: keys.status >= 200 && keys.status < 300,
headers: new Headers(), ok: keys.status >= 200 && keys.status < 300,
status: keys.status,
json: async () => {
if (!('body' in keys)) throw new SyntaxError('Unexpected token < in JSON at position 0');
Expand Down
10 changes: 8 additions & 2 deletions ui/apps/console/src/pages/developer/AgentConnectSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ import { useObjectTranslation } from '@object-ui/i18n';

import { SLOT, withSlots } from '../../lib/inlineSlots';
import { renderObjectStackSkill } from './objectstack-skill';
import { createAuthenticatedFetch } from '@object-ui/auth';

/** The console's authenticated fetch: the stored bearer token beside the session cookie. */
function authFetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response> {
return createAuthenticatedFetch()(input, init);
}

interface GeneratedKey {
id?: string;
Expand Down Expand Up @@ -109,7 +115,7 @@ export function AgentConnectSection() {
let cancelled = false;
(async () => {
try {
const res = await fetch('/api/v1/discovery', { credentials: 'include' });
const res = await authFetch('/api/v1/discovery', { credentials: 'include' });
const json = await res.json().catch(() => ({}));
const route: string | undefined = json?.data?.routes?.mcp ?? json?.routes?.mcp;
if (cancelled) return;
Expand All @@ -135,7 +141,7 @@ export function AgentConnectSection() {
setGenerating(true);
setError(null);
try {
const res = await fetch('/api/v1/keys', {
const res = await authFetch('/api/v1/keys', {
method: 'POST',
credentials: 'include',
headers: { 'content-type': 'application/json' },
Expand Down
8 changes: 7 additions & 1 deletion ui/apps/console/src/pages/developer/IntegrationsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ import { Terminal, Copy, Check, Plug, Database, KeyRound } from 'lucide-react';

import { AgentConnectSection } from './AgentConnectSection';
import { SLOT, withSlots } from '../../lib/inlineSlots';
import { createAuthenticatedFetch } from '@object-ui/auth';

/** The console's authenticated fetch: the stored bearer token beside the session cookie. */
function authFetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response> {
return createAuthenticatedFetch()(input, init);
}

interface ConsoleObjectMeta {
name: string;
Expand Down Expand Up @@ -101,7 +107,7 @@ function IntegrationsPageBody() {
let cancelled = false;
(async () => {
try {
const res = await fetch('/api/v1/meta/object', { credentials: 'include' });
const res = await authFetch('/api/v1/meta/object', { credentials: 'include' });
if (!res.ok) throw new Error(`meta/object ${res.status}`);
const json = await res.json();
const raw = (json?.data ?? json?.items ?? json ?? []) as Array<Record<string, unknown>>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ vi.mock('@object-ui/auth', async (importOriginal) => ({

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

/** `GET /api/v1/packages`: two app packages and a kernel one, in both served shapes. */
const PACKAGES_PAYLOAD = {
Expand Down Expand Up @@ -106,7 +109,7 @@ let fetchMock: ReturnType<typeof vi.fn>;
beforeEach(() => {
fetchMock = vi.fn(async (url: string) => {
if (String(url).endsWith('/api/v1/packages')) {
return { ok: true, status: 200, json: async () => PACKAGES_PAYLOAD };
return { headers: new Headers(), ok: true, status: 200, json: async () => PACKAGES_PAYLOAD };
}
throw new Error(`unexpected request: ${url}`);
});
Expand Down
8 changes: 7 additions & 1 deletion ui/packages/app-shell/src/console/AppNoAccessEmptyState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ import { useObjectTranslation } from '@object-ui/i18n';
import { useServedAppLabel } from '../hooks/useServedAppLabel.js';
import { useCanAuthorMetadata } from '../hooks/useCanAuthorMetadata.js';
import { studioHomePath } from '../views/studio-design/studioAddress.js';
import { createAuthenticatedFetch } from '@object-ui/auth';

/** The console's authenticated fetch: the stored bearer token beside the session cookie. */
function authFetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response> {
return createAuthenticatedFetch()(input, init);
}

export interface AppNoAccessEmptyStateProps {
/** The active app, as the console's metadata list carries it (`_packageId` as served). */
Expand Down Expand Up @@ -95,7 +101,7 @@ function useStoredMenuEmpty(appName: string, packageId: string | null, ask: bool
React.useEffect(() => {
if (!ask || !packageId) return;
let cancelled = false;
fetch(`/api/v1/meta/app/${encodeURIComponent(appName)}/layers?package=${encodeURIComponent(packageId)}`, {
authFetch(`/api/v1/meta/app/${encodeURIComponent(appName)}/layers?package=${encodeURIComponent(packageId)}`, {
credentials: 'include',
headers: { Accept: 'application/json' },
cache: 'no-store',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('BuildDebugDrawer', () => {
beforeEach(() => {
vi.stubGlobal(
'fetch',
vi.fn(async () => ({ ok: true, status: 200, json: async () => REPORT })),
vi.fn(async () => ({ headers: new Headers(), ok: true, status: 200, json: async () => REPORT })),
);
});
afterEach(() => {
Expand All @@ -60,10 +60,14 @@ describe('BuildDebugDrawer', () => {
});

it('hits the debug endpoint for the conversation', async () => {
const spy = vi.fn(async () => ({ ok: true, status: 200, json: async () => REPORT }));
const spy = vi.fn(async () => ({ headers: new Headers(), ok: true, status: 200, json: async () => REPORT }));
vi.stubGlobal('fetch', spy);
renderDrawer();
await screen.findByText(/Proposed but never applied/);
expect(spy).toHaveBeenCalledWith('/api/v1/ai/conversations/conv_x/debug', { credentials: 'include' });
// The authenticated fetch hands the wire a `Headers` (the bearer, when one is stored).
expect(spy).toHaveBeenCalledWith('/api/v1/ai/conversations/conv_x/debug', {
credentials: 'include',
headers: expect.any(Headers),
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ const SURFACES: Surface[] = [
{
name: 'BuildDebugDrawer — token count',
read: async (locale) => {
vi.stubGlobal('fetch', vi.fn(async () => ({ ok: true, status: 200, json: async () => REPORT })));
vi.stubGlobal('fetch', vi.fn(async () => ({ headers: new Headers(), ok: true, status: 200, json: async () => REPORT })));
render(session(locale, <BuildDebugDrawer apiBase="/api/v1/ai" conversationId="conv_x" open onOpenChange={() => {}} />));
const line = await screen.findByText(/tok/);
const text = line.textContent ?? '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ function answer(report: BuildDebugReport | null) {
'fetch',
vi.fn(async () =>
report
? { ok: true, status: 200, json: async () => report }
: { ok: false, status: 404, json: async () => ({}) },
? { headers: new Headers(), ok: true, status: 200, json: async () => report }
: { headers: new Headers(), ok: false, status: 404, json: async () => ({}) },
),
);
}
Expand Down
11 changes: 9 additions & 2 deletions ui/packages/app-shell/src/console/ai/buildDebugApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,16 @@
* This fetches the server-side reconciliation — agent-CLAIMED vs LIVE
* `sys_metadata` — so a signed-in admin can diagnose a build that "went wrong"
* from the browser, with no DB credentials. Mirrors `fetchConversation`'s
* same-origin cookie auth.
* same-origin cookie auth, and sends the stored bearer token beside it.
*/

import { createAuthenticatedFetch } from '@object-ui/auth';

/** The console's authenticated fetch: the stored bearer token beside the session cookie. */
function authFetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response> {
return createAuthenticatedFetch()(input, init);
}

export interface ArtifactRef {
type: string;
name: string;
Expand Down Expand Up @@ -77,7 +84,7 @@ export interface BuildDebugReport {
* empty state instead of throwing.
*/
export async function fetchBuildDebug(apiBase: string, conversationId: string): Promise<BuildDebugReport | null> {
const res = await fetch(`${apiBase}/conversations/${encodeURIComponent(conversationId)}/debug`, {
const res = await authFetch(`${apiBase}/conversations/${encodeURIComponent(conversationId)}/debug`, {
credentials: 'include',
});
if (res.status === 404 || res.status === 403 || res.status === 401) return null;
Expand Down
11 changes: 8 additions & 3 deletions ui/packages/app-shell/src/console/connect/ConnectAgentWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ import {
AlertCircle,
Sparkles,
} from 'lucide-react';
import { TokenStorage } from '@object-ui/auth';
import { createAuthenticatedFetch, TokenStorage } from '@object-ui/auth';
import { formatDateTime, useObjectTranslation } from '@object-ui/i18n';
import { ComponentRegistry } from '@object-ui/core';
import { notifyDataChanged } from '@object-ui/react';
Expand All @@ -104,6 +104,11 @@ import { AuthorizedAccessList } from './AuthorizedAccessList.js';
import { DeveloperNamespaceGate } from './DeveloperNamespaceGate.js';
import { useConnectedAccess, type ConnectedEntry } from './connectedAccess.js';

/** The console's authenticated fetch: the stored bearer token beside the session cookie. */
function authFetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response> {
return createAuthenticatedFetch()(input, init);
}

const SERVER_URL = (import.meta.env.VITE_SERVER_URL || '').replace(/\/$/, '');

/** Same-origin API calls need the Bearer token (see marketplaceApi.ts). */
Expand Down Expand Up @@ -295,7 +300,7 @@ function ConnectAgentBody() {
useEffect(() => {
(async () => {
try {
const res = await fetch(`${SERVER_URL}/api/v1/discovery`, { credentials: 'include' });
const res = await authFetch(`${SERVER_URL}/api/v1/discovery`, { credentials: 'include' });
const json = await res.json().catch(() => ({}));
const routes = (json?.data ?? json)?.routes ?? {};
setMcpUrl(typeof routes.mcp === 'string' ? absoluteUrl(routes.mcp) : null);
Expand Down Expand Up @@ -338,7 +343,7 @@ function ConnectAgentBody() {
setMinting(true);
setMintError(null);
try {
const res = await fetch(`${SERVER_URL}/api/v1/keys`, {
const res = await authFetch(`${SERVER_URL}/api/v1/keys`, {
method: 'POST',
credentials: 'include',
headers: withEnvAuth({ 'content-type': 'application/json' }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const DRAWN_IDS = NOTICE.findings.map((f) => f.id).filter((id) => id !== 'email_

const envelope = (data: unknown) => ({ success: true, data });
const json = (status: number, body: unknown) =>
({ ok: status >= 200 && status < 300, status, json: async () => body }) as unknown as Response;
({ headers: new Headers(), ok: status >= 200 && status < 300, status, json: async () => body }) as unknown as Response;

let fetchMock: ReturnType<typeof vi.fn>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
*/

import { bearerAuthHeaders } from '../../utils/authToken.js';
import { createAuthenticatedFetch } from '@object-ui/auth';

/** The console's authenticated fetch: the stored bearer token beside the session cookie. */
function authFetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response> {
return createAuthenticatedFetch()(input, init);
}

export type DeploymentFindingId =
| 'database_local_file'
Expand Down Expand Up @@ -91,7 +97,7 @@ export function parseDeploymentNotice(body: unknown): DeploymentNoticeState | nu

export async function fetchDeploymentNotice(): Promise<DeploymentNoticeState | null> {
try {
const res = await fetch(`${serverUrl()}${NOTICE_PATH}`, {
const res = await authFetch(`${serverUrl()}${NOTICE_PATH}`, {
credentials: 'include',
headers: { Accept: 'application/json', ...bearerAuthHeaders() },
});
Expand All @@ -107,7 +113,7 @@ export type HideAnswer = 'hidden' | 'no-audit-log' | 'changed' | 'failed';

export async function hideDeploymentNotice(fingerprint: string): Promise<HideAnswer> {
try {
const res = await fetch(`${serverUrl()}${NOTICE_PATH}/hide`, {
const res = await authFetch(`${serverUrl()}${NOTICE_PATH}/hide`, {
method: 'POST',
credentials: 'include',
headers: { 'Content-Type': 'application/json', Accept: 'application/json', ...bearerAuthHeaders() },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ beforeEach(() => {
vi.fn(async (input: unknown) => {
const url = String(input);
fetchCalls.push(url);
if (routeOf(url) === DRAFTS_ROUTE) return { ok: true, status: 200, json: async () => ({ drafts: DRAFTS }) };
return { ok: false, status: 404, json: async () => ({}) };
if (routeOf(url) === DRAFTS_ROUTE) return { headers: new Headers(), ok: true, status: 200, json: async () => ({ drafts: DRAFTS }) };
return { headers: new Headers(), ok: false, status: 404, json: async () => ({}) };
}),
);
});
Expand Down
Loading
Loading