Skip to content

Commit 6303465

Browse files
committed
refactor: apply audit cleanup (reuse + simplify)
- domain-check: drop the redundant isIpLiteral guard (isLoopbackIp already validates and returns false for non-literals). - session.ts: use shared getErrorMessage instead of the local error ternary (the file already imports it). - tray.ts: use shared sleep() instead of a hand-rolled setTimeout promise. - updater.ts: distinguish the synchronous-throw log from the async-rejection log on the manual update check.
1 parent 1fff071 commit 6303465

4 files changed

Lines changed: 5 additions & 7 deletions

File tree

apps/desktop/src/main/browser-agent/session.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ function createTabView(): WebContentsView {
198198
void tab.view.webContents.loadURL(details.url).catch(() => {})
199199
} catch (error) {
200200
logger.warn('Could not open browser popup in a new tab', {
201-
error: error instanceof Error ? error.message : String(error),
201+
error: getErrorMessage(error),
202202
})
203203
}
204204
}

apps/desktop/src/main/tray.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { join } from 'node:path'
22
import { createLogger } from '@sim/logger'
3+
import { sleep } from '@sim/utils/helpers'
34
import type { MenuItemConstructorOptions, NativeImage } from 'electron'
45
import { app, Menu, nativeImage, session, Tray } from 'electron'
56
import { isSafeInternalPath } from '@/main/config'
@@ -285,10 +286,7 @@ export function installTray(deps: TrayDeps): TrayHandle | null {
285286
const EMPTY_CACHE_POP_GRACE_MS = 600
286287
const popMenu = async () => {
287288
if (cachedChats.length === 0) {
288-
await Promise.race([
289-
refreshChats(),
290-
new Promise((resolve) => setTimeout(resolve, EMPTY_CACHE_POP_GRACE_MS)),
291-
])
289+
await Promise.race([refreshChats(), sleep(EMPTY_CACHE_POP_GRACE_MS)])
292290
}
293291
if (tray.isDestroyed()) return
294292
tray.popUpContextMenu(Menu.buildFromTemplate(buildTrayMenuTemplate(deps, cachedChats)))

apps/desktop/src/main/updater.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,6 @@ export function checkForUpdatesInteractive(deps: UpdaterDeps): void {
238238
})
239239
})
240240
} catch (error) {
241-
logger.error('Manual update check failed', { error })
241+
logger.error('Manual update check threw synchronously', { error })
242242
}
243243
}

apps/sim/lib/mcp/domain-check.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export function validateMcpDomain(url: string | undefined): void {
104104
function isLocalhostHostname(hostname: string): boolean {
105105
const clean = hostname.toLowerCase()
106106
if (clean === 'localhost') return true
107-
return isIpLiteral(clean) && isLoopbackIp(clean)
107+
return isLoopbackIp(clean)
108108
}
109109

110110
/**

0 commit comments

Comments
 (0)