MCPcopy Index your code
hub / github.com/ChatLab/ChatLab / addSessions

Method addSessions

packages/sync/src/data-source-manager.ts:144–167  ·  view source on GitHub ↗
(sourceId: string, sessions: Array<{ name: string; remoteSessionId: string }>)

Source from the content-addressed store, hash-verified

142 // ==================== ImportSession CRUD ====================
143
144 addSessions(sourceId: string, sessions: Array<{ name: string; remoteSessionId: string }>): ImportSession[] {
145 const sources = this.loadAll()
146 const ds = sources.find((s) => s.id === sourceId)
147 if (!ds) return []
148
149 const added: ImportSession[] = []
150 for (const sess of sessions) {
151 if (ds.sessions.some((s) => s.remoteSessionId === sess.remoteSessionId)) continue
152 const imp: ImportSession = {
153 id: generateId('sess'),
154 name: sess.name,
155 remoteSessionId: sess.remoteSessionId,
156 targetSessionId: '',
157 lastPullAt: 0,
158 lastStatus: 'idle',
159 lastError: '',
160 lastNewMessages: 0,
161 }
162 ds.sessions.push(imp)
163 added.push(imp)
164 }
165 this.saveAll(sources)
166 return added
167 }
168
169 removeSession(sourceId: string, sessionId: string): ImportSession | null {
170 const sources = this.loadAll()

Callers 3

registerApiHandlersFunction · 0.80
routes.test.tsFile · 0.80
registerAutomationRoutesFunction · 0.80

Calls 3

loadAllMethod · 0.95
saveAllMethod · 0.95
generateIdFunction · 0.70

Tested by

no test coverage detected