* 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)
| 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. |
no test coverage detected