fix(cli): Exit CLI when trust save unsuccessful during launch (#11968)

This commit is contained in:
shrutip90
2025-11-14 11:56:39 -08:00
committed by GitHub
parent 6d83d3440c
commit d683e1c0db
7 changed files with 174 additions and 30 deletions

View File

@@ -148,10 +148,11 @@ describe('PermissionsModifyTrustDialog', () => {
});
});
it('should commit, restart, and exit on `r` keypress', async () => {
it('should commit and restart `r` keypress', async () => {
const mockRelaunchApp = vi
.spyOn(processUtils, 'relaunchApp')
.mockResolvedValue(undefined);
mockCommitTrustLevelChange.mockReturnValue(true);
vi.mocked(usePermissionsModifyTrust).mockReturnValue({
cwd: '/test/dir',
currentTrustLevel: TrustLevel.DO_NOT_TRUST,
@@ -175,7 +176,6 @@ describe('PermissionsModifyTrustDialog', () => {
await waitFor(() => {
expect(mockCommitTrustLevelChange).toHaveBeenCalled();
expect(mockRelaunchApp).toHaveBeenCalled();
expect(onExit).toHaveBeenCalled();
});
mockRelaunchApp.mockRestore();

View File

@@ -62,9 +62,12 @@ export function PermissionsModifyTrustDialog({
onExit();
}
if (needsRestart && key.name === 'r') {
commitTrustLevelChange();
relaunchApp();
onExit();
const success = commitTrustLevelChange();
if (success) {
relaunchApp();
} else {
onExit();
}
}
},
{ isActive: true },