Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/editor/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { TableOfContents } from '@plannotator/ui/components/TableOfContents';
import { useSharing } from '@plannotator/ui/hooks/useSharing';
import { useAgents } from '@plannotator/ui/hooks/useAgents';
import { useActiveSection } from '@plannotator/ui/hooks/useActiveSection';
import { storage } from '@plannotator/ui/utils/storage';
import { storage, getAutoClose } from '@plannotator/ui/utils/storage';
import { UpdateBanner } from '@plannotator/ui/components/UpdateBanner';
import { getObsidianSettings, getEffectiveVaultPath, isObsidianConfigured, CUSTOM_PATH_SENTINEL } from '@plannotator/ui/utils/obsidian';
import { getBearSettings } from '@plannotator/ui/utils/bear';
Expand Down Expand Up @@ -570,6 +570,9 @@ const App: React.FC = () => {
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(body),
});
if (getAutoClose()) {
window.close();
}
setSubmitted('approved');
} catch {
setIsSubmitting(false);
Expand All @@ -591,6 +594,9 @@ const App: React.FC = () => {
},
})
});
if (getAutoClose()) {
window.close();
}
setSubmitted('denied');
} catch {
setIsSubmitting(false);
Expand Down
8 changes: 7 additions & 1 deletion packages/review-editor/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ModeToggle } from '@plannotator/ui/components/ModeToggle';
import { ConfirmDialog } from '@plannotator/ui/components/ConfirmDialog';
import { Settings } from '@plannotator/ui/components/Settings';
import { UpdateBanner } from '@plannotator/ui/components/UpdateBanner';
import { storage } from '@plannotator/ui/utils/storage';
import { storage, getAutoClose } from '@plannotator/ui/utils/storage';
import { getIdentity } from '@plannotator/ui/utils/identity';
import { getAgentSwitchSettings, getEffectiveAgentName } from '@plannotator/ui/utils/agentSwitch';
import { CodeAnnotation, CodeAnnotationType, SelectedLineRange, DiffAnnotationMetadata } from '@plannotator/ui/types';
Expand Down Expand Up @@ -415,6 +415,9 @@ const ReviewApp: React.FC = () => {
}),
});
if (res.ok) {
if (getAutoClose()) {
window.close();
}
setSubmitted('feedback');
} else {
throw new Error('Failed to send');
Expand All @@ -440,6 +443,9 @@ const ReviewApp: React.FC = () => {
}),
});
if (res.ok) {
if (getAutoClose()) {
window.close();
}
setSubmitted('approved');
} else {
throw new Error('Failed to send');
Expand Down
33 changes: 33 additions & 0 deletions packages/ui/components/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
PERMISSION_MODE_OPTIONS,
type PermissionMode,
} from '../utils/permissionMode';
import { getAutoClose, setAutoClose } from '../utils/storage';
import {
getDefaultNotesApp,
saveDefaultNotesApp,
Expand Down Expand Up @@ -71,6 +72,7 @@ export const Settings: React.FC<SettingsProps> = ({ taterMode, onTaterModeChange
const [uiPrefs, setUiPrefs] = useState<UIPreferences>({ tocEnabled: true, stickyActionsEnabled: true });
const [permissionMode, setPermissionMode] = useState<PermissionMode>('bypassPermissions');
const [agentWarning, setAgentWarning] = useState<string | null>(null);
const [autoClose, setAutoCloseState] = useState(false);
const [defaultNotesApp, setDefaultNotesApp] = useState<DefaultNotesApp>('ask');

// Fetch available agents for OpenCode
Expand All @@ -94,6 +96,7 @@ export const Settings: React.FC<SettingsProps> = ({ taterMode, onTaterModeChange
setPlanSave(getPlanSaveSettings());
setUiPrefs(getUIPreferences());
setPermissionMode(getPermissionModeSettings().mode);
setAutoCloseState(getAutoClose());
setDefaultNotesApp(getDefaultNotesApp());

// Validate agent setting when dialog opens
Expand Down Expand Up @@ -366,6 +369,36 @@ export const Settings: React.FC<SettingsProps> = ({ taterMode, onTaterModeChange
</div>
</>
)}

<div className="border-t border-border" />

{/* Auto-close Tab */}
<div className="flex items-center justify-between">
<div>
<div className="text-sm font-medium">Auto-close Tab</div>
<div className="text-xs text-muted-foreground">
Close browser tab after submitting
</div>
</div>
<button
role="switch"
aria-checked={autoClose}
onClick={() => {
const next = !autoClose;
setAutoCloseState(next);
setAutoClose(next);
}}
className={`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${
autoClose ? 'bg-primary' : 'bg-muted'
}`}
>
<span
className={`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${
autoClose ? 'translate-x-6' : 'translate-x-1'
}`}
/>
</button>
</div>
</>
)}

Expand Down
13 changes: 13 additions & 0 deletions packages/ui/utils/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,19 @@ function escapeRegex(str: string): string {
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
}

/**
* Auto-close tab setting
*/
const AUTO_CLOSE_KEY = 'plannotator-auto-close';

export function getAutoClose(): boolean {
return getItem(AUTO_CLOSE_KEY) === 'true';
}

export function setAutoClose(enabled: boolean): void {
setItem(AUTO_CLOSE_KEY, String(enabled));
}

/**
* Storage object with localStorage-like API
*/
Expand Down