MCPcopy Create free account
hub / github.com/arctic-cli/interface / sync

Function sync

packages/arctic/src/cli/cmd/tui/context/sync.tsx:499–521  ·  view source on GitHub ↗
(sessionID: string)

Source from the content-addressed store, hash-verified

497 return last.time.completed ? "idle" : "working"
498 },
499 async sync(sessionID: string) {
500 if (fullSyncedSessions.has(sessionID)) return
501 const [session, messages, todo, diff] = await Promise.all([
502 sdk.client.session.get({ sessionID }, { throwOnError: true }),
503 sdk.client.session.messages({ sessionID, limit: 100 }),
504 sdk.client.session.todo({ sessionID }),
505 sdk.client.session.diff({ sessionID }),
506 ])
507 setStore(
508 produce((draft) => {
509 const match = Binary.search(draft.session, sessionID, (s) => s.id)
510 if (match.found) draft.session[match.index] = session.data!
511 if (!match.found) draft.session.splice(match.index, 0, session.data!)
512 draft.todo[sessionID] = todo.data ?? []
513 draft.message[sessionID] = (messages.data ?? []).map((x) => x.info)
514 for (const message of messages.data ?? []) {
515 draft.part[message.info.id] = message.parts
516 }
517 draft.session_diff[sessionID] = diff.data ?? []
518 }),
519 )
520 fullSyncedSessions.add(sessionID)
521 },
522 },
523 bootstrap,
524 }

Callers

nothing calls this directly

Calls 5

getMethod · 0.45
messagesMethod · 0.45
todoMethod · 0.45
diffMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected