state save + settings

This commit is contained in:
Neil
2026-03-18 18:01:23 -07:00
parent 4cadfaa031
commit 8446d25440
18 changed files with 1029 additions and 300 deletions
+28 -2
View File
@@ -1,4 +1,9 @@
import type { GlobalSettings, PersistedState } from './types'
import type {
GlobalSettings,
PersistedState,
RepoHookSettings,
WorkspaceSessionState
} from './types'
export const SCHEMA_VERSION = 1
@@ -25,6 +30,16 @@ export function getDefaultSettings(homedir: string): GlobalSettings {
}
}
export function getDefaultRepoHookSettings(): RepoHookSettings {
return {
mode: 'auto',
scripts: {
setup: '',
archive: ''
}
}
}
export function getDefaultPersistedState(homedir: string): PersistedState {
return {
schemaVersion: SCHEMA_VERSION,
@@ -36,6 +51,17 @@ export function getDefaultPersistedState(homedir: string): PersistedState {
lastActiveWorktreeId: null,
sidebarWidth: 280
},
githubCache: { pr: {}, issue: {} }
githubCache: { pr: {}, issue: {} },
workspaceSession: getDefaultWorkspaceSession()
}
}
export function getDefaultWorkspaceSession(): WorkspaceSessionState {
return {
activeRepoId: null,
activeWorktreeId: null,
activeTabId: null,
tabsByWorktree: {},
terminalLayoutsByTabId: {}
}
}
+38
View File
@@ -5,6 +5,7 @@ export interface Repo {
displayName: string
badgeColor: string
addedAt: number
hookSettings?: RepoHookSettings
}
// ─── Worktree (git-level) ────────────────────────────────────────────
@@ -51,6 +52,34 @@ export interface TerminalTab {
createdAt: number
}
export type TerminalPaneSplitDirection = 'vertical' | 'horizontal'
export type TerminalPaneLayoutNode =
| {
type: 'leaf'
leafId: string
}
| {
type: 'split'
direction: TerminalPaneSplitDirection
first: TerminalPaneLayoutNode
second: TerminalPaneLayoutNode
}
export interface TerminalLayoutSnapshot {
root: TerminalPaneLayoutNode | null
activeLeafId: string | null
expandedLeafId: string | null
}
export interface WorkspaceSessionState {
activeRepoId: string | null
activeWorktreeId: string | null
activeTabId: string | null
tabsByWorktree: Record<string, TerminalTab[]>
terminalLayoutsByTabId: Record<string, TerminalLayoutSnapshot>
}
// ─── GitHub ──────────────────────────────────────────────────────────
export type PRState = 'open' | 'closed' | 'merged' | 'draft'
export type IssueState = 'open' | 'closed'
@@ -81,6 +110,14 @@ export interface OrcaHooks {
}
}
export interface RepoHookSettings {
mode: 'auto' | 'override'
scripts: {
setup: string
archive: string
}
}
// ─── Settings ────────────────────────────────────────────────────────
export interface GlobalSettings {
workspaceDir: string
@@ -107,4 +144,5 @@ export interface PersistedState {
pr: Record<string, { data: PRInfo | null; fetchedAt: number }>
issue: Record<string, { data: IssueInfo | null; fetchedAt: number }>
}
workspaceSession: WorkspaceSessionState
}