Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(desktop): 共用 Work Louder 保护设置并精简重启提示 (#3983)

Dashdf05fdafced7
diff --git a/apps/desktop/src/main/worklouder-codex/CodexMicroGuardService.ts b/apps/desktop/src/main/worklouder-codex/CodexMicroGuardService.ts
index 27fcbfb032..3ef2b3185f 100644
--- a/apps/desktop/src/main/worklouder-codex/CodexMicroGuardService.ts
+++ b/apps/desktop/src/main/worklouder-codex/CodexMicroGuardService.ts
@@ -10,6 +10,10 @@ import {
type OverrideSettingsFile,
} from '../maker-host/override-settings-file.js';
import hookContents from './codexMicroGuardHook.cjs?raw';
+import {
+ listCodexMicroGuardProcesses,
+ type CodexMicroGuardProcess,
+} from './codexMicroGuardProcesses.js';
import {
CodexMicroGuardManager,
CodexMicroGuardStore,
@@ -29,6 +33,7 @@ interface CodexMicroGuardServiceOptions {
runner?: GuardCommandRunner;
hookContents?: string;
heartbeatIntervalMs?: number;
+ listProcesses?: () => Promise<CodexMicroGuardProcess[]>;
}
const log = desktopMakerLogger.child('codex-micro-guard');
@@ -52,9 +57,12 @@ export class CodexMicroGuardService {
private recoveryRequired = false;
private disposed = false;
private lastEmittedState: string | null = null;
+ private readonly listProcesses: () => Promise<CodexMicroGuardProcess[]>;
+ private restartProcesses: CodexMicroGuardProcess[] = [];
constructor(options: CodexMicroGuardServiceOptions = {}) {
this.platform = options.platform ?? process.platform;
+ this.listProcesses = options.listProcesses ?? listCodexMicroGuardProcesses;
const supportPath = options.supportPath ?? defaultSupportPath();
this.store = new CodexMicroGuardStore(supportPath);
this.manager = new CodexMicroGuardManager(
@@ -88,6 +96,7 @@ export class CodexMicroGuardService {
async getState(): Promise<CodexMicroGuardState> {
await this.initialize();
+ await this.enqueue(() => this.refreshRestartRequired());
return this.snapshot();
}
@@ -110,6 +119,7 @@ export class CodexMicroGuardService {
this.settingsStore.writePatch({ enabled: false });
this.stopHeartbeat();
this.active = false;
+ this.restartProcesses = [];
await this.manager.disable();
this.failed = false;
this.recoveryRequired = false;
@@ -129,6 +139,7 @@ export class CodexMicroGuardService {
if (this.disposed) return;
this.disposed = true;
this.stopHeartbeat();
+ this.restartProcesses = [];
if (this.platform !== 'darwin') return;
try {
if (this.active || this.hasRecoveryState()) await this.manager.disable();
@@ -149,6 +160,7 @@ export class CodexMicroGuardService {
try {
if (enabled) {
await this.manager.enable(this.hookContents);
+ // Restart hints belong only to an explicit toggle, not startup recovery.
this.active = true;
this.startHeartbeat();
} else if (this.hasRecoveryState()) {
@@ -172,6 +184,12 @@ export class CodexMicroGuardService {
if (this.active && this.store.isFresh()) return;
this.failed = false;
this.recoveryRequired = false;
+ let processes: CodexMicroGuardProcess[] = [];
+ try {
+ processes = await this.listProcesses();
+ } catch {
+ // Process detection is only a hint; it must not fail protection activation.
+ }
await this.manager.enable(this.hookContents);
try {
this.settingsStore.writePatch({ enabled: true });
@@ -184,6 +202,7 @@ export class CodexMicroGuardService {
throw error;
}
this.active = true;
+ this.restartProcesses = processes;
this.startHeartbeat();
this.emitIfChanged();
}
@@ -192,6 +211,7 @@ export class CodexMicroGuardService {
if (options.persistSetting) this.settingsStore.writePatch({ enabled: false });
this.stopHeartbeat();
this.active = false;
+ this.restartProcesses = [];
try {
await this.manager.disable();
this.failed = false;
@@ -224,6 +244,7 @@ export class CodexMicroGuardService {
}
log.warn('Codex Micro guard heartbeat failed and protection was stopped');
}
+ await this.refreshRestartRequired();
this.emitIfChanged();
});
}, this.heartbeatIntervalMs);
@@ -244,6 +265,29 @@ export class CodexMicroGuardService {
}
}
+ private async refreshRestartRequired(): Promise<void> {
+ if (!this.active || this.disposed) {
+ this.restartProcesses = [];
+ return;
+ }
+ if (this.restartProcesses.length === 0) return;
+ try {
+ const processes = await this.listProcesses();
+ // Only keep processes observed at activation. A later launch cannot
+ // bring the hint back, even if the OS reuses the same PID.
+ this.restartProcesses = this.restartProcesses.filter((previous) =>
+ processes.some(
+ (current) =>
+ current.pid === previous.pid &&
+ current.startedAt === previous.startedAt &&
+ current.executable === previous.executable,
+ ),
+ );
+ } catch {
+ this.restartProcesses = [];
+ }
+ }
+
private snapshot(): CodexMicroGuardState {
if (this.platform !== 'darwin') {
return { supported: false, enabled: false, status: 'unsupported' };
@@ -254,7 +298,13 @@ export class CodexMicroGuardService {
else if (this.failed) status = 'error';
else if (!this.active || !this.store.isFresh()) status = 'disabled';
else status = this.store.hasInterceptionReceipt() ? 'intercepted' : 'protecting';
- return { supported: true, enabled, status };
+ return {
+ supported: true,
+ enabled,
+ status,
+ restartRequired:
+ (status === 'protecting' || status === 'intercepted') && this.restartProcesses.length > 0,
+ };
}
private emitIfChanged(): void {
diff --git a/apps/desktop/src/main/worklouder-codex/__tests__/CodexMicroGuardService.test.ts b/apps/desktop/src/main/worklouder-codex/__tests__/CodexMicroGuardService.test.ts
index 69d8b16199..40c82b17c0 100644
--- a/apps/desktop/src/main/worklouder-codex/__tests__/CodexMicroGuardService.test.ts
+++ b/apps/desktop/src/main/worklouder-codex/__tests__/CodexMicroGuardService.test.ts
@@ -4,6 +4,7 @@ import path from 'node:path';
import { afterEach, describe, expect, it, vi } from 'vitest';
import type { GuardCommandResult, GuardCommandRunner } from '../codexMicroGuardCore.js';
+import type { CodexMicroGuardProcess } from '../codexMicroGuardProcesses.js';
vi.mock('electron', () => ({
app: { getPath: () => '/unused' },
@@ -65,22 +66,107 @@ function paths() {
function service(
paths_: ReturnType<typeof paths>,
runner: GuardCommandRunner,
+ listProcesses: () => Promise<CodexMicroGuardProcess[]> = async () => [],
): CodexMicroGuardService {
return new CodexMicroGuardService({
platform: 'darwin',
...paths_,
launchctlDomain: 'gui/501',
runner,
+ listProcesses,
hookContents: '// safe test hook\n',
- heartbeatIntervalMs: 60_000,
+ heartbeatIntervalMs: 5_000,
});
}
afterEach(() => {
+ vi.useRealTimers();
for (const root of roots.splice(0)) fs.rmSync(root, { recursive: true, force: true });
});
describe('CodexMicroGuardService', () => {
+ const runningCodex = () => ({
+ pid: 101,
+ startedAt: Date.now() - 60_000,
+ executable: '/Applications/Codex.app/Contents/MacOS/Codex',
+ });
+
+ it('clears the restart hint on exit or restart through the existing heartbeat', async () => {
+ vi.useFakeTimers();
+ let processes = [runningCodex()];
+ const instance = service(paths(), new EnvironmentRunner(null), async () => processes);
+ const listener = vi.fn();
+ instance.subscribe(listener);
+ expect(await instance.setEnabled(true)).toMatchObject({ restartRequired: true });
+ processes = [];
+ await vi.advanceTimersByTimeAsync(5_000);
+ expect(listener).toHaveBeenLastCalledWith(
+ expect.objectContaining({ status: 'protecting', enabled: true, restartRequired: false }),
+ );
+ processes = [{ ...runningCodex(), startedAt: Date.now(), pid: 102 }];
+ expect(await instance.getState()).toMatchObject({
+ status: 'protecting',
+ restartRequired: false,
+ });
+ await instance.dispose();
+ });
+
+ it('only considers processes running when the switch is enabled', async () => {
+ const list = vi.fn(async (): Promise<CodexMicroGuardProcess[]> => []);
+ const instance = service(paths(), new EnvironmentRunner(null), list);
+ expect(await instance.setEnabled(true)).toMatchObject({ restartRequired: false });
+ list.mockResolvedValue([runningCodex()]);
+ expect(await instance.getState()).toMatchObject({ restartRequired: false });
+ expect(list).toHaveBeenCalledTimes(1);
+ await instance.setEnabled(false);
+ expect(await instance.setEnabled(true)).toMatchObject({ restartRequired: true });
+ expect(await instance.setEnabled(false)).toMatchObject({ restartRequired: false });
+ await instance.dispose();
+ });
+
+ it('clears restarted processes even when their PIDs are reused', async () => {
+ const original = runningCodex();
+ let processes = [original, { ...original, pid: 102 }];
+ const instance = service(paths(), new EnvironmentRunner(null), async () => processes);
+ expect(await instance.setEnabled(true)).toMatchObject({ restartRequired: true });
+ processes = [{ ...original, startedAt: original.startedAt + 10_000 }, processes[1]];
+ expect(await instance.getState()).toMatchObject({ restartRequired: true });
+ processes = [processes[0]];
+ expect(await instance.getState()).toMatchObject({ restartRequired: false });
+ await instance.dispose();
+ });
+
+ it('keeps protection active when process detection fails', async () => {
+ const list = vi.fn(async (): Promise<CodexMicroGuardProcess[]> => {
+ throw new Error('ps unavailable');
+ });
+ const instance = service(paths(), new EnvironmentRunner(null), list);
+ expect(await instance.setEnabled(true)).toMatchObject({
+ enabled: true,
+ restartRequired: false,
+ });
+ await instance.setEnabled(false);
+ list.mockResolvedValue([runningCodex()]);
+ expect(await instance.setEnabled(true)).toMatchObject({ restartRequired: true });
+ list.mockRejectedValue(new Error('ps unavailable'));
+ expect(await instance.getState()).toMatchObject({ enabled: true, restartRequired: false });
+ await instance.dispose();
+ });
+
+ it('does not carry restart hints across Cindy restarts', async () => {
+ const locations = paths();
+ const runner = new EnvironmentRunner(null);
+ const list = vi.fn(async () => [runningCodex()]);
+ const first = service(locations, runner, list);
+ expect(await first.setEnabled(true)).toMatchObject({ restartRequired: true });
+ await first.dispose();
+ list.mockClear();
+ const second = service(locations, runner, list);
+ expect(await second.getState()).toMatchObject({ enabled: true, restartRequired: false });
+ expect(list).not.toHaveBeenCalled();
+ await second.dispose();
+ });
+
it('reports unsupported without touching launchctl on other platforms', async () => {
const locations = paths();
const runner = new EnvironmentRunner('--trace-warnings');
diff --git a/apps/desktop/src/main/worklouder-codex/__tests__/codexMicroGuardProcesses.test.ts b/apps/desktop/src/main/worklouder-codex/__tests__/codexMicroGuardProcesses.test.ts
new file mode 100644
index 0000000000..7be8bbdd13
--- /dev/null
+++ b/apps/desktop/src/main/worklouder-codex/__tests__/codexMicroGuardProcesses.test.ts
@@ -0,0 +1,26 @@
+import { describe, expect, it } from 'vitest';
+import { parseCodexMicroGuardProcesses } from '../codexMicroGuardProcesses.js';
+
+describe('Codex Micro process observation', () => {
+ it('only selects supported desktop main executables, never CLI or helpers', () => {
+ const date = 'Sun Sep 6 09:10:11 2026';
+ const codex = '/Applications/Codex.app/Contents/MacOS/Codex';
+ const chatgpt = '/Applications/ChatGPT.app/Contents/MacOS/ChatGPT';
+ expect(
+ parseCodexMicroGuardProcesses(
+ [
+ ` 101 ${date} ${codex}`,
+ ` 102 ${date} ${chatgpt}`,
+ ` 103 ${date} /usr/local/bin/codex`,
+ ` 104 ${date} ${codex} Helper`,
+ ` 105 ${date} /tmp/Codex.app/Contents/MacOS/Codex`,
+ ` 0 ${date} ${codex}`,
+ 'malformed',
+ ].join('\n'),
+ ),
+ ).toEqual([
+ { pid: 101, startedAt: Date.parse('2026-09-06T09:10:11Z'), executable: codex },
+ { pid: 102, startedAt: Date.parse('2026-09-06T09:10:11Z'), executable: chatgpt },
+ ]);
+ });
+});
diff --git a/apps/desktop/src/main/worklouder-codex/codexMicroGuardProcesses.ts b/apps/desktop/src/main/worklouder-codex/codexMicroGuardProcesses.ts
new file mode 100644
index 0000000000..bf02050194
--- /dev/null
+++ b/apps/desktop/src/main/worklouder-codex/codexMicroGuardProcesses.ts
@@ -0,0 +1,42 @@
+import { execFile } from 'node:child_process';
+import { promisify } from 'node:util';
+
+const execFileAsync = promisify(execFile);
+const TARGET_EXECUTABLES = new Set([
+ '/Applications/Codex.app/Contents/MacOS/Codex',
+ '/Applications/ChatGPT.app/Contents/MacOS/ChatGPT',
+]);
+
+export interface CodexMicroGuardProcess {
+ pid: number;
+ startedAt: number;
+ executable: string;
+}
+
+export async function listCodexMicroGuardProcesses(): Promise<CodexMicroGuardProcess[]> {
+ const { stdout } = await execFileAsync(
+ '/bin/ps',
+ ['-ww', '-U', String(process.getuid!()), '-o', 'pid=,lstart=,comm='],
+ {
+ encoding: 'utf8',
+ env: { ...process.env, LC_ALL: 'C', TZ: 'UTC' },
+ timeout: 1_000,
+ maxBuffer: 2 * 1024 * 1024,
+ },
+ );
+ return parseCodexMicroGuardProcesses(stdout);
+}
+
+export function parseCodexMicroGuardProcesses(output: string): CodexMicroGuardProcess[] {
+ return output.split('\n').flatMap((line) => {
+ const match = /^\s*(\d+)\s+(\w{3}\s+\w{3}\s+\d+\s+\d{2}:\d{2}:\d{2}\s+\d{4})\s+(.+?)\s*$/u.exec(
+ line,
+ );
+ if (!match || !TARGET_EXECUTABLES.has(match[3])) return [];
+ const pid = Number(match[1]);
+ const startedAt = Date.parse(`${match[2]} UTC`);
+ return Number.isSafeInteger(pid) && pid > 0 && Number.isFinite(startedAt)
+ ? [{ pid, startedAt, executable: match[3] }]
+ : [];
+ });
+}
diff --git a/apps/desktop/src/renderer/components/settings/WorkLouderCodexSettings.tsx b/apps/desktop/src/renderer/components/settings/WorkLouderCodexSettings.tsx
index fb2dff9696..bb519b3cf0 100644
--- a/apps/desktop/src/renderer/components/settings/WorkLouderCodexSettings.tsx
+++ b/apps/desktop/src/renderer/components/settings/WorkLouderCodexSettings.tsx
@@ -608,46 +608,6 @@ export function WorkLouderCodexSettings({
</div>
</SettingsCard>
- {model === 'codex-micro' ? (
- <SettingsGroup title={t('settings.shortcuts.workLouderCodex.codexGuard.title')}>
- <SettingsRow
- label={t('settings.shortcuts.workLouderCodex.codexGuard.label')}
- description={t(
- `settings.shortcuts.workLouderCodex.codexGuard.descriptions.${guardDescriptionKey(
- guardState?.status,
- guardError,
- )}`,
- )}
- control={
- <div className="flex items-center justify-end gap-2">
- {guardState?.status === 'recovery-required' ? (
- <SettingsSecondaryButton
- disabled={guardSaving}
- onClick={() => void recoverGuard()}
- >
- {t('settings.shortcuts.workLouderCodex.codexGuard.recover')}
- </SettingsSecondaryButton>
- ) : (
- <Switch
- checked={guardState?.enabled ?? false}
- disabled={guardLoading || guardSaving || !guardState || !guardState.supported}
- onCheckedChange={(checked) => void setGuardEnabled(checked)}
- aria-label={t('settings.shortcuts.workLouderCodex.codexGuard.aria')}
- />
- )}
- <DeviceChip>
- {t(
- `settings.shortcuts.workLouderCodex.codexGuard.status.${
- guardState?.status ?? (guardError ? 'error' : 'disabled')
- }`,
- )}
- </DeviceChip>
- </div>
- }
- />
- </SettingsGroup>
- ) : null}
-
<SettingsCard className="flex flex-col gap-3">
<div className="flex items-start justify-between gap-3">
<div className="flex min-w-0 flex-col gap-1">
@@ -1084,6 +1044,43 @@ export function WorkLouderCodexSettings({
}
/>
</SettingsGroup>
+
+ {/* Both keyboards share the same Codex service and machine-local guard. */}
+ <SettingsGroup title={t('settings.shortcuts.workLouderCodex.codexGuard.title')}>
+ <SettingsRow
+ label={t('settings.shortcuts.workLouderCodex.codexGuard.label')}
+ description={t(
+ `settings.shortcuts.workLouderCodex.codexGuard.descriptions.${guardDescriptionKey(
+ guardState?.status,
+ guardError,
+ )}`,
+ )}
+ control={
+ <div className="flex items-center justify-end gap-2">
+ {guardState?.enabled &&
+ guardState.restartRequired &&
+ !guardError &&
+ (guardState.status === 'protecting' || guardState.status === 'intercepted') && (
+ <span className="text-12 text-[var(--text-secondary)]">
+ {t('settings.shortcuts.workLouderCodex.codexGuard.restartRequired')}
+ </span>
+ )}
+ {guardState?.status === 'recovery-required' ? (
+ <SettingsSecondaryButton disabled={guardSaving} onClick={() => void recoverGuard()}>
+ {t('settings.shortcuts.workLouderCodex.codexGuard.recover')}
+ </SettingsSecondaryButton>
+ ) : (
+ <Switch
+ checked={guardState?.enabled ?? false}
+ disabled={guardLoading || guardSaving || !guardState || !guardState.supported}
+ onCheckedChange={(checked) => void setGuardEnabled(checked)}
+ aria-label={t('settings.shortcuts.workLouderCodex.codexGuard.aria')}
+ />
+ )}
+ </div>
+ }
+ />
+ </SettingsGroup>
</div>
);
}
@@ -1588,9 +1585,8 @@ function guardDescriptionKey(
case 'unsupported':
return 'unsupported';
case 'protecting':
- return 'protecting';
case 'intercepted':
- return 'intercepted';
+ return 'disabled';
case 'recovery-required':
return 'recovery-required';
case 'error':
diff --git a/apps/desktop/src/renderer/components/settings/__tests__/WorkLouderCodexSettings.test.tsx b/apps/desktop/src/renderer/components/settings/__tests__/WorkLouderCodexSettings.test.tsx
index 3af61a64f9..33edb9aba7 100644
--- a/apps/desktop/src/renderer/components/settings/__tests__/WorkLouderCodexSettings.test.tsx
+++ b/apps/desktop/src/renderer/components/settings/__tests__/WorkLouderCodexSettings.test.tsx
@@ -16,6 +16,7 @@ const mocks = vi.hoisted(() => ({
reload: vi.fn(),
setGuardEnabled: vi.fn(),
recoverGuard: vi.fn(),
+ guardRestartRequired: false,
guardStatus: 'disabled' as 'disabled' | 'protecting' | 'intercepted' | 'recovery-required',
setLayoutPreviewActive: vi.fn(),
previewListeners: [] as Array<
@@ -46,6 +47,7 @@ vi.mock('@/hooks/useCodexMicroGuard', () => ({
supported: true,
enabled: mocks.guardStatus === 'protecting' || mocks.guardStatus === 'intercepted',
status: mocks.guardStatus,
+ restartRequired: mocks.guardRestartRequired,
},
loading: false,
saving: false,
@@ -120,6 +122,7 @@ describe('WorkLouderCodexSettings', () => {
mocks.agentSource = 'sidebar';
mocks.layout = createWorkLouderCodexDefaultSettings().layout;
mocks.guardStatus = 'disabled';
+ mocks.guardRestartRequired = false;
mocks.deviceEnabled = true;
mocks.connectionStatus = 'connected';
mocks.connectionReason = null;
@@ -251,29 +254,66 @@ describe('WorkLouderCodexSettings', () => {
expect(mocks.setSettings).toHaveBeenCalledWith({ lightingAutoDim: '10-minutes' });
});
- it('lets Cindy protect the device from Codex and exposes recovery failures', () => {
- const { unmount } = render(<WorkLouderCodexSettings onBack={vi.fn()} />);
+ it.each(['codex-micro', 'creator-micro-2'] as const)(
+ 'shares Codex protection and recovery for %s',
+ (model) => {
+ mocks.deviceType = model;
+ mocks.layout = createWorkLouderCodexDefaultSettings(model).layout;
+ const { unmount } = render(<WorkLouderCodexSettings model={model} onBack={vi.fn()} />);
- fireEvent.click(
- screen.getByRole('switch', {
- name: 'settings.shortcuts.workLouderCodex.codexGuard.aria',
- }),
- );
- expect(mocks.setGuardEnabled).toHaveBeenCalledWith(true);
- expect(
- screen.getByText('settings.shortcuts.workLouderCodex.codexGuard.status.disabled'),
- ).toBeTruthy();
- unmount();
-
- mocks.guardStatus = 'recovery-required';
- render(<WorkLouderCodexSettings onBack={vi.fn()} />);
- fireEvent.click(
- screen.getByRole('button', {
- name: 'settings.shortcuts.workLouderCodex.codexGuard.recover',
- }),
- );
- expect(mocks.recoverGuard).toHaveBeenCalledOnce();
- });
+ fireEvent.click(
+ screen.getByRole('switch', {
+ name: 'settings.shortcuts.workLouderCodex.codexGuard.aria',
+ }),
+ );
+ expect(mocks.setGuardEnabled).toHaveBeenCalledWith(true);
+ expect(
+ screen.queryByText('settings.shortcuts.workLouderCodex.codexGuard.status.disabled'),
+ ).toBeNull();
+ unmount();
+
+ mocks.guardStatus = 'recovery-required';
+ render(<WorkLouderCodexSettings model={model} onBack={vi.fn()} />);
+ fireEvent.click(
+ screen.getByRole('button', {
+ name: 'settings.shortcuts.workLouderCodex.codexGuard.recover',
+ }),
+ );
+ expect(mocks.recoverGuard).toHaveBeenCalledOnce();
+ },
+ );
+
+ it.each(['codex-micro', 'creator-micro-2'] as const)(
+ 'places compatibility last and only shows a needed restart for %s',
+ (model) => {
+ mocks.deviceType = model;
+ mocks.layout = createWorkLouderCodexDefaultSettings(model).layout;
+ mocks.guardStatus = 'protecting';
+ const { rerender, container } = render(
+ <WorkLouderCodexSettings model={model} onBack={vi.fn()} />,
+ );
+ const prefix = 'settings.shortcuts.workLouderCodex.codexGuard';
+ expect(container.firstElementChild?.lastElementChild?.textContent).toContain(
+ `${prefix}.label`,
+ );
+ expect(screen.queryByText(`${prefix}.restartRequired`)).toBeNull();
+ expect(screen.queryByText(`${prefix}.descriptions.protecting`)).toBeNull();
+
+ mocks.guardRestartRequired = true;
+ rerender(<WorkLouderCodexSettings model={model} onBack={vi.fn()} />);
+ const hint = screen.getByText(`${prefix}.restartRequired`);
+ const toggle = screen.getByRole('switch', { name: `${prefix}.aria` });
+ expect(hint.compareDocumentPosition(toggle) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
+
+ mocks.guardRestartRequired = false;
+ rerender(<WorkLouderCodexSettings model={model} onBack={vi.fn()} />);
+ expect(screen.queryByText(`${prefix}.restartRequired`)).toBeNull();
+ mocks.guardRestartRequired = true;
+ mocks.guardStatus = 'disabled';
+ rerender(<WorkLouderCodexSettings model={model} onBack={vi.fn()} />);
+ expect(screen.queryByText(`${prefix}.restartRequired`)).toBeNull();
+ },
+ );
it('sets all six task keys at once, since they follow one shared rule', async () => {
render(<WorkLouderCodexSettings onBack={vi.fn()} />);
diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.json
index 7889d477f7..981f630197 100644
--- a/apps/desktop/src/renderer/i18n/locales/en/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json
@@ -3748,24 +3748,15 @@
"codexGuard": {
"title": "Codex compatibility",
"label": "Prevent Codex from occupying the device",
- "aria": "Prevent Codex from occupying Codex Micro",
+ "aria": "Prevent Codex from occupying Work Louder keyboards",
"recover": "Restore environment",
- "status": {
- "unsupported": "macOS only",
- "disabled": "Off",
- "protecting": "Restart Codex",
- "intercepted": "Protected",
- "recovery-required": "Recovery needed",
- "error": "Unavailable"
- },
"descriptions": {
"unsupported": "This protection is available on macOS only.",
- "disabled": "While Cindy is running, stop Codex from connecting to Codex Micro. Cindy itself is not restricted.",
- "protecting": "Protection is ready. Completely quit and reopen Codex; an already-running Codex is unaffected.",
- "intercepted": "Codex's Work Louder service was blocked. Cindy can keep using the device.",
+ "disabled": "While Cindy is running, stop Codex from connecting to Work Louder keyboards. Cindy itself is not restricted.",
"recovery-required": "Protection stopped, but NODE_OPTIONS has not been safely restored. Retry the recovery before enabling it again.",
"error": "Cindy could not update Codex protection. Your previous NODE_OPTIONS value was preserved or queued for recovery."
- }
+ },
+ "restartRequired": "Quit and reopen Codex to apply"
},
"commands": {
"session.selectPrevious": {
diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.json
index d9347d3aed..b7edb21429 100644
--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json
@@ -3747,24 +3747,15 @@
"codexGuard": {
"title": "Codex との互換性",
"label": "Codex によるデバイスの占有を防ぐ",
- "aria": "Codex による Codex Micro の占有を防ぐ",
+ "aria": "Codex による Work Louder キーボード の占有を防ぐ",
"recover": "環境を復元",
- "status": {
- "unsupported": "macOS のみ",
- "disabled": "オフ",
- "protecting": "Codex を再起動",
- "intercepted": "保護中",
- "recovery-required": "復元が必要",
- "error": "利用不可"
- },
"descriptions": {
"unsupported": "この保護機能は macOS でのみ利用できます。",
- "disabled": "Cindy の実行中、Codex が Codex Micro に接続するのを防ぎます。Cindy 自体は制限されません。",
- "protecting": "保護の準備ができました。Codex を完全に終了してから開き直してください。実行中の Codex には影響しません。",
- "intercepted": "Codex の Work Louder サービスをブロックしました。Cindy は引き続きデバイスを使用できます。",
+ "disabled": "Cindy の実行中、Codex が Work Louder キーボード に接続するのを防ぎます。Cindy 自体は制限されません。",
"recovery-required": "保護は停止しましたが、NODE_OPTIONS は安全に復元されていません。再度有効にする前に復元を再試行してください。",
"error": "Codex の保護を更新できませんでした。以前の NODE_OPTIONS は保持されているか、復元待ちです。"
- }
+ },
+ "restartRequired": "適用するには Codex を完全に終了して再起動"
},
"commands": {
"session.selectPrevious": {
diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.json
index b5aa2826e4..a8ba56da5a 100644
--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json
@@ -3747,24 +3747,15 @@
"codexGuard": {
"title": "Codex 호환성",
"label": "Codex의 장치 점유 방지",
- "aria": "Codex의 Codex Micro 점유 방지",
+ "aria": "Codex의 Work Louder 키보드 점유 방지",
"recover": "환경 복원",
- "status": {
- "unsupported": "macOS 전용",
- "disabled": "꺼짐",
- "protecting": "Codex 재시작 필요",
- "intercepted": "보호 중",
- "recovery-required": "복원 필요",
- "error": "사용 불가"
- },
"descriptions": {
"unsupported": "이 보호 기능은 macOS에서만 사용할 수 있습니다.",
- "disabled": "Cindy가 실행되는 동안 Codex가 Codex Micro에 연결하지 못하게 합니다. Cindy 자체는 제한하지 않습니다.",
- "protecting": "보호 준비가 완료되었습니다. Codex를 완전히 종료한 뒤 다시 여세요. 이미 실행 중인 Codex에는 영향을 주지 않습니다.",
- "intercepted": "Codex의 Work Louder 서비스를 차단했습니다. Cindy는 장치를 계속 사용할 수 있습니다.",
+ "disabled": "Cindy가 실행되는 동안 Codex가 Work Louder 키보드에 연결하지 못하게 합니다. Cindy 자체는 제한하지 않습니다.",
"recovery-required": "보호가 중지되었지만 NODE_OPTIONS가 안전하게 복원되지 않았습니다. 다시 켜기 전에 복원을 재시도하세요.",
"error": "Codex 보호를 업데이트하지 못했습니다. 기존 NODE_OPTIONS는 유지되었거나 복원 대기 중입니다."
- }
+ },
+ "restartRequired": "적용하려면 Codex를 완전히 종료한 뒤 다시 여세요"
},
"commands": {
"session.selectPrevious": {
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
index 3c30f1bf4c..f89d1e8ba1 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
@@ -3741,24 +3741,15 @@
"codexGuard": {
"title": "Codex 兼容性",
"label": "防止 Codex 占用设备",
- "aria": "防止 Codex 占用 Codex Micro",
+ "aria": "防止 Codex 占用 Work Louder 键盘",
"recover": "恢复环境",
- "status": {
- "unsupported": "仅 macOS",
- "disabled": "已关闭",
- "protecting": "请重启 Codex",
- "intercepted": "保护中",
- "recovery-required": "需要恢复",
- "error": "不可用"
- },
"descriptions": {
"unsupported": "此保护仅在 macOS 上可用。",
- "disabled": "Cindy 运行期间阻止 Codex 连接 Codex Micro;不会限制 Cindy 本身。",
- "protecting": "保护已就绪。请完全退出后重新打开 Codex;已经运行的 Codex 不受影响。",
- "intercepted": "已阻止 Codex 的 Work Louder 服务,Cindy 可以继续使用设备。",
+ "disabled": "Cindy 运行期间阻止 Codex 连接 Work Louder 键盘;不会限制 Cindy 本身。",
"recovery-required": "保护已停止,但 NODE_OPTIONS 尚未安全恢复。请先重试恢复,再重新开启。",
"error": "Cindy 无法更新 Codex 保护;原有 NODE_OPTIONS 已保留或等待恢复。"
- }
+ },
+ "restartRequired": "请完全退出并重新打开 Codex 以生效"
},
"commands": {
"session.selectPrevious": {
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
index 7c8e8110ba..f685e587f3 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
@@ -3747,24 +3747,15 @@
"codexGuard": {
"title": "Codex 相容性",
"label": "防止 Codex 佔用裝置",
- "aria": "防止 Codex 佔用 Codex Micro",
+ "aria": "防止 Codex 佔用 Work Louder 鍵盤",
"recover": "還原環境",
- "status": {
- "unsupported": "僅 macOS",
- "disabled": "已關閉",
- "protecting": "請重新啟動 Codex",
- "intercepted": "保護中",
- "recovery-required": "需要還原",
- "error": "無法使用"
- },
"descriptions": {
"unsupported": "此保護僅可在 macOS 上使用。",
- "disabled": "Cindy 執行期間會阻止 Codex 連線至 Codex Micro;不會限制 Cindy 本身。",
- "protecting": "保護已就緒。請完全結束後重新開啟 Codex;已在執行的 Codex 不受影響。",
- "intercepted": "已阻止 Codex 的 Work Louder 服務,Cindy 可以繼續使用裝置。",
+ "disabled": "Cindy 執行期間會阻止 Codex 連線至 Work Louder 鍵盤;不會限制 Cindy 本身。",
"recovery-required": "保護已停止,但 NODE_OPTIONS 尚未安全還原。請先重試還原,再重新開啟。",
"error": "Cindy 無法更新 Codex 保護;原有 NODE_OPTIONS 已保留或等待還原。"
- }
+ },
+ "restartRequired": "請完全結束並重新開啟 Codex 以生效"
},
"commands": {
"session.selectPrevious": {
diff --git a/apps/desktop/src/shared/codexMicroGuard.ts b/apps/desktop/src/shared/codexMicroGuard.ts
index aefb8f6da5..75d992335c 100644
--- a/apps/desktop/src/shared/codexMicroGuard.ts
+++ b/apps/desktop/src/shared/codexMicroGuard.ts
@@ -10,7 +10,9 @@ export type CodexMicroGuardStatus =
export interface CodexMicroGuardState {
supported: boolean;
- /** Machine-local user override. The system default is false. */
+ /** Machine-local override shared by Codex Micro and Creator Micro 2. Defaults to false. */
enabled: boolean;
status: CodexMicroGuardStatus;
+ /** A running desktop Codex predates protection and has not applied it. */
+ restartRequired?: boolean;
}