@@ -96,6 +131,70 @@ export function GeneralPane({
+
+
+
Editor
+
Configure how Orca persists file edits.
+
+
+
+
+
+
+ Save editor and editable diff changes automatically after a short pause.
+
+
+
+
+
+
+
+
+
+ How long Orca waits after your last edit before saving automatically. First launch
+ defaults to {DEFAULT_EDITOR_AUTO_SAVE_DELAY_MS} ms.
+
+
+
+ setAutoSaveDelayDraft(e.target.value)}
+ onBlur={commitAutoSaveDelay}
+ onKeyDown={(e) => {
+ if (e.key === 'Enter') {
+ commitAutoSaveDelay()
+ }
+ }}
+ className="number-input-clean w-28 text-right tabular-nums"
+ />
+ ms
+
+
+
+
+
+
diff --git a/src/renderer/src/components/settings/Settings.tsx b/src/renderer/src/components/settings/Settings.tsx
index 80680746c..48624d065 100644
--- a/src/renderer/src/components/settings/Settings.tsx
+++ b/src/renderer/src/components/settings/Settings.tsx
@@ -185,7 +185,7 @@ function Settings(): React.JSX.Element {
const pageHeader = showGeneralPane ? (
General
-
Workspace, naming, and updates.
+
Workspace, editor, naming, and updates.
) : showAppearancePane ? (
diff --git a/src/renderer/src/components/terminal/useTerminalSaveDialog.ts b/src/renderer/src/components/terminal/useTerminalSaveDialog.ts
index 6fcdc2185..a55bb0b69 100644
--- a/src/renderer/src/components/terminal/useTerminalSaveDialog.ts
+++ b/src/renderer/src/components/terminal/useTerminalSaveDialog.ts
@@ -1,5 +1,6 @@
import { useCallback, useState } from 'react'
import type { OpenFile } from '@/store/slices/editor'
+import { requestEditorSaveQuiesce } from '@/components/editor/editor-autosave'
type UseTerminalSaveDialogParams = {
openFiles: OpenFile[]
@@ -50,11 +51,14 @@ export function useTerminalSaveDialog({
setSaveDialogFileId(null)
}, [saveDialogFileId])
- const handleSaveDialogDiscard = useCallback(() => {
+ const handleSaveDialogDiscard = useCallback(async () => {
if (!saveDialogFileId) {
return
}
+ // Why: "Don't Save" must win over any pending autosave write for the same
+ // tab, even if the editor is currently waiting on a background debounce.
+ await requestEditorSaveQuiesce({ fileId: saveDialogFileId })
markFileDirty(saveDialogFileId, false)
closeFile(saveDialogFileId)
setSaveDialogFileId(null)
diff --git a/src/renderer/src/lib/terminal-links.ts b/src/renderer/src/lib/terminal-links.ts
index 8e6ed7135..1e1ca0f73 100644
--- a/src/renderer/src/lib/terminal-links.ts
+++ b/src/renderer/src/lib/terminal-links.ts
@@ -220,7 +220,11 @@ export function resolveTerminalFileLink(
export function isPathInsideWorktree(filePath: string, worktreePath: string): boolean {
const normalizedFile = normalizeAbsolutePath(filePath)
const normalizedWorktree = normalizeAbsolutePath(worktreePath)
- if (!normalizedFile || !normalizedWorktree || normalizedFile.rootKind !== normalizedWorktree.rootKind) {
+ if (
+ !normalizedFile ||
+ !normalizedWorktree ||
+ normalizedFile.rootKind !== normalizedWorktree.rootKind
+ ) {
return false
}
if (normalizedFile.comparisonKey === normalizedWorktree.comparisonKey) {
@@ -232,7 +236,11 @@ export function isPathInsideWorktree(filePath: string, worktreePath: string): bo
export function toWorktreeRelativePath(filePath: string, worktreePath: string): string | null {
const normalizedFile = normalizeAbsolutePath(filePath)
const normalizedWorktree = normalizeAbsolutePath(worktreePath)
- if (!normalizedFile || !normalizedWorktree || normalizedFile.rootKind !== normalizedWorktree.rootKind) {
+ if (
+ !normalizedFile ||
+ !normalizedWorktree ||
+ normalizedFile.rootKind !== normalizedWorktree.rootKind
+ ) {
return null
}
if (normalizedFile.comparisonKey === normalizedWorktree.comparisonKey) {
diff --git a/src/shared/constants.ts b/src/shared/constants.ts
index fcfd8d6b3..29244e4e4 100644
--- a/src/shared/constants.ts
+++ b/src/shared/constants.ts
@@ -9,6 +9,9 @@ import type {
import { DEFAULT_TERMINAL_FONT_WEIGHT } from './terminal-fonts'
export const SCHEMA_VERSION = 1
+export const DEFAULT_EDITOR_AUTO_SAVE_DELAY_MS = 1000
+export const MIN_EDITOR_AUTO_SAVE_DELAY_MS = 250
+export const MAX_EDITOR_AUTO_SAVE_DELAY_MS = 10_000
export const DEFAULT_WORKTREE_CARD_PROPERTIES: WorktreeCardProperty[] = [
'status',
@@ -37,6 +40,8 @@ export function getDefaultSettings(homedir: string): GlobalSettings {
branchPrefix: 'git-username',
branchPrefixCustom: '',
theme: 'system',
+ editorAutoSave: false,
+ editorAutoSaveDelayMs: DEFAULT_EDITOR_AUTO_SAVE_DELAY_MS,
terminalFontSize: 14,
terminalFontFamily: 'SF Mono',
terminalFontWeight: DEFAULT_TERMINAL_FONT_WEIGHT,
diff --git a/src/shared/types.ts b/src/shared/types.ts
index cca936859..5e01d70b0 100644
--- a/src/shared/types.ts
+++ b/src/shared/types.ts
@@ -205,6 +205,8 @@ export type GlobalSettings = {
branchPrefix: 'git-username' | 'custom' | 'none'
branchPrefixCustom: string
theme: 'system' | 'dark' | 'light'
+ editorAutoSave: boolean
+ editorAutoSaveDelayMs: number
terminalFontSize: number
terminalFontFamily: string
terminalFontWeight: number