MCPcopy
hub / github.com/coder/mux / replay

Method replay

src/node/utils/eventStore.ts:140–161  ·  view source on GitHub ↗

* Replay events for a workspace. * Checks in-memory state first, falls back to disk. * Emits events using the provided emitEvent function. * * @param workspaceId - Workspace ID to replay events for * @param context - Optional context to pass to serializeState (e.g., workspaceId)

(workspaceId: string, context?: Record<string, unknown>)

Source from the content-addressed store, hash-verified

138 * @param context - Optional context to pass to serializeState (e.g., workspaceId)
139 */
140 async replay(workspaceId: string, context?: Record<string, unknown>): Promise<void> {
141 // Try in-memory state first (most recent)
142 let state: TState | undefined = this.stateMap.get(workspaceId);
143
144 // Fall back to disk if not in memory
145 if (!state) {
146 const diskState = await this.fileManager.read(workspaceId);
147 if (!diskState) {
148 return; // No state to replay
149 }
150 state = diskState;
151 }
152
153 // Augment state with context for serialization
154 const augmentedState = { ...state, ...context };
155
156 // Serialize state into events and emit them
157 const events = this.serializeState(augmentedState);
158 for (const event of events) {
159 this.emitEvent(event);
160 }
161 }
162
163 /**
164 * Get all workspace IDs with in-memory state.

Callers 2

eventStore.test.tsFile · 0.80
replayInitMethod · 0.80

Calls 2

getMethod · 0.65
readMethod · 0.45

Tested by

no test coverage detected