* Push a message that must be processed in isolation, preserving any * messages already queued ahead of it. The new message is never batched * with siblings (neither the ones before it, nor any that arrive after). * Use this when a slash command must run alone but earlier prompts must
(message: string, mode: T, localId?: string)
| 115 | * still be delivered in order. |
| 116 | */ |
| 117 | pushIsolated(message: string, mode: T, localId?: string): void { |
| 118 | if (this.closed) { |
| 119 | throw new Error('Cannot push to closed queue'); |
| 120 | } |
| 121 | |
| 122 | const modeHash = this.modeHasher(mode); |
| 123 | logger.debug(`[MessageQueue2] pushIsolated() called with mode hash: ${modeHash} - preserving ${this.queue.length} pending messages`); |
| 124 | |
| 125 | this.queue.push({ |
| 126 | message, |
| 127 | mode, |
| 128 | modeHash, |
| 129 | localId, |
| 130 | isolate: true |
| 131 | }); |
| 132 | |
| 133 | if (this.onMessageHandler) { |
| 134 | this.onMessageHandler(message, mode); |
| 135 | } |
| 136 | |
| 137 | if (this.waiter) { |
| 138 | logger.debug(`[MessageQueue2] Notifying waiter for isolated message`); |
| 139 | const waiter = this.waiter; |
| 140 | this.waiter = null; |
| 141 | waiter(true); |
| 142 | } |
| 143 | |
| 144 | logger.debug(`[MessageQueue2] pushIsolated() completed. Queue size: ${this.queue.length}`); |
| 145 | } |
| 146 | |
| 147 | /** |
| 148 | * Push a message that must be processed in complete isolation. |
no test coverage detected