Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

feat(desktop): add profile IPC handlers

Jiang Bohana157c6546dc8
diff --git a/apps/desktop/electron/electron-env.d.ts b/apps/desktop/electron/electron-env.d.ts
index 583a19b966..c92ef48a2d 100644
--- a/apps/desktop/electron/electron-env.d.ts
+++ b/apps/desktop/electron/electron-env.d.ts
@@ -65,6 +65,12 @@ interface SkillAddResult {
skills?: string[]
}
+interface ProfileData {
+ profileId: string | undefined
+ name: string | undefined
+ userContent: string | undefined
+}
+
interface ElectronAPI {
hub: {
init: () => Promise<unknown>
@@ -97,6 +103,11 @@ interface ElectronAPI {
agent: {
status: () => Promise<unknown>
}
+ profile: {
+ get: () => Promise<ProfileData>
+ updateName: (name: string) => Promise<unknown>
+ updateUser: (content: string) => Promise<unknown>
+ }
}
// Used in Renderer process, expose in `preload.ts`
diff --git a/apps/desktop/electron/ipc/index.ts b/apps/desktop/electron/ipc/index.ts
index 71bbec888b..762fe18fd4 100644
--- a/apps/desktop/electron/ipc/index.ts
+++ b/apps/desktop/electron/ipc/index.ts
@@ -4,10 +4,12 @@
export { registerAgentIpcHandlers, cleanupAgent } from './agent.js'
export { registerSkillsIpcHandlers } from './skills.js'
export { registerHubIpcHandlers, cleanupHub, initializeHub } from './hub.js'
+export { registerProfileIpcHandlers } from './profile.js'
import { registerAgentIpcHandlers, cleanupAgent } from './agent.js'
import { registerSkillsIpcHandlers } from './skills.js'
import { registerHubIpcHandlers, cleanupHub, initializeHub } from './hub.js'
+import { registerProfileIpcHandlers } from './profile.js'
/**
* Register all IPC handlers.
@@ -17,6 +19,7 @@ export function registerAllIpcHandlers(): void {
registerHubIpcHandlers()
registerAgentIpcHandlers()
registerSkillsIpcHandlers()
+ registerProfileIpcHandlers()
}
/**
diff --git a/apps/desktop/electron/ipc/profile.ts b/apps/desktop/electron/ipc/profile.ts
new file mode 100644
index 0000000000..bfb924da54
--- /dev/null
+++ b/apps/desktop/electron/ipc/profile.ts
@@ -0,0 +1,80 @@
+/**
+ * Profile IPC handlers for Electron main process.
+ *
+ * Manages agent profile settings like name and user.md content.
+ */
+import { ipcMain } from 'electron'
+import { getCurrentHub } from './hub.js'
+
+/**
+ * Get the default agent from Hub.
+ */
+function getDefaultAgent() {
+ const hub = getCurrentHub()
+ if (!hub) return null
+
+ const agentIds = hub.listAgents()
+ if (agentIds.length === 0) return null
+
+ return hub.getAgent(agentIds[0]) ?? null
+}
+
+/**
+ * Profile data returned to renderer.
+ */
+export interface ProfileData {
+ profileId: string | undefined
+ name: string | undefined
+ userContent: string | undefined
+}
+
+/**
+ * Register all Profile-related IPC handlers.
+ */
+export function registerProfileIpcHandlers(): void {
+ /**
+ * Get profile data (name + user content).
+ */
+ ipcMain.handle('profile:get', async (): Promise<ProfileData> => {
+ const agent = getDefaultAgent()
+ if (!agent) {
+ return {
+ profileId: undefined,
+ name: undefined,
+ userContent: undefined,
+ }
+ }
+
+ return {
+ profileId: agent.getProfileId(),
+ name: agent.getAgentName(),
+ userContent: agent.getUserContent(),
+ }
+ })
+
+ /**
+ * Update agent display name.
+ */
+ ipcMain.handle('profile:updateName', async (_event, name: string) => {
+ const agent = getDefaultAgent()
+ if (!agent) {
+ return { error: 'No agent available' }
+ }
+
+ agent.setAgentName(name)
+ return { ok: true, name }
+ })
+
+ /**
+ * Update user.md content.
+ */
+ ipcMain.handle('profile:updateUser', async (_event, content: string) => {
+ const agent = getDefaultAgent()
+ if (!agent) {
+ return { error: 'No agent available' }
+ }
+
+ agent.setUserContent(content)
+ return { ok: true }
+ })
+}
diff --git a/apps/desktop/electron/preload.ts b/apps/desktop/electron/preload.ts
index 8c89881991..e0afbf9a03 100644
--- a/apps/desktop/electron/preload.ts
+++ b/apps/desktop/electron/preload.ts
@@ -37,6 +37,12 @@ export interface SkillInfo {
triggers: string[]
}
+export interface ProfileData {
+ profileId: string | undefined
+ name: string | undefined
+ userContent: string | undefined
+}
+
// ============================================================================
// Expose typed API to Renderer process
// ============================================================================
@@ -84,6 +90,13 @@ const electronAPI = {
agent: {
status: () => ipcRenderer.invoke('agent:status'),
},
+
+ // Profile management
+ profile: {
+ get: (): Promise<ProfileData> => ipcRenderer.invoke('profile:get'),
+ updateName: (name: string) => ipcRenderer.invoke('profile:updateName', name),
+ updateUser: (content: string) => ipcRenderer.invoke('profile:updateUser', content),
+ },
}
// Expose to renderer