MCPcopy Index your code
hub / github.com/tiann/hapi / pushIsolateAndClear

Method pushIsolateAndClear

cli/src/utils/MessageQueue2.ts:152–185  ·  view source on GitHub ↗

* Push a message that must be processed in complete isolation. * Clears any pending messages and ensures this message is never batched with others. * Used for special commands that require dedicated processing.

(message: string, mode: T, localId?: string)

Source from the content-addressed store, hash-verified

150 * Used for special commands that require dedicated processing.
151 */
152 pushIsolateAndClear(message: string, mode: T, localId?: string): void {
153 if (this.closed) {
154 throw new Error('Cannot push to closed queue');
155 }
156
157 const modeHash = this.modeHasher(mode);
158 logger.debug(`[MessageQueue2] pushIsolateAndClear() called with mode hash: ${modeHash} - clearing ${this.queue.length} pending messages`);
159
160 // Clear any pending messages to ensure this message is processed in complete isolation
161 this.queue = [];
162
163 this.queue.push({
164 message,
165 mode,
166 modeHash,
167 localId,
168 isolate: true
169 });
170
171 // Trigger message handler if set
172 if (this.onMessageHandler) {
173 this.onMessageHandler(message, mode);
174 }
175
176 // Notify waiter if any
177 if (this.waiter) {
178 logger.debug(`[MessageQueue2] Notifying waiter for isolated message`);
179 const waiter = this.waiter;
180 this.waiter = null;
181 waiter(true);
182 }
183
184 logger.debug(`[MessageQueue2] pushIsolateAndClear() completed. Queue size: ${this.queue.length}`);
185 }
186
187 /**
188 * Push a message to the beginning of the queue with a mode.

Callers 6

createSessionStubFunction · 0.95
createSessionStubFunction · 0.95
createSessionStubFunction · 0.95
runCodexFunction · 0.95
runClaudeFunction · 0.95

Calls 2

debugMethod · 0.80
pushMethod · 0.45

Tested by 3

createSessionStubFunction · 0.76
createSessionStubFunction · 0.76
createSessionStubFunction · 0.76