From f6f5eb6aa30d3eaccf166cb18276c5068ede417d Mon Sep 17 00:00:00 2001 From: Kelvin Amoaba <97001695+AmoabaKelvin@users.noreply.github.com> Date: Fri, 13 Nov 2026 22:18:59 +0000 Subject: [PATCH] feat(settings): add a Workspace Cleanup settings page with rules, run now and activity (#42039) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(settings): add Workspace Cleanup settings page Adds a Settings > Workspace Cleanup page for the host that owns the repos: status with Clean up now, the rule switches, the ignored-files protection and an Activity list of past runs. Turning on a delete rule that matches workspaces right now asks first; Keep pins a workspace. The page refreshes when the host's runner finishes a run: desktop main now forwards workspaceCleanupRunFinished to its window, and remote hosts' event is no longer dropped by the client event allowlist. * feat(settings): confirm any cleanup rule change that would delete workspaces now Lowering the inactive days or turning off the ignored-files protection makes the runner delete within seconds too, so those changes get the same confirm as turning a rule on. * fix(settings): serialize cleanup rule changes and guard the confirm One rule change at a time, built from the host's rules as they are when it is saved; Esc or the close button can no longer abandon a confirm that is already saving. Local save failures surface, a host whose rules cannot be read says so with a retry, and the page follows project rules that keep the runner on. * fix(settings): keep cleanup changes bound to fresh rules and this page A change re-reads the host's rules when it is confirmed, a change still previewing when the page closes is dropped, Keep locks while saving, and each preview is kept with the rules it evaluated. The page is hidden in a paired browser, whose settings are not the host's. * refactor(settings): reuse existing helpers in the Workspace Cleanup page One row key helper, useMountedRef, SettingsSwitchRow and the shared runtime target builder; only the preview of rules about to be saved is kept as the page's matches, and the report waits for the rules. * chore(i18n): protect the cleanup confirm's copy * fix(settings): re-check the cleanup confirm when the rules moved meanwhile If another client changed the rules while the confirm was open, preview again and list any workspace the dialog had not shown before saving. * fix(settings): preview again on every cleanup confirm A workspace can age past a rule while the confirm is open, so the confirm always checks again and lists anything new before saving. * fix(settings): drop a confirmed cleanup change if the page closed while pinning * feat(workspace-cleanup): keep PR number and ignored file names on cleanup rows Run and preview rows now carry the merged PR number and up to 3 ignored file names the evidence already read, so the page can say 'Merged · #4182' and 'Ignored files · .env'. No new Git reads; older saved runs lack them. * fix(settings): say when a run's saved receipt lists fewer kept workspaces * fix(workspace-cleanup): import at-risk local files from its new home * perf(workspace-cleanup): share in-flight previews and stop re-scanning confirmed rules The host shares one evaluation between previews of the same rules, so reopened pages and several clients no longer stack full scans. The page keeps a would-be rules preview out of its matches until those rules are saved, then adopts it, and reuses its own preview for the current rules. --- .../events/runtime-notifier-contract.ts | 2 + .../runtime-workspace-change-events.ts | 1 + src/main/window/runtime-window-lifecycle.ts | 1 + .../cleanup/workspace-cleanup-run-summary.ts | 28 +- .../workspace-cleanup-runner-preview.test.ts | 48 ++ .../cleanup/workspace-cleanup-runner.ts | 40 +- .../api/workspaces/workspace-cleanup-api.ts | 3 + .../workspaces/workspace-cleanup-bridge.ts | 11 +- .../form-controls/SettingsFormControls.tsx | 22 +- .../navigation/settings-navigation-types.ts | 1 + .../settings/page/settings-page-renderer.tsx | 4 +- ...tings-setup-workflow-section-renderers.tsx | 31 ++ .../SettingsGroupDisclosure.tsx | 6 + .../WorkspaceCleanupSettingsPane.tsx | 428 ++++++++++++++++++ .../use-workspace-cleanup-host-activity.ts | 188 ++++++++ .../use-workspace-cleanup-host-rules.ts | 136 ++++++ .../workspace-cleanup-activity-list.tsx | 334 ++++++++++++++ .../workspace-cleanup-reason-chip.tsx | 49 ++ .../workspace-cleanup-rule-change-dialog.tsx | 177 ++++++++ .../workspace-cleanup-rule-keys.ts | 38 ++ .../workspace-cleanup-rule-rows.tsx | 239 ++++++++++ .../workspace-cleanup-run-labels.ts | 124 +++++ .../workspace-cleanup-settings-search.ts | 152 +++++++ .../workspace-cleanup-settings-status.tsx | 151 ++++++ .../workspace-cleanup-workspace-line.tsx | 38 ++ ...space-cleanup-run-finished-window-event.ts | 36 ++ ...vents-agent-status-window-test-fixtures.ts | 1 + .../ipc-events-close-routing-test-harness.ts | 1 + .../ipc-events/app-lifetime-ipc-bridge.ts | 6 + .../ipc-events/runtime-client-ipc-bridge.ts | 10 +- .../runtime-client-window-events.ts | 24 + ...settings-navigation-capability-sections.ts | 17 + .../src/i18n/en-runtime-required.json | 30 ++ src/renderer/src/i18n/locales/en.json | 158 +++++++ .../subscriptions/runtime-client-events.ts | 3 +- .../languages/protected-copy-keys.json | 11 + .../workspace-cleanup-policy.ts | 2 +- .../workspace-cleanup-run.ts | 46 +- 38 files changed, 2552 insertions(+), 45 deletions(-) create mode 100644 src/main/workspaces/cleanup/workspace-cleanup-runner-preview.test.ts create mode 100644 src/renderer/src/components/settings/workspace-cleanup/WorkspaceCleanupSettingsPane.tsx create mode 100644 src/renderer/src/components/settings/workspace-cleanup/use-workspace-cleanup-host-activity.ts create mode 100644 src/renderer/src/components/settings/workspace-cleanup/use-workspace-cleanup-host-rules.ts create mode 100644 src/renderer/src/components/settings/workspace-cleanup/workspace-cleanup-activity-list.tsx create mode 100644 src/renderer/src/components/settings/workspace-cleanup/workspace-cleanup-reason-chip.tsx create mode 100644 src/renderer/src/components/settings/workspace-cleanup/workspace-cleanup-rule-change-dialog.tsx create mode 100644 src/renderer/src/components/settings/workspace-cleanup/workspace-cleanup-rule-keys.ts create mode 100644 src/renderer/src/components/settings/workspace-cleanup/workspace-cleanup-rule-rows.tsx create mode 100644 src/renderer/src/components/settings/workspace-cleanup/workspace-cleanup-run-labels.ts create mode 100644 src/renderer/src/components/settings/workspace-cleanup/workspace-cleanup-settings-search.ts create mode 100644 src/renderer/src/components/settings/workspace-cleanup/workspace-cleanup-settings-status.tsx create mode 100644 src/renderer/src/components/settings/workspace-cleanup/workspace-cleanup-workspace-line.tsx create mode 100644 src/renderer/src/components/workspace-cleanup/events/workspace-cleanup-run-finished-window-event.ts create mode 100644 src/renderer/src/hooks/ipc-events/runtime-client-window-events.ts diff --git a/src/main/runtime/client/events/runtime-notifier-contract.ts b/src/main/runtime/client/events/runtime-notifier-contract.ts index a91a15a9255..299078fa642 100644 --- a/src/main/runtime/client/events/runtime-notifier-contract.ts +++ b/src/main/runtime/client/events/runtime-notifier-contract.ts @@ -1,4 +1,5 @@ import type { WorkspaceMetadataSet } from '../../../../shared/worktree/metadata/workspace-metadata-set' +import type { WorkspaceCleanupRunFinishedEvent } from '../../../../shared/workspace-cleanup/workspace-cleanup-run' import type { RuntimeEditorTabReveal, RuntimeFileOpenPosition @@ -55,6 +56,7 @@ export type RuntimeNotifier = { worktreeRemoteBranchConflict?(event: WorktreeRemoteBranchConflictEvent): void reposChanged(): void browserProfilesChanged?(): void + workspaceCleanupRunFinished?(run: WorkspaceCleanupRunFinishedEvent['run']): void activateWorktree( repoId: string, worktreeId: string, diff --git a/src/main/runtime/workspaces/catalog/runtime-workspace-change-events.ts b/src/main/runtime/workspaces/catalog/runtime-workspace-change-events.ts index 90226e7b05e..9169085e2f3 100644 --- a/src/main/runtime/workspaces/catalog/runtime-workspace-change-events.ts +++ b/src/main/runtime/workspaces/catalog/runtime-workspace-change-events.ts @@ -69,6 +69,7 @@ export abstract class RuntimeWorkspaceChangeEvents extends NativeChatLaunchDraft /** The cleanup runner finished a run on this host; clients may toast. */ notifyWorkspaceCleanupRunFinished(run: WorkspaceCleanupRunFinishedEvent['run']): void { + this.notifier?.workspaceCleanupRunFinished?.(run) this.emitClientEvent({ type: 'workspaceCleanupRunFinished', run }) } } diff --git a/src/main/window/runtime-window-lifecycle.ts b/src/main/window/runtime-window-lifecycle.ts index 22c9b64e9ef..f1bc293bfc6 100644 --- a/src/main/window/runtime-window-lifecycle.ts +++ b/src/main/window/runtime-window-lifecycle.ts @@ -52,6 +52,7 @@ export function registerRuntimeWindowLifecycle( reposChanged: () => send('repos:changed'), browserProfilesChanged: () => send('browser:session:profilesChanged'), automationsChanged: (payload) => send('automations:changed', payload), + workspaceCleanupRunFinished: (run) => send('workspaceCleanup:runFinished', run), activateWorktree: ( repoId, worktreeId, diff --git a/src/main/workspaces/cleanup/workspace-cleanup-run-summary.ts b/src/main/workspaces/cleanup/workspace-cleanup-run-summary.ts index b865a5ea5b1..494c39c996a 100644 --- a/src/main/workspaces/cleanup/workspace-cleanup-run-summary.ts +++ b/src/main/workspaces/cleanup/workspace-cleanup-run-summary.ts @@ -1,6 +1,12 @@ -import type { WorkspaceCleanupEvaluation } from '../../../shared/workspace-cleanup/workspace-cleanup-evaluation' +import type { + WorkspaceCleanupEvaluation, + WorkspaceCleanupEvaluationInput +} from '../../../shared/workspace-cleanup/workspace-cleanup-evaluation' +import { hasWorktreeAtRiskLocalFiles } from '../../../shared/worktree/removal/at-risk-local-files' import { WORKSPACE_CLEANUP_REPORT_ROW_LIMIT, + WORKSPACE_CLEANUP_ROW_IGNORED_FILE_LIMIT, + type WorkspaceCleanupRowDetails, WORKSPACE_CLEANUP_UNWATCHED_CAUSES, type WorkspaceCleanupRun, type WorkspaceCleanupRunOutcome, @@ -12,6 +18,26 @@ export type WorkspaceCleanupKeptOutcome = Pick< 'outcome' | 'reason' | 'keepCause' | 'waiting' > +/** What the evidence already says about a row, for its label; no new Git reads. */ +export function workspaceCleanupRowDetails( + input: Pick +): WorkspaceCleanupRowDetails { + const review = input.git.merge?.mergedReview + const files = input.git.atRiskLocalFiles + return { + ...(review?.containsHead ? { prNumber: review.number } : {}), + ...(files && hasWorktreeAtRiskLocalFiles(files) + ? { + ignoredFiles: { + count: files.count, + samplePaths: files.samplePaths.slice(0, WORKSPACE_CLEANUP_ROW_IGNORED_FILE_LIMIT), + complete: files.complete + } + } + : {}) + } +} + export function keptRunOutcome( evaluation: WorkspaceCleanupEvaluation ): WorkspaceCleanupKeptOutcome { diff --git a/src/main/workspaces/cleanup/workspace-cleanup-runner-preview.test.ts b/src/main/workspaces/cleanup/workspace-cleanup-runner-preview.test.ts new file mode 100644 index 00000000000..4ccc129a108 --- /dev/null +++ b/src/main/workspaces/cleanup/workspace-cleanup-runner-preview.test.ts @@ -0,0 +1,48 @@ +import { afterEach, describe, expect, it, vi } from 'vitest' +import type { OrcaRuntimeService } from '../../runtime/orca-runtime' +import type { RuntimeStore } from '../../runtime/construction/runtime-store-contract' +import { getDefaultWorkspaceCleanupRules } from '../../../shared/workspace-cleanup/workspace-cleanup-policy' + +const { collectWorkspaces } = vi.hoisted(() => ({ collectWorkspaces: vi.fn() })) + +vi.mock('./workspace-cleanup-run-evidence', () => ({ + collectWorkspaceCleanupWorkspaces: collectWorkspaces +})) +vi.mock('../space-analysis/workspace-space-analysis-snapshot', () => ({ + readWorkspaceSpaceAnalysisSnapshot: () => Promise.resolve(null) +})) + +const { WorkspaceCleanupRunner } = await import('./workspace-cleanup-runner') + +function createRunner(): InstanceType { + const store = { + getSettings: () => ({ workspaceCleanupPolicy: getDefaultWorkspaceCleanupRules() }) + } + return new WorkspaceCleanupRunner({ + // SAFETY: preview only reads settings from the store and passes the runtime through to mocked evidence. + // oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: see above + store: store as unknown as RuntimeStore, + // oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: see above + runtime: {} as OrcaRuntimeService, + historyDirectory: '/unused' + }) +} + +describe('workspace cleanup runner preview', () => { + afterEach(() => { + collectWorkspaces.mockReset() + }) + + it('shares one evaluation between concurrent previews of the same rules', async () => { + let finish: (value: []) => void = () => {} + collectWorkspaces.mockReturnValue(new Promise<[]>((resolve) => (finish = resolve))) + const runner = createRunner() + + const first = runner.preview() + const second = runner.preview(getDefaultWorkspaceCleanupRules()) + finish([]) + await Promise.all([first, second]) + + expect(collectWorkspaces).toHaveBeenCalledTimes(1) + }) +}) diff --git a/src/main/workspaces/cleanup/workspace-cleanup-runner.ts b/src/main/workspaces/cleanup/workspace-cleanup-runner.ts index 95cab81bd2e..f51f1243c95 100644 --- a/src/main/workspaces/cleanup/workspace-cleanup-runner.ts +++ b/src/main/workspaces/cleanup/workspace-cleanup-runner.ts @@ -16,6 +16,7 @@ import type { WorkspaceCleanupReport, WorkspaceCleanupRun, WorkspaceCleanupRunRow, + WorkspaceCleanupRowDetails, WorkspaceCleanupRunTrigger, WorkspaceCleanupWorkspaceRef } from '../../../shared/workspace-cleanup/workspace-cleanup-run' @@ -24,7 +25,11 @@ import { type WorkspaceCleanupWorkspace } from './workspace-cleanup-run-evidence' import { decideWorkspaceCleanup, removeWorkspaceForCleanup } from './workspace-cleanup-removal-step' -import { keptRunOutcome, summarizeWorkspaceCleanupRun } from './workspace-cleanup-run-summary' +import { + keptRunOutcome, + summarizeWorkspaceCleanupRun, + workspaceCleanupRowDetails +} from './workspace-cleanup-run-summary' import { appendWorkspaceCleanupRun, readWorkspaceCleanupRunHistory @@ -39,7 +44,7 @@ const SETTINGS_DEBOUNCE_MS = 10 * 1000 type DecidedWorkspace = { workspace: WorkspaceCleanupWorkspace - ref: WorkspaceCleanupWorkspaceRef & { sizeBytes?: number } + ref: WorkspaceCleanupWorkspaceRef & WorkspaceCleanupRowDetails & { sizeBytes?: number } evaluation: WorkspaceCleanupEvaluation } @@ -54,6 +59,8 @@ export type WorkspaceCleanupRunnerDeps = { export class WorkspaceCleanupRunner { private readonly deps: WorkspaceCleanupRunnerDeps private current: Promise | null = null + // Every caller asking for the same rules while one evaluation runs shares it: reopened pages, several clients. + private readonly previews = new Map>() private timer: ReturnType | null = null private nextRunAt: number | null = null private enabledRules = new Set() @@ -107,9 +114,28 @@ export class WorkspaceCleanupRunner { } /** What a run would do now, removing nothing; `rules` previews other global rules. */ - async preview(rules?: WorkspaceCleanupRules): Promise { + preview(rules?: WorkspaceCleanupRules): Promise { + const effective = rules ?? this.globalRules() + const key = JSON.stringify(effective) + const shared = this.previews.get(key) + if (shared) { + return shared + } + const evaluation = this.evaluatePreview(effective) + this.previews.set(key, evaluation) + void evaluation + .catch(() => undefined) + .finally(() => { + if (this.previews.get(key) === evaluation) { + this.previews.delete(key) + } + }) + return evaluation + } + + private async evaluatePreview(rules: WorkspaceCleanupRules): Promise { const evaluatedAt = Date.now() - const decided = await this.evaluate(rules ?? this.globalRules(), evaluatedAt) + const decided = await this.evaluate(rules, evaluatedAt) return { evaluatedAt, rows: decided.map(({ ref, evaluation }) => ({ ...ref, evaluation })) } } @@ -193,7 +219,11 @@ export class WorkspaceCleanupRunner { const sizeBytes = sizes.get(workspace.ref.worktreeId) decided.push({ workspace, - ref: { ...workspace.ref, ...(sizeBytes !== undefined ? { sizeBytes } : {}) }, + ref: { + ...workspace.ref, + ...workspaceCleanupRowDetails(workspace.input), + ...(sizeBytes !== undefined ? { sizeBytes } : {}) + }, evaluation: await decideWorkspaceCleanup(this.deps.runtime, workspace, now) }) } diff --git a/src/preload/api/workspaces/workspace-cleanup-api.ts b/src/preload/api/workspaces/workspace-cleanup-api.ts index e286bbd2913..a16c8d7b7b2 100644 --- a/src/preload/api/workspaces/workspace-cleanup-api.ts +++ b/src/preload/api/workspaces/workspace-cleanup-api.ts @@ -12,6 +12,7 @@ import type { WorkspaceSpaceScanProgress } from '../../../shared/workspace-disk-space/workspace-space-types' import type { ExecutionHostId } from '../../../shared/execution-host' +import type { WorkspaceCleanupRunFinishedEvent } from '../../../shared/workspace-cleanup/workspace-cleanup-run' import type { WorkspaceSpaceChange } from '../../../shared/workspace-disk-space/workspace-space-change' export type WorkspaceCleanupApi = { @@ -27,6 +28,8 @@ export type WorkspaceCleanupApi = { beginRemovalSnapshotPruneBatch?: (args: WorkspaceCleanupSnapshotPruneBatchArgs) => Promise recordRemovalSnapshotPrune?: (args: WorkspaceCleanupSnapshotPruneRecordArgs) => Promise finishRemovalSnapshotPruneBatch?: (args: WorkspaceCleanupSnapshotPruneBatchArgs) => Promise + /** This app's own cleanup runner finished a run. */ + onRunFinished: (callback: (run: WorkspaceCleanupRunFinishedEvent['run']) => void) => () => void } export type WorkspaceSpaceApi = { diff --git a/src/preload/api/workspaces/workspace-cleanup-bridge.ts b/src/preload/api/workspaces/workspace-cleanup-bridge.ts index 4c979e55e84..f7d47eb08b0 100644 --- a/src/preload/api/workspaces/workspace-cleanup-bridge.ts +++ b/src/preload/api/workspaces/workspace-cleanup-bridge.ts @@ -1,5 +1,6 @@ import { ipcRenderer } from 'electron' import type { WorkspaceCleanupScanProgress } from '../../../shared/workspace-cleanup/workspace-cleanup' +import type { WorkspaceCleanupRunFinishedEvent } from '../../../shared/workspace-cleanup/workspace-cleanup-run' import type { PreloadApi } from '../../api-types' export const workspaceCleanupApi = { @@ -30,5 +31,13 @@ export const workspaceCleanupApi = { recordRemovalSnapshotPrune: (args) => ipcRenderer.invoke('workspaceCleanup:recordRemovalSnapshotPrune', args), finishRemovalSnapshotPruneBatch: (args) => - ipcRenderer.invoke('workspaceCleanup:finishRemovalSnapshotPruneBatch', args) + ipcRenderer.invoke('workspaceCleanup:finishRemovalSnapshotPruneBatch', args), + onRunFinished: (callback) => { + const listener = ( + _event: Electron.IpcRendererEvent, + run: WorkspaceCleanupRunFinishedEvent['run'] + ): void => callback(run) + ipcRenderer.on('workspaceCleanup:runFinished', listener) + return () => ipcRenderer.removeListener('workspaceCleanup:runFinished', listener) + } } satisfies PreloadApi['workspaceCleanup'] diff --git a/src/renderer/src/components/settings/form-controls/SettingsFormControls.tsx b/src/renderer/src/components/settings/form-controls/SettingsFormControls.tsx index 995a0a52a82..4aa0610a117 100644 --- a/src/renderer/src/components/settings/form-controls/SettingsFormControls.tsx +++ b/src/renderer/src/components/settings/form-controls/SettingsFormControls.tsx @@ -253,7 +253,7 @@ type ColorFieldProps = { type NumberFieldProps = { label: string - description: string + description?: string /** undefined renders the field empty — pair it with `placeholder` and `onClear` for an unset state. */ value: number | undefined defaultValue?: number @@ -369,15 +369,17 @@ export function NumberField({ className={className} label={label} description={ - <> - {description} - {defaultValue !== undefined ? ( - - {t('auto.components.settings.SettingsFormControls.b661b034ec', '· Default:')}{' '} - {defaultValue} - - ) : null} - + description || defaultValue !== undefined ? ( + <> + {description} + {defaultValue !== undefined ? ( + + {t('auto.components.settings.SettingsFormControls.b661b034ec', '· Default:')}{' '} + {defaultValue} + + ) : null} + + ) : undefined } control={
diff --git a/src/renderer/src/components/settings/navigation/settings-navigation-types.ts b/src/renderer/src/components/settings/navigation/settings-navigation-types.ts index c90336ad724..798d0163f16 100644 --- a/src/renderer/src/components/settings/navigation/settings-navigation-types.ts +++ b/src/renderer/src/components/settings/navigation/settings-navigation-types.ts @@ -15,6 +15,7 @@ export type SettingsNavInstallStatus = const SETTINGS_NAV_TARGETS = [ 'general', + 'workspace-cleanup', 'integrations', 'accounts', 'browser', diff --git a/src/renderer/src/components/settings/page/settings-page-renderer.tsx b/src/renderer/src/components/settings/page/settings-page-renderer.tsx index 376049e9d6a..df2ec7f741f 100644 --- a/src/renderer/src/components/settings/page/settings-page-renderer.tsx +++ b/src/renderer/src/components/settings/page/settings-page-renderer.tsx @@ -25,7 +25,8 @@ import { renderMobileSettingsSection, renderOrcaAccountSettingsSection, renderSetupGuideSettingsSection, - renderShareSkillsSettingsSection + renderShareSkillsSettingsSection, + renderWorkspaceCleanupSettingsSection } from './settings-setup-workflow-section-renderers' import { renderGitSettingsSection, @@ -169,6 +170,7 @@ export function renderSettingsPage( {renderOrcaAccountSettingsSection(context, t)} {renderSetupGuideSettingsSection(context, t)} {renderGeneralSettingsSection(context, t)} + {renderWorkspaceCleanupSettingsSection(context, t)} {renderIntegrationsSettingsSection(context, t)} {renderMobileSettingsSection(context, t)} {renderAutomationsSettingsSection(context, t)} diff --git a/src/renderer/src/components/settings/page/settings-setup-workflow-section-renderers.tsx b/src/renderer/src/components/settings/page/settings-setup-workflow-section-renderers.tsx index e70d30dc142..5f8715f59d5 100644 --- a/src/renderer/src/components/settings/page/settings-setup-workflow-section-renderers.tsx +++ b/src/renderer/src/components/settings/page/settings-setup-workflow-section-renderers.tsx @@ -13,6 +13,8 @@ import { translate } from '@/i18n/i18n' import type { Translate } from '@/i18n/use-translate' import type { SettingsRenderContext } from './settings-render-context' import { SettingsGroup } from '../section-layout/SettingsGroup' +import { WorkspaceCleanupSettingsPane } from '../workspace-cleanup/WorkspaceCleanupSettingsPane' +import { runtimeTargetEnvironmentId } from '@/runtime/rpc/targets/runtime-client-target' export function renderOrcaAccountSettingsSection( context: SettingsRenderContext, @@ -236,3 +238,32 @@ export function renderSessionHistorySettingsSection( ) } + +export function renderWorkspaceCleanupSettingsSection( + context: SettingsRenderContext, + t: Translate = translate +): React.JSX.Element | null { + const { model, navigation, view } = context + // A paired browser's settings are its own; the cleanup rules live on the host it pairs with. + return model.showDesktopOnlySettings ? ( + + {view.isSectionMounted('workspace-cleanup') ? ( + + ) : null} + + ) : null +} diff --git a/src/renderer/src/components/settings/section-layout/SettingsGroupDisclosure.tsx b/src/renderer/src/components/settings/section-layout/SettingsGroupDisclosure.tsx index 9a51102871f..612a79198f9 100644 --- a/src/renderer/src/components/settings/section-layout/SettingsGroupDisclosure.tsx +++ b/src/renderer/src/components/settings/section-layout/SettingsGroupDisclosure.tsx @@ -8,6 +8,8 @@ import { SETTINGS_GROUP_NESTED_INSET_CLASS } from './SettingsGroup' type SettingsGroupDisclosureProps = { label?: string + /** A muted hint after the label naming what the disclosure holds. */ + description?: string forceOpen?: boolean children: React.ReactNode } @@ -15,6 +17,7 @@ type SettingsGroupDisclosureProps = { /** Collapsible rows inside a SettingsGroup card, one fixed step in from the card's rows. Search force-opens it so matches remain reachable. */ export function SettingsGroupDisclosure({ label, + description, forceOpen = false, children }: SettingsGroupDisclosureProps): React.JSX.Element { @@ -40,6 +43,9 @@ export function SettingsGroupDisclosure({ )} /> {label ?? t('auto.components.settings.AppearanceAdvancedDisclosure.advanced', 'Advanced')} + {description ? ( + {description} + ) : null} {/* Stays mounted while collapsed so a settings jump can find and reveal its rows. */}