mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-10-20 05:15:31 +00:00
refactor(desktop): extract VS Code Marketplace theme IPC from main.cjs into vscode-theme-ipc.cjs
Seventh main.cjs cluster peel. The two hermes:vscode-theme:* handlers (fetch,
search) move verbatim into electron/vscode-theme-ipc.cjs behind a
registerVscodeThemeIpc({ ipcMain }) registrar. Both delegate to the
vscode-marketplace sibling module, which the new module requires directly — so
the now-dead require in main.cjs is removed.
Channel names unchanged → preload + renderer untouched. Adds
electron/vscode-theme-ipc.test.cjs (surface invariant).
This commit is contained in:
parent
e167ed7bb1
commit
8a48d54193
3 changed files with 52 additions and 7 deletions
|
|
@ -41,7 +41,6 @@ const { adoptServedDashboardToken } = require('./dashboard-token.cjs')
|
|||
const { waitForDashboardPortAnnouncement } = require('./backend-ready.cjs')
|
||||
const { dashboardFallbackArgs, sourceDeclaresServe } = require('./backend-command.cjs')
|
||||
const { serializeJsonBody, setJsonRequestHeaders } = require('./oauth-net-request.cjs')
|
||||
const { fetchMarketplaceThemes, searchMarketplaceThemes } = require('./vscode-marketplace.cjs')
|
||||
const { buildDesktopBackendEnv, normalizeHermesHomeRoot } = require('./backend-env.cjs')
|
||||
const { readWindowsUserEnvVar } = require('./windows-user-env.cjs')
|
||||
const { readWslWindowsClipboardImage } = require('./wsl-clipboard-image.cjs')
|
||||
|
|
@ -62,6 +61,7 @@ const { registerTerminalIpc } = require('./terminal-ipc.cjs')
|
|||
const { registerUpdatesIpc } = require('./updates-ipc.cjs')
|
||||
const { registerLogsIpc } = require('./logs-ipc.cjs')
|
||||
const { registerProjectDirIpc } = require('./project-dir-ipc.cjs')
|
||||
const { registerVscodeThemeIpc } = require('./vscode-theme-ipc.cjs')
|
||||
const { OFFICIAL_REPO_HTTPS_URL, isOfficialSshRemote } = require('./update-remote.cjs')
|
||||
const { resolveBehindCount, shouldCountCommits } = require('./update-count.cjs')
|
||||
const { runRebuildWithRetry } = require('./update-rebuild.cjs')
|
||||
|
|
@ -7133,12 +7133,8 @@ ipcMain.handle('hermes:uninstall:run', async (_event, payload) => {
|
|||
return runDesktopUninstall(String(mode || ''))
|
||||
})
|
||||
|
||||
// Download a VS Code Marketplace extension and return the raw color-theme JSON
|
||||
// it contributes. No theme code is executed — we only read JSON from the .vsix.
|
||||
ipcMain.handle('hermes:vscode-theme:fetch', async (_event, id) => fetchMarketplaceThemes(String(id || '')))
|
||||
|
||||
// Search the Marketplace for color-theme extensions (empty query = top installs).
|
||||
ipcMain.handle('hermes:vscode-theme:search', async (_event, query) => searchMarketplaceThemes(String(query || ''), 20))
|
||||
// VS Code Marketplace theme IPC lives in vscode-theme-ipc.cjs.
|
||||
registerVscodeThemeIpc({ ipcMain })
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// hermes:// deep links (e.g. hermes://blueprint/morning-brief?time=08:00).
|
||||
|
|
|
|||
19
apps/desktop/electron/vscode-theme-ipc.cjs
Normal file
19
apps/desktop/electron/vscode-theme-ipc.cjs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
'use strict'
|
||||
|
||||
const { fetchMarketplaceThemes, searchMarketplaceThemes } = require('./vscode-marketplace.cjs')
|
||||
|
||||
// VS Code Marketplace color-theme IPC: fetch a theme by extension id + search the
|
||||
// marketplace. Both delegate to the vscode-marketplace sibling module; no theme
|
||||
// code is ever executed (only JSON is read from the .vsix).
|
||||
function registerVscodeThemeIpc({ ipcMain }) {
|
||||
// Download a VS Code Marketplace extension and return the raw color-theme JSON
|
||||
// it contributes. No theme code is executed — we only read JSON from the .vsix.
|
||||
ipcMain.handle('hermes:vscode-theme:fetch', async (_event, id) => fetchMarketplaceThemes(String(id || '')))
|
||||
|
||||
// Search the Marketplace for color-theme extensions (empty query = top installs).
|
||||
ipcMain.handle('hermes:vscode-theme:search', async (_event, query) =>
|
||||
searchMarketplaceThemes(String(query || ''), 20)
|
||||
)
|
||||
}
|
||||
|
||||
module.exports = { registerVscodeThemeIpc }
|
||||
30
apps/desktop/electron/vscode-theme-ipc.test.cjs
Normal file
30
apps/desktop/electron/vscode-theme-ipc.test.cjs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
'use strict'
|
||||
|
||||
const assert = require('node:assert/strict')
|
||||
const test = require('node:test')
|
||||
|
||||
const { registerVscodeThemeIpc } = require('./vscode-theme-ipc.cjs')
|
||||
|
||||
function fakeIpcMain() {
|
||||
const handlers = new Map()
|
||||
|
||||
return {
|
||||
handlers,
|
||||
handle(channel, handler) {
|
||||
assert.ok(!handlers.has(channel), `duplicate registration for ${channel}`)
|
||||
handlers.set(channel, handler)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
test('registerVscodeThemeIpc wires only hermes:vscode-theme:* channels, each to a handler fn', () => {
|
||||
const ipcMain = fakeIpcMain()
|
||||
|
||||
registerVscodeThemeIpc({ ipcMain })
|
||||
|
||||
assert.deepEqual([...ipcMain.handlers.keys()].sort(), ['hermes:vscode-theme:fetch', 'hermes:vscode-theme:search'])
|
||||
|
||||
for (const handler of ipcMain.handlers.values()) {
|
||||
assert.equal(typeof handler, 'function')
|
||||
}
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue