further improvements

This commit is contained in:
Alexis Purslane
2025-12-01 11:35:03 -05:00
parent aa0c31fa1e
commit c9c1f69b82
6 changed files with 35 additions and 5 deletions

1
.gitignore vendored
View File

@@ -6,3 +6,4 @@ release/
.vite/ .vite/
.electron-vite/ .electron-vite/
out/ out/
.dir-locals.el

View File

@@ -18,6 +18,7 @@ const PreferencesSchema = z.object({
toolOutputExpansion: z.enum(["expanded", "collapsed"]).default("expanded"), toolOutputExpansion: z.enum(["expanded", "collapsed"]).default("expanded"),
diagnosticsExpansion: z.enum(["expanded", "collapsed"]).default("expanded"), diagnosticsExpansion: z.enum(["expanded", "collapsed"]).default("expanded"),
showUsageMetrics: z.boolean().default(true), showUsageMetrics: z.boolean().default(true),
autoCleanupBlankSessions: z.boolean().default(true),
}) })
const RecentFolderSchema = z.object({ const RecentFolderSchema = z.object({

View File

@@ -47,6 +47,7 @@ const App: Component = () => {
preferences, preferences,
recordWorkspaceLaunch, recordWorkspaceLaunch,
toggleShowThinkingBlocks, toggleShowThinkingBlocks,
toggleAutoCleanupBlankSessions,
toggleUsageMetrics, toggleUsageMetrics,
setDiffViewMode, setDiffViewMode,
setToolOutputExpansion, setToolOutputExpansion,
@@ -206,6 +207,7 @@ const App: Component = () => {
const { commands: paletteCommands, executeCommand } = useCommands({ const { commands: paletteCommands, executeCommand } = useCommands({
preferences, preferences,
toggleAutoCleanupBlankSessions,
toggleShowThinkingBlocks, toggleShowThinkingBlocks,
toggleUsageMetrics, toggleUsageMetrics,
setDiffViewMode, setDiffViewMode,

View File

@@ -22,6 +22,7 @@ export interface UseCommandsOptions {
preferences: Accessor<Preferences> preferences: Accessor<Preferences>
toggleShowThinkingBlocks: () => void toggleShowThinkingBlocks: () => void
toggleUsageMetrics: () => void toggleUsageMetrics: () => void
toggleAutoCleanupBlankSessions: () => void
setDiffViewMode: (mode: "split" | "unified") => void setDiffViewMode: (mode: "split" | "unified") => void
setToolOutputExpansion: (mode: ExpansionPreference) => void setToolOutputExpansion: (mode: ExpansionPreference) => void
setDiagnosticsExpansion: (mode: ExpansionPreference) => void setDiagnosticsExpansion: (mode: ExpansionPreference) => void
@@ -145,10 +146,10 @@ export function useCommands(options: UseCommandsOptions) {
commandRegistry.register({ commandRegistry.register({
id: "cleanup-blank-sessions", id: "cleanup-blank-sessions",
label: "Cleanup Blank Sessions", label: "Scrub Sessions",
description: "Remove empty sessions from the current instance", description: "Remove empty sessions, subagent sessions that have completed their primary task, and extraneous forked sessions.",
category: "Session", category: "Session",
keywords: ["cleanup", "blank", "empty", "sessions", "remove", "delete"], keywords: ["cleanup", "blank", "empty", "sessions", "remove", "delete", "scrub"],
action: async () => { action: async () => {
const instance = activeInstance() const instance = activeInstance()
if (!instance) return if (!instance) return
@@ -481,6 +482,18 @@ export function useCommands(options: UseCommandsOptions) {
keywords: ["token", "usage", "cost", "stats"], keywords: ["token", "usage", "cost", "stats"],
action: options.toggleUsageMetrics, action: options.toggleUsageMetrics,
}) })
commandRegistry.register({
id: "auto-cleanup-blank-sessions",
label: () => {
const enabled = options.preferences().autoCleanupBlankSessions
return `Auto-Cleanup Blank Sessions · ${enabled ? "Enabled" : "Disabled"}`
},
description: "Automatically clean up blank sessions when creating new ones",
category: "System",
keywords: ["auto", "cleanup", "blank", "sessions", "toggle"],
action: options.toggleAutoCleanupBlankSessions,
})
commandRegistry.register({ commandRegistry.register({
id: "help", id: "help",

View File

@@ -37,6 +37,7 @@ export interface Preferences {
toolOutputExpansion: ExpansionPreference toolOutputExpansion: ExpansionPreference
diagnosticsExpansion: ExpansionPreference diagnosticsExpansion: ExpansionPreference
showUsageMetrics: boolean showUsageMetrics: boolean
autoCleanupBlankSessions?: boolean
} }
export interface OpenCodeBinary { export interface OpenCodeBinary {
@@ -64,6 +65,7 @@ const defaultPreferences: Preferences = {
toolOutputExpansion: "expanded", toolOutputExpansion: "expanded",
diagnosticsExpansion: "expanded", diagnosticsExpansion: "expanded",
showUsageMetrics: true, showUsageMetrics: true,
autoCleanupBlankSessions: true,
} }
function deepEqual(a: unknown, b: unknown): boolean { function deepEqual(a: unknown, b: unknown): boolean {
@@ -98,6 +100,7 @@ function normalizePreferences(pref?: Partial<Preferences> & { agentModelSelectio
toolOutputExpansion: sanitized.toolOutputExpansion ?? defaultPreferences.toolOutputExpansion, toolOutputExpansion: sanitized.toolOutputExpansion ?? defaultPreferences.toolOutputExpansion,
diagnosticsExpansion: sanitized.diagnosticsExpansion ?? defaultPreferences.diagnosticsExpansion, diagnosticsExpansion: sanitized.diagnosticsExpansion ?? defaultPreferences.diagnosticsExpansion,
showUsageMetrics: sanitized.showUsageMetrics ?? defaultPreferences.showUsageMetrics, showUsageMetrics: sanitized.showUsageMetrics ?? defaultPreferences.showUsageMetrics,
autoCleanupBlankSessions: sanitized.autoCleanupBlankSessions ?? defaultPreferences.autoCleanupBlankSessions,
} }
} }
@@ -285,6 +288,11 @@ function toggleUsageMetrics(): void {
updatePreferences({ showUsageMetrics: !preferences().showUsageMetrics }) updatePreferences({ showUsageMetrics: !preferences().showUsageMetrics })
} }
function toggleAutoCleanupBlankSessions(): void {
console.log("toggle auto cleanup")
updatePreferences({ autoCleanupBlankSessions: !preferences().autoCleanupBlankSessions })
}
function addRecentFolder(path: string): void { function addRecentFolder(path: string): void {
updateConfig((draft) => { updateConfig((draft) => {
draft.recentFolders = buildRecentFolderList(path, draft.recentFolders) draft.recentFolders = buildRecentFolderList(path, draft.recentFolders)
@@ -386,6 +394,7 @@ interface ConfigContextValue {
updateConfig: typeof updateConfig updateConfig: typeof updateConfig
toggleShowThinkingBlocks: typeof toggleShowThinkingBlocks toggleShowThinkingBlocks: typeof toggleShowThinkingBlocks
toggleUsageMetrics: typeof toggleUsageMetrics toggleUsageMetrics: typeof toggleUsageMetrics
toggleAutoCleanupBlankSessions: typeof toggleAutoCleanupBlankSessions
setDiffViewMode: typeof setDiffViewMode setDiffViewMode: typeof setDiffViewMode
setToolOutputExpansion: typeof setToolOutputExpansion setToolOutputExpansion: typeof setToolOutputExpansion
setDiagnosticsExpansion: typeof setDiagnosticsExpansion setDiagnosticsExpansion: typeof setDiagnosticsExpansion
@@ -418,6 +427,7 @@ const configContextValue: ConfigContextValue = {
updateConfig, updateConfig,
toggleShowThinkingBlocks, toggleShowThinkingBlocks,
toggleUsageMetrics, toggleUsageMetrics,
toggleAutoCleanupBlankSessions,
setDiffViewMode, setDiffViewMode,
setToolOutputExpansion, setToolOutputExpansion,
setDiagnosticsExpansion, setDiagnosticsExpansion,
@@ -473,6 +483,7 @@ export {
updateConfig, updateConfig,
updatePreferences, updatePreferences,
toggleShowThinkingBlocks, toggleShowThinkingBlocks,
toggleAutoCleanupBlankSessions,
toggleUsageMetrics, toggleUsageMetrics,
recentFolders, recentFolders,
addRecentFolder, addRecentFolder,

View File

@@ -2,7 +2,7 @@ import type { Session } from "../types/session"
import type { Message } from "../types/message" import type { Message } from "../types/message"
import { instances, refreshPermissionsForSession } from "./instances" import { instances, refreshPermissionsForSession } from "./instances"
import { setAgentModelPreference } from "./preferences" import { preferences, setAgentModelPreference } from "./preferences"
import { setSessionCompactionState } from "./session-compaction" import { setSessionCompactionState } from "./session-compaction"
import { import {
activeSessionId, activeSessionId,
@@ -231,7 +231,9 @@ async function createSession(instanceId: string, agent?: string): Promise<Sessio
return next return next
}) })
await cleanupBlankSessions(instanceId, session.id) if (preferences().autoCleanupBlankSessions) {
await cleanupBlankSessions(instanceId, session.id)
}
return session return session
} catch (error) { } catch (error) {