MCPcopy Create free account
hub / github.com/anomalyco/opencode / groupBySession

Function groupBySession

packages/app/src/context/global-sync/bootstrap.ts:133–141  ·  view source on GitHub ↗
(input: T[])

Source from the content-addressed store, hash-verified

131}
132
133function groupBySession<T extends { id: string; sessionID: string }>(input: T[]) {
134 return input.reduce<Record<string, T[]>>((acc, item) => {
135 if (!item?.id || !item.sessionID) return acc
136 const list = acc[item.sessionID]
137 if (list) list.push(item)
138 if (!list) acc[item.sessionID] = [item]
139 return acc
140 }, {})
141}
142
143function projectID(directory: string, projects: Project[]) {
144 return projects.find((project) => project.worktree === directory || project.sandboxes?.includes(directory))?.id

Callers 1

bootstrapDirectoryFunction · 0.85

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected