mirror of
https://github.com/stablyai/orca.git
synced 2026-10-25 16:03:53 +00:00
* 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
50 lines
1.3 KiB
TypeScript
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 }
|
|
}
|