MCPcopy Create free account
hub / github.com/tiann/hapi / unshiftIsolated

Method unshiftIsolated

cli/src/utils/MessageQueue2.ts:229–256  ·  view source on GitHub ↗

* Push a message to the beginning of the queue with isolation preserved. * Mirrors `pushIsolated` but inserts at the head. Use this when requeueing a * batch that was originally collected under isolation (e.g. a slash command * that failed transiently and must retry without batching a

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

Source from the content-addressed store, hash-verified

227 * prompts).
228 */
229 unshiftIsolated(message: string, mode: T, localId?: string): void {
230 if (this.closed) {
231 throw new Error('Cannot unshift to closed queue');
232 }
233
234 const modeHash = this.modeHasher(mode);
235 logger.debug(`[MessageQueue2] unshiftIsolated() called with mode hash: ${modeHash}`);
236
237 this.queue.unshift({
238 message,
239 mode,
240 modeHash,
241 localId,
242 isolate: true
243 });
244
245 if (this.onMessageHandler) {
246 this.onMessageHandler(message, mode);
247 }
248
249 if (this.waiter) {
250 const waiter = this.waiter;
251 this.waiter = null;
252 waiter(true);
253 }
254
255 logger.debug(`[MessageQueue2] unshiftIsolated() completed. Queue size: ${this.queue.length}`);
256 }
257
258 /**
259 * Remove the first queued message that matches the given localId.

Callers 1

Calls 2

debugMethod · 0.80
unshiftMethod · 0.80

Tested by

no test coverage detected