From c09a2ee251e12ff5b16adb72253443d63734c985 Mon Sep 17 00:00:00 2001 From: Jinwoo Hong <73622457+Jinwoo-H@users.noreply.github.com> Date: Fri, 31 Jul 2026 20:42:05 -0700 Subject: [PATCH] fix(mobile): open resume workspace route reliably (#11876) Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com> --- mobile/app/index.tsx | 7 +++- .../src/session/mobile-session-route.test.ts | 35 +++++++++++++++++++ mobile/src/session/mobile-session-route.ts | 17 +++++++++ 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 mobile/src/session/mobile-session-route.test.ts create mode 100644 mobile/src/session/mobile-session-route.ts diff --git a/mobile/app/index.tsx b/mobile/app/index.tsx index 8a4a774b6..7670fec82 100644 --- a/mobile/app/index.tsx +++ b/mobile/app/index.tsx @@ -50,6 +50,7 @@ import { type TaskProvider } from '../src/tasks/mobile-task-providers' import { useResponsiveLayout } from '../src/layout/responsive-layout' +import { createMobileSessionHref } from '../src/session/mobile-session-route' function endpointLabel(endpoint: string): string { try { @@ -807,7 +808,11 @@ export default function HomeScreen() { style={({ pressed }) => [styles.resumeCard, pressed && styles.hostCardPressed]} onPress={() => router.push( - `/h/${resumeWorktree.hostId}/session/${encodeURIComponent(resumeWorktree.worktree.worktreeId)}` + createMobileSessionHref({ + hostId: resumeWorktree.hostId, + worktreeId: resumeWorktree.worktree.worktreeId, + name: resumeWorktree.worktree.displayName || resumeWorktree.worktree.repo + }) ) } > diff --git a/mobile/src/session/mobile-session-route.test.ts b/mobile/src/session/mobile-session-route.test.ts new file mode 100644 index 000000000..79b0c1264 --- /dev/null +++ b/mobile/src/session/mobile-session-route.test.ts @@ -0,0 +1,35 @@ +import { readFileSync } from 'node:fs' +import { describe, expect, it } from 'vitest' +import { createMobileSessionHref } from './mobile-session-route' + +const homeSource = readFileSync(new URL('../../app/index.tsx', import.meta.url), 'utf8') + +describe('mobile session route', () => { + it('keeps dynamic route identities raw for Expo Router to encode', () => { + expect( + createMobileSessionHref({ + hostId: 'host/one', + worktreeId: 'repo::/Users/ada/orca/workspaces/fix #1', + name: 'Fix #1' + }) + ).toEqual({ + pathname: '/h/[hostId]/session/[worktreeId]', + params: { + hostId: 'host/one', + worktreeId: 'repo::/Users/ada/orca/workspaces/fix #1', + name: 'Fix #1' + } + }) + }) + + it('routes the home Resume card through the typed dynamic href', () => { + const start = homeSource.indexOf('{/* ─── Resume card ─── */}') + const end = homeSource.indexOf('{/* ─── Quick actions ─── */}', start) + const resumeCard = homeSource.slice(start, end) + + expect(start).toBeGreaterThanOrEqual(0) + expect(end).toBeGreaterThan(start) + expect(resumeCard).toContain('createMobileSessionHref({') + expect(resumeCard).not.toContain('encodeURIComponent(resumeWorktree.worktree.worktreeId)') + }) +}) diff --git a/mobile/src/session/mobile-session-route.ts b/mobile/src/session/mobile-session-route.ts new file mode 100644 index 000000000..505e53bfb --- /dev/null +++ b/mobile/src/session/mobile-session-route.ts @@ -0,0 +1,17 @@ +export type MobileSessionRouteParams = { + hostId: string + worktreeId: string + name?: string +} + +export type MobileSessionHref = { + pathname: '/h/[hostId]/session/[worktreeId]' + params: MobileSessionRouteParams +} + +export function createMobileSessionHref(params: MobileSessionRouteParams): MobileSessionHref { + return { + pathname: '/h/[hostId]/session/[worktreeId]', + params + } +}