state save + settings
This commit is contained in:
+28
-2
@@ -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: {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user