format remote-control files with Prettier

This commit is contained in:
Akshan Krithick
2026-03-14 21:41:56 -07:00
parent 8cbd715ee2
commit de62ef6b3f
2 changed files with 34 additions and 17 deletions

View File

@@ -45,14 +45,20 @@ describe('remote-control', () => {
stdoutFileContent = ''; stdoutFileContent = '';
// Default fs mocks // Default fs mocks
mkdirSyncSpy = vi.spyOn(fs, 'mkdirSync').mockImplementation(() => undefined as any); mkdirSyncSpy = vi
writeFileSyncSpy = vi.spyOn(fs, 'writeFileSync').mockImplementation(() => {}); .spyOn(fs, 'mkdirSync')
.mockImplementation(() => undefined as any);
writeFileSyncSpy = vi
.spyOn(fs, 'writeFileSync')
.mockImplementation(() => {});
unlinkSyncSpy = vi.spyOn(fs, 'unlinkSync').mockImplementation(() => {}); unlinkSyncSpy = vi.spyOn(fs, 'unlinkSync').mockImplementation(() => {});
openSyncSpy = vi.spyOn(fs, 'openSync').mockReturnValue(42 as any); openSyncSpy = vi.spyOn(fs, 'openSync').mockReturnValue(42 as any);
closeSyncSpy = vi.spyOn(fs, 'closeSync').mockImplementation(() => {}); closeSyncSpy = vi.spyOn(fs, 'closeSync').mockImplementation(() => {});
// readFileSync: return stdoutFileContent for the stdout file, state file, etc. // readFileSync: return stdoutFileContent for the stdout file, state file, etc.
readFileSyncSpy = vi.spyOn(fs, 'readFileSync').mockImplementation(((p: string) => { readFileSyncSpy = vi.spyOn(fs, 'readFileSync').mockImplementation(((
p: string,
) => {
if (p.endsWith('remote-control.stdout')) return stdoutFileContent; if (p.endsWith('remote-control.stdout')) return stdoutFileContent;
if (p.endsWith('remote-control.json')) { if (p.endsWith('remote-control.json')) {
throw Object.assign(new Error('ENOENT'), { code: 'ENOENT' }); throw Object.assign(new Error('ENOENT'), { code: 'ENOENT' });
@@ -74,7 +80,8 @@ describe('remote-control', () => {
spawnMock.mockReturnValue(proc); spawnMock.mockReturnValue(proc);
// Simulate URL appearing in stdout file on first poll // Simulate URL appearing in stdout file on first poll
stdoutFileContent = 'Session URL: https://claude.ai/code?bridge=env_abc123\n'; stdoutFileContent =
'Session URL: https://claude.ai/code?bridge=env_abc123\n';
vi.spyOn(process, 'kill').mockImplementation((() => true) as any); vi.spyOn(process, 'kill').mockImplementation((() => true) as any);
const result = await startRemoteControl('user1', 'tg:123', '/project'); const result = await startRemoteControl('user1', 'tg:123', '/project');
@@ -157,7 +164,9 @@ describe('remote-control', () => {
spawnMock.mockReturnValueOnce(proc1).mockReturnValueOnce(proc2); spawnMock.mockReturnValueOnce(proc1).mockReturnValueOnce(proc2);
// First start: process alive, URL found // First start: process alive, URL found
const killSpy = vi.spyOn(process, 'kill').mockImplementation((() => true) as any); const killSpy = vi
.spyOn(process, 'kill')
.mockImplementation((() => true) as any);
stdoutFileContent = 'https://claude.ai/code?bridge=env_first\n'; stdoutFileContent = 'https://claude.ai/code?bridge=env_first\n';
await startRemoteControl('user1', 'tg:123', '/project'); await startRemoteControl('user1', 'tg:123', '/project');
@@ -239,7 +248,9 @@ describe('remote-control', () => {
const proc = createMockProcess(55555); const proc = createMockProcess(55555);
spawnMock.mockReturnValue(proc); spawnMock.mockReturnValue(proc);
stdoutFileContent = 'https://claude.ai/code?bridge=env_stop\n'; stdoutFileContent = 'https://claude.ai/code?bridge=env_stop\n';
const killSpy = vi.spyOn(process, 'kill').mockImplementation((() => true) as any); const killSpy = vi
.spyOn(process, 'kill')
.mockImplementation((() => true) as any);
await startRemoteControl('user1', 'tg:123', '/project'); await startRemoteControl('user1', 'tg:123', '/project');
@@ -337,7 +348,9 @@ describe('remote-control', () => {
if (p.endsWith('remote-control.json')) return JSON.stringify(session); if (p.endsWith('remote-control.json')) return JSON.stringify(session);
return ''; return '';
}) as any); }) as any);
const killSpy = vi.spyOn(process, 'kill').mockImplementation((() => true) as any); const killSpy = vi
.spyOn(process, 'kill')
.mockImplementation((() => true) as any);
restoreRemoteControl(); restoreRemoteControl();
expect(getActiveSession()).not.toBeNull(); expect(getActiveSession()).not.toBeNull();
@@ -365,13 +378,15 @@ describe('remote-control', () => {
restoreRemoteControl(); restoreRemoteControl();
return startRemoteControl('user2', 'tg:456', '/project').then((result) => { return startRemoteControl('user2', 'tg:456', '/project').then(
expect(result).toEqual({ (result) => {
ok: true, expect(result).toEqual({
url: 'https://claude.ai/code?bridge=env_restored', ok: true,
}); url: 'https://claude.ai/code?bridge=env_restored',
expect(spawnMock).not.toHaveBeenCalled(); });
}); expect(spawnMock).not.toHaveBeenCalled();
},
);
}); });
}); });
}); });

View File

@@ -196,9 +196,11 @@ export async function startRemoteControl(
}); });
} }
export function stopRemoteControl(): { export function stopRemoteControl():
ok: true; | {
} | { ok: false; error: string } { ok: true;
}
| { ok: false; error: string } {
if (!activeSession) { if (!activeSession) {
return { ok: false, error: 'No active Remote Control session' }; return { ok: false, error: 'No active Remote Control session' };
} }