fix(sync-ui): exit CLI cleanly when sync window closes

- Use runAppCommandInteractive so sync-window inherits the terminal directly
- Quit app on window-all-closed when launched with --sync-window on macOS
- Catch synchronous onWillQuitCleanup errors to prevent quit getting stuck
This commit is contained in:
2026-07-12 16:39:13 -07:00
parent a013a7ea55
commit a4c12165af
5 changed files with 73 additions and 4 deletions
+18
View File
@@ -206,6 +206,7 @@ test('app command starts default macOS background app detached from launcher', (
runAppCommandWithInherit: () => {
calls.push('attached');
},
runAppCommandInteractive: () => calls.push('interactive'),
launchAppBackgroundDetached: (appPath, logLevel) => {
calls.push(`detached:${appPath}:${logLevel}`);
},
@@ -225,6 +226,7 @@ test('app command starts default Linux background app detached from launcher', (
runAppCommandWithInherit: () => {
calls.push('attached');
},
runAppCommandInteractive: () => calls.push('interactive'),
launchAppBackgroundDetached: (appPath, logLevel) => {
calls.push(`detached:${appPath}:${logLevel}`);
},
@@ -245,6 +247,7 @@ test('app command keeps explicit passthrough args attached', () => {
runAppCommandWithInherit: (_appPath, appArgs) => {
forwarded.push(appArgs);
},
runAppCommandInteractive: () => detached.push('interactive'),
launchAppBackgroundDetached: () => {
detached.push('detached');
},
@@ -255,6 +258,21 @@ test('app command keeps explicit passthrough args attached', () => {
assert.deepEqual(detached, []);
});
test('sync UI command attaches the app directly to the terminal', () => {
const context = createContext();
context.args.syncUi = true;
const calls: string[] = [];
const handled = runAppPassthroughCommand(context, {
runAppCommandWithInherit: () => calls.push('piped'),
runAppCommandInteractive: (_appPath, appArgs) => calls.push(`direct:${appArgs.join(' ')}`),
launchAppBackgroundDetached: () => calls.push('detached'),
});
assert.equal(handled, true);
assert.deepEqual(calls, ['direct:--sync-window']);
});
test('mpv pre-app command exits non-zero when socket is not ready', async () => {
const context = createContext();
context.args.mpvStatus = true;