summaryrefslogtreecommitdiff
path: root/src/preload/index.ts
diff options
context:
space:
mode:
authorhaoyuren <13851610112@163.com>2026-03-12 18:11:10 -0500
committerhaoyuren <13851610112@163.com>2026-03-12 18:11:10 -0500
commita0dd3d7ac642111faeaefd02c5a452898b9c6d49 (patch)
tree2f435e189bd38505b9793b78de51b3a1c282f1c6 /src/preload/index.ts
parentb116335f9dbde4f483c0b2b8e7bfca5d321c5dfc (diff)
Add collaborator cursors and project chat
Collaborator cursors: - Real-time cursor positions via clientTracking Socket.IO events - CM6 extension renders colored cursor widgets with name labels - Throttled cursor position broadcasting (300ms) - Connected users count in toolbar and status bar Project chat: - Chat panel in right sidebar (toggleable) - Load message history via REST API - Send messages with real-time delivery via Socket.IO new-chat-message - Auto-scroll, avatars, timestamps Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'src/preload/index.ts')
-rw-r--r--src/preload/index.ts27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/preload/index.ts b/src/preload/index.ts
index 5dcbbff..ca7f098 100644
--- a/src/preload/index.ts
+++ b/src/preload/index.ts
@@ -144,6 +144,33 @@ const api = {
syncContentChanged: (docId: string, content: string) =>
ipcRenderer.invoke('sync:contentChanged', docId, content),
+ // Cursor tracking
+ cursorUpdate: (docId: string, row: number, column: number) =>
+ ipcRenderer.invoke('cursor:update', docId, row, column),
+ cursorGetConnectedUsers: () =>
+ ipcRenderer.invoke('cursor:getConnectedUsers') as Promise<unknown[]>,
+ onCursorRemoteUpdate: (cb: (data: unknown) => void) => {
+ const handler = (_e: Electron.IpcRendererEvent, data: unknown) => cb(data)
+ ipcRenderer.on('cursor:remoteUpdate', handler)
+ return () => ipcRenderer.removeListener('cursor:remoteUpdate', handler)
+ },
+ onCursorRemoteDisconnected: (cb: (clientId: string) => void) => {
+ const handler = (_e: Electron.IpcRendererEvent, clientId: string) => cb(clientId)
+ ipcRenderer.on('cursor:remoteDisconnected', handler)
+ return () => ipcRenderer.removeListener('cursor:remoteDisconnected', handler)
+ },
+
+ // Chat
+ chatGetMessages: (projectId: string, limit?: number) =>
+ ipcRenderer.invoke('chat:getMessages', projectId, limit) as Promise<{ success: boolean; messages: unknown[] }>,
+ chatSendMessage: (projectId: string, content: string) =>
+ ipcRenderer.invoke('chat:sendMessage', projectId, content) as Promise<{ success: boolean }>,
+ onChatMessage: (cb: (msg: unknown) => void) => {
+ const handler = (_e: Electron.IpcRendererEvent, msg: unknown) => cb(msg)
+ ipcRenderer.on('chat:newMessage', handler)
+ return () => ipcRenderer.removeListener('chat:newMessage', handler)
+ },
+
// Shell
openExternal: (url: string) => ipcRenderer.invoke('shell:openExternal', url),
showInFinder: (path: string) => ipcRenderer.invoke('shell:showInFinder', path)