From ff8a13adaf0b5fe7e3c150cdacfe095f31207629 Mon Sep 17 00:00:00 2001 From: Jinwoo-H Date: Tue, 1 Sep 2026 19:18:11 -0400 Subject: [PATCH] refactor(mobile): brand the host-side workspace and repo identifiers The authority now mints branded MobileWebHostWorkspaceId and MobileWebHostRepoId, so passing a page handle where a resolved host identifier belongs is a compile error. Reauthorization is the case that matters: assertHostWorkspaceBinding no longer accepts the page handle as its expected host value. Values the host itself reported go through two named boundary functions rather than a bare cast, so every such site is greppable. No runtime check changed. The page-side handles stay unbranded: branding MobileWebWorkspaceIdSchema alone produced 527 type errors across the page and shell, and six more handle types remain. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb --- .../mobile-web-markdown-operations.ts | 7 ++-- .../mobile-web-native-chat-authority.ts | 3 +- ...le-web-session-quick-command-operations.ts | 11 ++++--- .../mobile-web/mobile-web-session-snapshot.ts | 7 ++-- .../mobile-web-session-subscriptions.ts | 5 +-- ...le-web-workspace-authority-test-fixture.ts | 7 ++-- .../mobile-web-workspace-authority.ts | 33 +++++++++++++++---- ...eb-workspace-creation-create-operations.ts | 10 ++++-- 8 files changed, 61 insertions(+), 22 deletions(-) diff --git a/mobile/src/mobile-web/mobile-web-markdown-operations.ts b/mobile/src/mobile-web/mobile-web-markdown-operations.ts index 464ab323d31..c44d48c4207 100644 --- a/mobile/src/mobile-web/mobile-web-markdown-operations.ts +++ b/mobile/src/mobile-web/mobile-web-markdown-operations.ts @@ -20,7 +20,10 @@ import type { RpcClient } from '../transport/rpc-client' import type { RpcFailure } from '../transport/types' import { MobileWebBrokerError } from './mobile-web-broker-error' import type { MobileWebNativeCapabilityAuthority } from './mobile-web-native-capability-authority' -import type { MobileWebWorkspaceAuthority } from './mobile-web-workspace-authority' +import type { + MobileWebHostWorkspaceId, + MobileWebWorkspaceAuthority +} from './mobile-web-workspace-authority' type MarkdownOperationArgs = { operation: string @@ -102,7 +105,7 @@ export async function executeMobileWebMarkdownOperation( async function verifyMarkdownTarget( args: MarkdownOperationArgs, target: MarkdownTarget -): Promise { +): Promise { const hostWorkspaceId = args.workspaceAuthority.hostWorkspaceId(target.workspaceId) const response = await args.client.sendRequest('session.tabs.list', { worktree: `id:${hostWorkspaceId}` diff --git a/mobile/src/mobile-web/mobile-web-native-chat-authority.ts b/mobile/src/mobile-web/mobile-web-native-chat-authority.ts index 42c825519e8..061719c816e 100644 --- a/mobile/src/mobile-web/mobile-web-native-chat-authority.ts +++ b/mobile/src/mobile-web/mobile-web-native-chat-authority.ts @@ -1,8 +1,9 @@ +import type { MobileWebHostWorkspaceId } from './mobile-web-workspace-authority' import { MobileWebBrokerError } from './mobile-web-broker-error' import { MOBILE_WEB_NATIVE_CHAT_IMAGE_LIMIT } from '../../../src/shared/mobile-web/native-chat-operation-contract' export type MobileWebHostNativeChatBinding = { - hostWorkspaceId: string + hostWorkspaceId: MobileWebHostWorkspaceId hostTabId: string hostTerminalId: string | null agent: string diff --git a/mobile/src/mobile-web/mobile-web-session-quick-command-operations.ts b/mobile/src/mobile-web/mobile-web-session-quick-command-operations.ts index 647288642a4..e5591ab1be8 100644 --- a/mobile/src/mobile-web/mobile-web-session-quick-command-operations.ts +++ b/mobile/src/mobile-web/mobile-web-session-quick-command-operations.ts @@ -21,7 +21,10 @@ import { getRepoIdFromMobileWorktreeId } from '../session/mobile-session-route-h import { loadMobileNewTabAgentOptions } from '../session/mobile-new-tab-agent-loader' import type { RpcClient } from '../transport/rpc-client' import { MobileWebBrokerError } from './mobile-web-broker-error' -import type { MobileWebWorkspaceAuthority } from './mobile-web-workspace-authority' +import type { + MobileWebHostWorkspaceId, + MobileWebWorkspaceAuthority +} from './mobile-web-workspace-authority' export async function executeMobileWebSessionQuickCommandOperation(args: { operation: string @@ -99,7 +102,7 @@ async function readQuickCommands(client: RpcClient): Promise