diff --git a/mobile/.oxlintrc.json b/mobile/.oxlintrc.json
index 5b0c202ea..b4b5ef57f 100644
--- a/mobile/.oxlintrc.json
+++ b/mobile/.oxlintrc.json
@@ -28,19 +28,19 @@
{
"files": ["src/terminal/TerminalWebView.tsx"],
"rules": {
- "max-lines": ["error", { "max": 369, "skipBlankLines": true, "skipComments": true }]
+ "max-lines": ["error", { "max": 379, "skipBlankLines": true, "skipComments": true }]
}
},
{
"files": ["src/terminal/terminal-webview-html.ts"],
"rules": {
- "max-lines": ["error", { "max": 1773, "skipBlankLines": true, "skipComments": true }]
+ "max-lines": ["error", { "max": 1778, "skipBlankLines": true, "skipComments": true }]
}
},
{
"files": ["app/h/*/source-control/*.tsx"],
"rules": {
- "max-lines": ["error", { "max": 2004, "skipBlankLines": true, "skipComments": true }]
+ "max-lines": ["error", { "max": 2152, "skipBlankLines": true, "skipComments": true }]
}
},
{
@@ -58,7 +58,7 @@
{
"files": ["app/index.tsx"],
"rules": {
- "max-lines": ["error", { "max": 1419, "skipBlankLines": true, "skipComments": true }]
+ "max-lines": ["error", { "max": 1422, "skipBlankLines": true, "skipComments": true }]
}
},
{
diff --git a/mobile/app.json b/mobile/app.json
index 1381fc041..211bb7703 100644
--- a/mobile/app.json
+++ b/mobile/app.json
@@ -2,7 +2,7 @@
"expo": {
"name": "Orca",
"slug": "orca-mobile",
- "version": "0.0.13",
+ "version": "0.0.14",
"orientation": "default",
"icon": "./assets/icon.png",
"userInterfaceStyle": "automatic",
@@ -16,10 +16,11 @@
"ios": {
"supportsTablet": true,
"bundleIdentifier": "com.stably.orca.mobile",
- "buildNumber": "2",
+ "buildNumber": "1",
"infoPlist": {
"NSLocalNetworkUsageDescription": "Orca connects to the desktop app on your local network.",
"NSMicrophoneUsageDescription": "Allow Orca to record voice dictation and transcribe it on your paired desktop.",
+ "NSPhotoLibraryUsageDescription": "Allow Orca to attach photos from your library to a terminal session on your paired desktop.",
"NSAppTransportSecurity": {
"NSAllowsLocalNetworking": true,
"NSExceptionDomains": {
@@ -94,6 +95,12 @@
"recordAudioAndroid": false
}
],
+ [
+ "expo-image-picker",
+ {
+ "photosPermission": "Allow Orca to attach photos from your library to a terminal session on your paired desktop."
+ }
+ ],
[
"expo-build-properties",
{
diff --git a/mobile/app/_layout.tsx b/mobile/app/_layout.tsx
index 4572790c9..bb4042157 100644
--- a/mobile/app/_layout.tsx
+++ b/mobile/app/_layout.tsx
@@ -165,6 +165,7 @@ export default function RootLayout() {
+
diff --git a/mobile/app/h/[hostId]/history/[worktreeId].tsx b/mobile/app/h/[hostId]/history/[worktreeId].tsx
new file mode 100644
index 000000000..8ac0eb8a8
--- /dev/null
+++ b/mobile/app/h/[hostId]/history/[worktreeId].tsx
@@ -0,0 +1,207 @@
+import { useCallback, useEffect, useState } from 'react'
+import { ActivityIndicator, FlatList, Pressable, StyleSheet, Text, View } from 'react-native'
+import { SafeAreaView, useSafeAreaInsets } from 'react-native-safe-area-context'
+import { useLocalSearchParams, useRouter } from 'expo-router'
+import { ChevronDown, ChevronLeft, ChevronRight } from 'lucide-react-native'
+import { useHostClient } from '../../../../src/transport/client-context'
+import type { RpcSuccess } from '../../../../src/transport/types'
+import { colors, spacing, typography } from '../../../../src/theme/mobile-theme'
+import {
+ fetchMobileGitHistory,
+ mapMobileCommitRows,
+ type MobileCommitRow
+} from '../../../../src/source-control/mobile-git-history'
+import type { GitBranchChangeEntry } from '../../../../../src/shared/types'
+
+function firstParam(value: string | string[] | undefined): string {
+ return Array.isArray(value) ? (value[0] ?? '') : (value ?? '')
+}
+
+export default function HistoryScreen() {
+ const params = useLocalSearchParams<{
+ hostId?: string | string[]
+ worktreeId?: string | string[]
+ }>()
+ const hostId = firstParam(params.hostId)
+ const worktreeId = firstParam(params.worktreeId)
+ const router = useRouter()
+ const insets = useSafeAreaInsets()
+ const { client, state: connState } = useHostClient(hostId)
+
+ const [rows, setRows] = useState(null)
+ const [error, setError] = useState(null)
+ const [expanded, setExpanded] = useState(null)
+ const [filesById, setFilesById] = useState>({})
+
+ useEffect(() => {
+ let active = true
+ if (!client || connState !== 'connected' || !worktreeId) {
+ return
+ }
+ // Reset prior error/rows so a successful retry doesn't stay stuck behind a
+ // stale error (error wins render precedence).
+ setError(null)
+ setRows(null)
+ void (async () => {
+ try {
+ const result = await fetchMobileGitHistory(client, worktreeId)
+ if (active) {
+ setRows(mapMobileCommitRows(result, Date.now()))
+ }
+ } catch (err) {
+ if (active) {
+ setError(err instanceof Error ? err.message : 'Failed to load history')
+ }
+ }
+ })()
+ return () => {
+ active = false
+ }
+ }, [client, connState, worktreeId])
+
+ const toggleCommit = useCallback(
+ (row: MobileCommitRow) => {
+ const next = expanded === row.id ? null : row.id
+ setExpanded(next)
+ if (next && client && !filesById[row.id]) {
+ setFilesById((prev) => ({ ...prev, [row.id]: 'loading' }))
+ void client
+ .sendRequest('git.commitCompare', { worktree: `id:${worktreeId}`, commitId: row.id })
+ .then((response) => {
+ const entries = response.ok
+ ? ((response as RpcSuccess).result as { entries: GitBranchChangeEntry[] }).entries
+ : []
+ setFilesById((prev) => ({ ...prev, [row.id]: entries }))
+ })
+ .catch(() => setFilesById((prev) => ({ ...prev, [row.id]: [] })))
+ }
+ },
+ [client, expanded, filesById, worktreeId]
+ )
+
+ const renderCommit = useCallback(
+ ({ item }: { item: MobileCommitRow }) => {
+ const files = filesById[item.id]
+ const isOpen = expanded === item.id
+ return (
+
+ [styles.commitHeader, pressed && styles.commitHeaderPressed]}
+ onPress={() => toggleCommit(item)}
+ >
+ {isOpen ? (
+
+ ) : (
+
+ )}
+
+
+ {item.subject}
+
+
+ {item.shortId} · {item.author} · {item.relativeTime}
+
+
+
+ {isOpen ? (
+
+ {files === 'loading' || files === undefined ? (
+
+ ) : files.length === 0 ? (
+ No file changes
+ ) : (
+ files.map((file) => (
+
+
+ {file.path}
+
+
+ {file.added ? +{file.added} : null}
+ {file.removed ? -{file.removed} : null}
+
+
+ ))
+ )}
+
+ ) : null}
+
+ )
+ },
+ [expanded, filesById, toggleCommit]
+ )
+
+ return (
+
+
+ router.back()} accessibilityLabel="Back">
+
+
+ Commit History
+
+ {error ? (
+
+ {error}
+
+ ) : rows === null ? (
+
+
+
+ ) : rows.length === 0 ? (
+
+ No commits.
+
+ ) : (
+ row.id}
+ contentContainerStyle={{ paddingBottom: spacing.lg + insets.bottom }}
+ />
+ )}
+
+ )
+}
+
+const styles = StyleSheet.create({
+ container: { flex: 1, backgroundColor: colors.bgBase },
+ header: {
+ flexDirection: 'row',
+ alignItems: 'center',
+ paddingHorizontal: spacing.md,
+ paddingVertical: spacing.sm,
+ gap: spacing.sm
+ },
+ back: { padding: spacing.xs },
+ title: { color: colors.textPrimary, fontSize: typography.bodySize, fontWeight: '600' },
+ state: { flex: 1, alignItems: 'center', justifyContent: 'center', padding: spacing.lg },
+ stateText: { color: colors.textMuted, fontSize: typography.bodySize },
+ commit: { borderBottomWidth: 1, borderBottomColor: colors.borderSubtle },
+ commitHeader: {
+ flexDirection: 'row',
+ alignItems: 'center',
+ gap: spacing.sm,
+ paddingHorizontal: spacing.md,
+ paddingVertical: spacing.sm + 2
+ },
+ commitHeaderPressed: { backgroundColor: colors.bgRaised },
+ commitMain: { flex: 1, minWidth: 0 },
+ commitSubject: { color: colors.textPrimary, fontSize: typography.bodySize },
+ commitMeta: {
+ color: colors.textMuted,
+ fontSize: typography.metaSize,
+ fontFamily: typography.monoFamily,
+ marginTop: 2
+ },
+ files: { paddingHorizontal: spacing.lg, paddingBottom: spacing.sm, gap: 4 },
+ fileRow: { flexDirection: 'row', alignItems: 'center', gap: spacing.sm },
+ filePath: {
+ flex: 1,
+ color: colors.textSecondary,
+ fontSize: typography.metaSize,
+ fontFamily: typography.monoFamily
+ },
+ fileStat: { fontSize: typography.metaSize, fontFamily: typography.monoFamily },
+ add: { color: colors.gitDecorationAdded },
+ del: { color: colors.gitDecorationDeleted },
+ empty: { color: colors.textMuted, fontSize: typography.metaSize }
+})
diff --git a/mobile/app/h/[hostId]/index.tsx b/mobile/app/h/[hostId]/index.tsx
index e271c64a2..3ee2c1cbb 100644
--- a/mobile/app/h/[hostId]/index.tsx
+++ b/mobile/app/h/[hostId]/index.tsx
@@ -14,9 +14,7 @@ import {
Search,
X,
Pin,
- Bell,
GitBranch,
- GitPullRequest,
List,
SlidersHorizontal,
Layers,
@@ -43,10 +41,13 @@ import {
type ConnectionVerdict
} from '../../../src/transport/connection-health'
import type { RpcSuccess } from '../../../src/transport/types'
-import { triggerMediumImpact } from '../../../src/platform/haptics'
import { StatusDot } from '../../../src/components/StatusDot'
import { NewWorktreeModal } from '../../../src/components/NewWorktreeModal'
-import { AgentSpinner } from '../../../src/components/AgentSpinner'
+import { MobileRepoIcon } from '../../../src/components/MobileRepoIcon'
+import { WorktreeListRow } from '../../../src/components/WorktreeListRow'
+import { useNow } from '../../../src/hooks/use-now'
+import { useActiveWorktreeScroll } from '../../../src/hooks/use-active-worktree-scroll'
+import type { RepoIcon } from '../../../../src/shared/repo-icon'
import { PickerModal, type PickerOption } from '../../../src/components/PickerModal'
import { ActionSheetContent } from '../../../src/components/ActionSheetModal'
import { ConfirmModal } from '../../../src/components/ConfirmModal'
@@ -57,17 +58,27 @@ import { getCachedWorktrees } from '../../../src/cache/worktree-cache'
import { colors, radii, spacing, typography } from '../../../src/theme/mobile-theme'
import { useResponsiveLayout } from '../../../src/layout/responsive-layout'
import { evaluateCompat, type CompatVerdict } from '../../../src/transport/protocol-compat'
-import {
- loadPinnedIds,
- savePinnedIds,
- loadPreferences,
- savePreferences
-} from '../../../src/storage/preferences'
+import { loadPinnedIds, savePinnedIds } from '../../../src/storage/preferences'
import {
createInitialHostRouteActionState,
resolveHostRouteActionState,
setHostRouteNewWorktreeVisible
} from '../../../src/host-route-action-state'
+import {
+ applyDesktopViewSettings,
+ groupModeToDesktop,
+ type MobileGroupMode,
+ type MobileSortMode,
+ type MobileViewState,
+ type WorkspaceViewSettings
+} from '../../../src/worktree/workspace-view-settings'
+import {
+ buildSections,
+ getWorktreeStatus,
+ isWorktreePinned,
+ type FilterState,
+ type Worktree
+} from '../../../src/worktree/workspace-list-sections'
// Why: locally-typed subset of the desktop's RuntimeStatus we read from
// `status.get`. Only the version fields matter to mobile today; everything
@@ -78,268 +89,34 @@ type DesktopStatus = {
minCompatibleMobileVersion?: number
}
-type Worktree = {
- worktreeId: string
- repo: string
- branch: string
- displayName: string
- // Why: on-disk worktree directory path. Needed by NewWorktreeModal so the
- // marine-creature fallback dedupes against the actual filesystem basenames
- // (matching the desktop's collision check), not against displayName which
- // the user may have renamed.
- path: string
- liveTerminalCount: number
- hasAttachedPty: boolean
- preview: string
- unread: boolean
- lastOutputAt?: number
- isPinned: boolean
- linkedPR: { number: number; state: string } | null
- status?: 'working' | 'active' | 'permission' | 'done' | 'inactive'
-}
-
+// repo.list response item — captures id (desktop filter key) plus the visual
+// metadata keyed by displayName the section headers/rows already use.
type RepoSummary = {
+ id: string
displayName: string
badgeColor?: string
-}
-
-type SortMode = 'smart' | 'name' | 'recent' | 'repo'
-type _FilterMode = 'all' | 'active'
-type GroupMode = 'none' | 'workspaceStatus' | 'repo' | 'prStatus'
-
-type FilterState = {
- activeOnly: boolean
- selectedRepos: Set
+ repoIcon?: RepoIcon | null
}
function isErrorVerdict(v: ConnectionVerdict): boolean {
return v.kind === 'warning' || v.kind === 'unreachable' || v.kind === 'auth-failed'
}
-const SORT_OPTIONS: PickerOption[] = [
+const SORT_OPTIONS: PickerOption[] = [
{ value: 'smart', label: 'Smart', subtitle: 'Unread and active first' },
{ value: 'name', label: 'Name', subtitle: 'Alphabetical by name' },
{ value: 'recent', label: 'Recent', subtitle: 'Most recent output first' },
- { value: 'repo', label: 'Repo', subtitle: 'Repository, then workspace name' }
+ { value: 'repo', label: 'Repo', subtitle: 'Repository, then workspace name' },
+ { value: 'manual', label: 'Manual', subtitle: 'Server order' }
]
-const GROUP_OPTIONS: PickerOption[] = [
+const GROUP_OPTIONS: PickerOption[] = [
{ value: 'none', label: 'No Grouping' },
{ value: 'workspaceStatus', label: 'Status' },
{ value: 'repo', label: 'Repository' },
{ value: 'prStatus', label: 'PR Status' }
]
-function getWorktreeStatus(w: Worktree): 'working' | 'active' | 'permission' | 'done' | 'inactive' {
- if (w.status) {
- return w.status
- }
- if (w.liveTerminalCount > 0) {
- return 'active'
- }
- return 'inactive'
-}
-
-// Why: the previous 10-minute lastOutputAt window was too strict — most
-// worktrees with idle terminal prompts had no recent output and were excluded.
-// Any worktree with live terminals or unread output counts as "active".
-function isWorktreeActive(w: Worktree): boolean {
- if (w.unread) {
- return true
- }
- if (w.status) {
- return w.status !== 'inactive'
- }
- if (w.liveTerminalCount > 0) {
- return true
- }
- return false
-}
-
-const WORKSPACE_STATUS_LABELS: Record, string> = {
- permission: 'Needs Permission',
- working: 'Working',
- done: 'Done',
- active: 'Active',
- inactive: 'Inactive'
-}
-
-const WORKSPACE_STATUS_ORDER: ReturnType[] = [
- 'permission',
- 'working',
- 'done',
- 'active',
- 'inactive'
-]
-
-function sortWorktrees(worktrees: Worktree[], mode: SortMode): Worktree[] {
- return [...worktrees].sort((a, b) => {
- if (mode === 'name') {
- return (a.displayName || a.repo).localeCompare(b.displayName || b.repo)
- }
- if (mode === 'recent') {
- return (b.lastOutputAt ?? 0) - (a.lastOutputAt ?? 0)
- }
- if (mode === 'repo') {
- const repoComparison = a.repo.localeCompare(b.repo, undefined, { sensitivity: 'base' })
- return repoComparison || (a.displayName || a.repo).localeCompare(b.displayName || b.repo)
- }
- // 'smart' — attention-first
- if (a.unread !== b.unread) {
- return a.unread ? -1 : 1
- }
- const aStatus = getWorktreeStatus(a)
- const bStatus = getWorktreeStatus(b)
- const statusOrder = { permission: 0, working: 1, done: 2, active: 3, inactive: 4 }
- if (statusOrder[aStatus] !== statusOrder[bStatus]) {
- return statusOrder[aStatus] - statusOrder[bStatus]
- }
- if ((a.lastOutputAt ?? 0) !== (b.lastOutputAt ?? 0)) {
- return (b.lastOutputAt ?? 0) - (a.lastOutputAt ?? 0)
- }
- return (a.displayName || a.repo).localeCompare(b.displayName || b.repo)
- })
-}
-
-function filterWorktrees(worktrees: Worktree[], filters: FilterState, search: string): Worktree[] {
- let result = worktrees
- if (filters.activeOnly) {
- result = result.filter(isWorktreeActive)
- }
- if (filters.selectedRepos.size > 0) {
- result = result.filter((w) => filters.selectedRepos.has(w.repo))
- }
- if (search.trim()) {
- const q = search.toLowerCase()
- result = result.filter(
- (w) =>
- (w.displayName || w.repo).toLowerCase().includes(q) ||
- w.branch.toLowerCase().includes(q) ||
- w.repo.toLowerCase().includes(q)
- )
- }
- return result
-}
-
-type Section = { title: string; icon?: 'pin'; data: Worktree[] }
-
-// Why: matches desktop's PR_GROUP_META naming from worktree-list-groups.ts.
-// no PR/draft/unknown → "In Progress", open → "In Review", merged → "Done", closed → "Closed"
-type PRGroupKey = 'done' | 'in-review' | 'in-progress' | 'closed'
-
-const PR_GROUP_LABELS: Record = {
- done: 'Done',
- 'in-review': 'In Review',
- 'in-progress': 'In Progress',
- closed: 'Closed'
-}
-
-const PR_GROUP_ORDER: PRGroupKey[] = ['done', 'in-review', 'in-progress', 'closed']
-
-function getPRGroupKey(w: Worktree): PRGroupKey {
- if (!w.linkedPR) {
- return 'in-progress'
- }
- const s = w.linkedPR.state.toLowerCase()
- if (s === 'merged') {
- return 'done'
- }
- if (s === 'closed') {
- return 'closed'
- }
- if (s === 'draft') {
- return 'in-progress'
- }
- return 'in-review'
-}
-
-function isWorktreePinned(w: Worktree, localPins: Set): boolean {
- return w.isPinned || localPins.has(w.worktreeId)
-}
-
-function buildSections(
- worktrees: Worktree[],
- sortMode: SortMode,
- filters: FilterState,
- search: string,
- groupMode: GroupMode,
- pinnedIds: Set
-): Section[] {
- const filtered = filterWorktrees(worktrees, filters, search)
- const sorted = sortWorktrees(filtered, sortMode)
-
- const pinned = sorted.filter((w) => isWorktreePinned(w, pinnedIds))
- const unpinned = sorted.filter((w) => !isWorktreePinned(w, pinnedIds))
- const active = unpinned.filter(isWorktreeActive)
- const inactive = unpinned.filter((w) => !isWorktreeActive(w))
-
- const sections: Section[] = []
- if (pinned.length > 0) {
- sections.push({ title: 'Pinned', icon: 'pin', data: pinned })
- }
-
- if (groupMode === 'none') {
- if (active.length > 0) {
- // Why: without explicit grouping, mobile's primary workflow is jumping
- // back into running sessions before browsing the full worktree archive.
- sections.push({ title: 'Active', data: active })
- }
- if (inactive.length > 0) {
- sections.push({ title: pinned.length > 0 || active.length > 0 ? 'All' : '', data: inactive })
- }
- } else if (groupMode === 'repo') {
- const byRepo = new Map()
- for (const w of unpinned) {
- const key = w.repo || 'Unknown'
- const list = byRepo.get(key)
- if (list) {
- list.push(w)
- } else {
- byRepo.set(key, [w])
- }
- }
- for (const [repo, items] of byRepo) {
- sections.push({ title: repo, data: items })
- }
- } else if (groupMode === 'workspaceStatus') {
- const byStatus = new Map, Worktree[]>()
- for (const w of unpinned) {
- const key = getWorktreeStatus(w)
- const list = byStatus.get(key)
- if (list) {
- list.push(w)
- } else {
- byStatus.set(key, [w])
- }
- }
- for (const status of WORKSPACE_STATUS_ORDER) {
- const items = byStatus.get(status)
- if (items && items.length > 0) {
- sections.push({ title: WORKSPACE_STATUS_LABELS[status], data: items })
- }
- }
- } else if (groupMode === 'prStatus') {
- const byGroup = new Map()
- for (const w of unpinned) {
- const key = getPRGroupKey(w)
- const list = byGroup.get(key)
- if (list) {
- list.push(w)
- } else {
- byGroup.set(key, [w])
- }
- }
- for (const groupKey of PR_GROUP_ORDER) {
- const items = byGroup.get(groupKey)
- if (items && items.length > 0) {
- sections.push({ title: PR_GROUP_LABELS[groupKey], data: items })
- }
- }
- }
-
- return sections
-}
-
export default function HostScreen() {
const { hostId, action } = useLocalSearchParams<{ hostId: string; action?: string }>()
const router = useRouter()
@@ -360,19 +137,31 @@ export default function HostScreen() {
const forceReconnectHost = useForceReconnect()
const [worktrees, setWorktrees] = useState(initialCache ?? [])
const [worktreesLoaded, setWorktreesLoaded] = useState(initialCache != null)
+ // Why: opening a worktree activates it on the host, but the active-row
+ // highlight otherwise waits for the next worktree.ps poll to reflect it.
+ // Track the locally-opened worktree so the highlight moves instantly.
+ const [optimisticActiveWorktreeId, setOptimisticActiveWorktreeId] = useState(null)
+ // One tick drives every visible agent row's relative timestamp.
+ const now = useNow(30_000)
const [repoColorsByName, setRepoColorsByName] = useState