Files
orca/mobile/src/host-route-action-state.ts
T
Brennan Benson f6d0bde6fb fix(mobile): choose host for new workspace (#11647)
* fix(mobile): choose host for new workspace

* fix(mobile): close stale workspace host picker

* fix(mobile): disambiguate workspace host choices

* fix(mobile): keep host endpoint paths private

* fix(mobile): redact invalid host endpoints

* fix(mobile): handle opaque host endpoints

* fix(mobile): announce host picker options

* fix(mobile): harden workspace host picker

* fix(mobile): preserve host through workspace creation
2026-08-06 11:15:36 -07:00

50 lines
1.3 KiB
TypeScript

export type HostRouteActionState = {
routeAction: string | undefined
showNewWorktree: boolean
}
export function hostNewWorktreeRoute(hostId: string): `/h/${string}?action=newWorktree` {
return `/h/${encodeURIComponent(hostId)}?action=newWorktree`
}
export function hostNewWorktreeSessionRoute(
hostId: string,
worktreeId: string,
worktreeName: string
): `/h/${string}/session/${string}?${string}` {
const params = new URLSearchParams({ name: worktreeName, created: '1' })
return `/h/${encodeURIComponent(hostId)}/session/${encodeURIComponent(worktreeId)}?${params}`
}
export function createInitialHostRouteActionState(
routeAction: string | undefined
): HostRouteActionState {
return {
routeAction,
showNewWorktree: routeAction === 'newWorktree'
}
}
export function resolveHostRouteActionState(
current: HostRouteActionState,
routeAction: string | undefined
): HostRouteActionState {
if (current.routeAction === routeAction) {
return current
}
return {
routeAction,
showNewWorktree: current.showNewWorktree || routeAction === 'newWorktree'
}
}
export function setHostRouteNewWorktreeVisible(
current: HostRouteActionState,
showNewWorktree: boolean
): HostRouteActionState {
if (current.showNewWorktree === showNewWorktree) {
return current
}
return { ...current, showNewWorktree }
}