@in-the-loop-labs/pair-review 5.3.1 → 5.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -158,11 +158,15 @@ class AIProvider {
158
158
  }
159
159
 
160
160
  /**
161
- * Get the default model for this provider
162
- * @returns {string}
161
+ * Get the default model for this provider: the built-in entry flagged
162
+ * `default: true`. Move that flag to change a provider's default.
163
+ * @returns {string|null} Model id, or null when no entry is flagged
163
164
  */
164
165
  static getDefaultModel() {
165
- throw new Error('getDefaultModel() must be implemented by subclass');
166
+ // In a static method, `this` is the class the method was called on
167
+ // (e.g. CodexProvider.getDefaultModel()), so this reads that provider's
168
+ // own catalog. `?.` and `?? null` return null when no entry is flagged.
169
+ return this.getModels().find(m => m.default)?.id ?? null;
166
170
  }
167
171
 
168
172
  /**
@@ -589,8 +593,8 @@ function resolveCliModelConfig(builtIn, configModel, modelId) {
589
593
  /**
590
594
  * Match a model definition against a selector that may be the model's canonical
591
595
  * id OR one of its aliases. Used by config-driven selectors (`default_model`,
592
- * `disabled_models`, `models` overrides) so legacy config naming an alias (e.g.
593
- * `opus`, an alias of the canonical `opus-4.8-xhigh`) keeps working.
596
+ * `models` overrides) so legacy config naming an alias (e.g.
597
+ * `opus`, an alias of the canonical `opus-5.5-xhigh`) keeps working.
594
598
  *
595
599
  * Optional-chaining is intentional: a model with no `aliases` short-circuits to
596
600
  * undefined/falsy, so no Array.isArray guard is needed.
@@ -781,7 +785,7 @@ function applyConfigOverrides(config) {
781
785
 
782
786
  // Canonicalize alias-keyed override ids to their built-in canonical id.
783
787
  // A config entry may key a model by a short alias (e.g. `opus` for the
784
- // canonical `opus-4.8-xhigh`). mergeModels() already resolves aliases for the
788
+ // canonical `opus-5.5-xhigh`). mergeModels() already resolves aliases for the
785
789
  // display/metadata path, but the runtime path forwards this raw `models` array
786
790
  // to the provider instance, where per-model config is looked up by EXACT id
787
791
  // (e.g. `configOverrides.models.find(m => m.id === model)`). The frontend
@@ -893,7 +897,7 @@ function mergeModels(builtInModels, configModels) {
893
897
  }
894
898
  // Replace overridden built-ins in-place to preserve display order. An override
895
899
  // matched by alias (e.g. config `{ id: 'opus' }` against built-in
896
- // `opus-4.8-xhigh`) still replaces, but keeps the canonical built-in id.
900
+ // `opus-5.5-xhigh`) still replaces, but keeps the canonical built-in id.
897
901
  const matched = new Set();
898
902
  const merged = builtInModels.map(bm => {
899
903
  const override = configModels.find(cm => modelMatches(bm, cm.id));
@@ -914,7 +918,8 @@ function mergeModels(builtInModels, configModels) {
914
918
 
915
919
  /**
916
920
  * Compute the effective model list for a provider: built-in models merged with
917
- * config-override models, then with any `disabled_models` IDs removed.
921
+ * config-override models, then with any `disabled_models` IDs removed. Only
922
+ * canonical ids disable a model; aliases are ignored (see below).
918
923
  *
919
924
  * This is the single source of truth for "which models does this provider
920
925
  * actually expose" — every call site that surfaces or selects a model should go
@@ -936,8 +941,11 @@ function applyModelOverrides(builtInModels, overrides) {
936
941
  if (!Array.isArray(disabled) || disabled.length === 0) {
937
942
  return merged;
938
943
  }
939
- // Drop a model if ANY disabled selector matches it by canonical id or alias.
940
- const filtered = merged.filter(m => !disabled.some(d => modelMatches(m, d)));
944
+ // Drop a model only when a disabled selector names its canonical id. Aliases
945
+ // are deliberately not matched: they include redirects for retired ids (e.g.
946
+ // `opus-4.7-high` -> `opus-5.5-high`), so a list that hid an old model would
947
+ // otherwise hide the newer model that inherited its id.
948
+ const filtered = merged.filter(m => !disabled.includes(m.id));
941
949
  // Never strip a provider down to zero models — fall back to the unfiltered set.
942
950
  return filtered.length > 0 ? filtered : merged;
943
951
  }
@@ -982,11 +990,15 @@ function validateModelSelectors(providerId, builtInModels, configModels, disable
982
990
 
983
991
  if (disabledModels) {
984
992
  for (const id of disabledModels) {
985
- if (!isKnown(id)) {
993
+ if (merged.some(m => m.id === id)) continue;
994
+ const aliased = merged.find(m => modelMatches(m, id));
995
+ if (aliased) {
996
+ logger.warn(`Provider "${providerId}": disabled_models entry "${id}" is an alias of "${aliased.id}", not an id; disabled_models needs canonical ids. Ignored.`);
997
+ } else {
986
998
  logger.warn(`Provider "${providerId}": disabled_models references unknown model "${id}".`);
987
999
  }
988
1000
  }
989
- const remaining = merged.filter(m => !disabledModels.some(d => modelMatches(m, d)));
1001
+ const remaining = merged.filter(m => !disabledModels.includes(m.id));
990
1002
  if (merged.length > 0 && remaining.length === 0) {
991
1003
  logger.warn(`Provider "${providerId}": disabled_models removes every model; the filter will be ignored.`);
992
1004
  }
@@ -995,7 +1007,7 @@ function validateModelSelectors(providerId, builtInModels, configModels, disable
995
1007
  if (defaultModel != null) {
996
1008
  if (!isKnown(defaultModel)) {
997
1009
  logger.warn(`Provider "${providerId}": default_model "${defaultModel}" is not a known model; falling back to automatic default.`);
998
- } else if (disabledModels && disabledModels.includes(defaultModel)) {
1010
+ } else if (disabledModels && disabledModels.includes(merged.find(m => modelMatches(m, defaultModel)).id)) {
999
1011
  logger.warn(`Provider "${providerId}": default_model "${defaultModel}" is also listed in disabled_models; falling back to automatic default.`);
1000
1012
  }
1001
1013
  }
@@ -18,11 +18,38 @@
18
18
  * - OMP's `autoResume` setting reopens the most recent session in the cwd
19
19
  * when no session flag is passed, so new chats must explicitly request a
20
20
  * fresh session via the `new_session` RPC command before session discovery.
21
+ * - OMP emits session events Pi does not: `notice` diagnostics and status-line
22
+ * updates (advisor, compaction, retry, ...). See _handleOtherEvent.
21
23
  */
22
24
 
23
25
  const PiBridge = require('./pi-bridge');
24
26
  const logger = require('../utils/logger');
25
27
 
28
+ /**
29
+ * OMP session events that only drive its TUI status line. They carry nothing
30
+ * the chat panel renders, so they are acknowledged at debug level rather than
31
+ * reported as unhandled. Mirrors the informational members of OMP's
32
+ * `AgentSessionEvent` union (src/session/agent-session-events.ts).
33
+ */
34
+ const OMP_STATUS_EVENTS = new Set([
35
+ 'advisor_cost_changed',
36
+ 'advisor_yielded',
37
+ 'auto_compaction_end',
38
+ 'auto_compaction_start',
39
+ 'auto_retry_end',
40
+ 'auto_retry_start',
41
+ 'config_warnings_changed',
42
+ 'goal_updated',
43
+ 'irc_message',
44
+ 'model_changed',
45
+ 'retry_fallback_applied',
46
+ 'retry_fallback_succeeded',
47
+ 'thinking_level_changed',
48
+ 'todo_auto_clear',
49
+ 'todo_reminder',
50
+ 'ttsr_triggered',
51
+ ]);
52
+
26
53
  class OmpBridge extends PiBridge {
27
54
  /**
28
55
  * @param {Object} options - Same options as PiBridge, except:
@@ -55,6 +82,35 @@ class OmpBridge extends PiBridge {
55
82
  this._splitProviderModel = false;
56
83
  }
57
84
 
85
+ /**
86
+ * Handle OMP-only session events. A `notice` is OMP reporting a problem or
87
+ * status of its own (config warnings, advisor quota, session persistence
88
+ * failures), so it is logged at its own level; status-line events are
89
+ * acknowledged quietly.
90
+ * @param {Object} event - The parsed event
91
+ */
92
+ _handleOtherEvent(event) {
93
+ if (event.type === 'notice') {
94
+ const source = event.source ? ` (${event.source})` : '';
95
+ const text = `[${this.logName}] OMP notice${source}: ${event.message}`;
96
+ if (event.level === 'error') {
97
+ logger.error(text);
98
+ } else if (event.level === 'warning') {
99
+ logger.warn(text);
100
+ } else {
101
+ logger.debug(text);
102
+ }
103
+ return;
104
+ }
105
+
106
+ if (OMP_STATUS_EVENTS.has(event.type)) {
107
+ logger.debug(`[${this.logName}] ${event.type}`);
108
+ return;
109
+ }
110
+
111
+ super._handleOtherEvent(event);
112
+ }
113
+
58
114
  /**
59
115
  * No sessionPath means this is a new chat. Launching OMP without a session
60
116
  * flag would let its `autoResume` setting reopen the user's most recent
@@ -76,6 +76,12 @@ class PiBridge extends EventEmitter {
76
76
  // Accumulate text across streaming deltas for each turn
77
77
  this._accumulatedText = '';
78
78
  this._inMessage = false;
79
+ // OMP pause tracking (see _handleAgentEnd). _continuing: a non-terminal
80
+ // agent_end arrived and the run's terminal agent_end has not, so the agent
81
+ // still owns the turn. _paused: the part of that window before the resumed
82
+ // run's agent_start, while OMP has no agent loop running.
83
+ this._continuing = false;
84
+ this._paused = false;
79
85
  // Pending callbacks for RPC responses keyed by command type
80
86
  this._pendingCallbacks = new Map();
81
87
  }
@@ -133,11 +139,18 @@ class PiBridge extends EventEmitter {
133
139
 
134
140
  if (!this._closing) {
135
141
  logger.warn(`[${this.logName}] Process exited unexpectedly (code=${code}, signal=${signal})`);
142
+ // A paused run's reply up to the pause is finished text that OMP
143
+ // reported with an agent_end; save it rather than lose it with the
144
+ // process. No terminal agent_end can follow now.
145
+ if (this._continuing) this._handleAgentEnd({});
136
146
  this.emit('error', { error: new Error(`${this.cliName} process exited (code=${code}, signal=${signal})`) });
137
147
  } else {
138
148
  logger.info(`[${this.logName}] Process exited (code=${code}, signal=${signal})`);
139
149
  }
140
150
 
151
+ this._inMessage = false;
152
+ this._continuing = false;
153
+ this._paused = false;
141
154
  this.emit('close');
142
155
  });
143
156
 
@@ -206,6 +219,14 @@ class PiBridge extends EventEmitter {
206
219
  const command = JSON.stringify({ type: 'abort' });
207
220
  logger.debug(`[${this.logName}] Sending abort`);
208
221
  this._write(command);
222
+ // OMP answers an abort during a pause with no agent_end: no agent loop is
223
+ // running for it to stop. End the paused run here so its reply so far is
224
+ // saved and 'complete' fires. Once the run has resumed (agent_start), OMP
225
+ // ends the aborted loop with its own terminal agent_end instead.
226
+ if (this._paused) {
227
+ logger.debug(`[${this.logName}] Abort during a pause; ending the run`);
228
+ this._handleAgentEnd({});
229
+ }
209
230
  }
210
231
 
211
232
  /**
@@ -216,6 +237,10 @@ class PiBridge extends EventEmitter {
216
237
  if (!this._process) return;
217
238
 
218
239
  this._closing = true;
240
+ // Emit the paused reply while the session manager is still listening,
241
+ // so its complete handler saves it to chat_messages. The process close
242
+ // event cannot: listeners are gone by then, and _closing skips it.
243
+ if (this._continuing) this._handleAgentEnd({});
219
244
  this.removeAllListeners();
220
245
 
221
246
  // Try to abort any in-flight work first
@@ -262,11 +287,14 @@ class PiBridge extends EventEmitter {
262
287
  }
263
288
 
264
289
  /**
265
- * Check if the bridge is currently processing a message.
290
+ * Check if the bridge is currently processing a message. A run paused by a
291
+ * non-terminal agent_end stays busy until its terminal agent_end: a prompt
292
+ * sent in the gap would start a new turn and drop the reply accumulated so
293
+ * far, which has not been saved yet.
266
294
  * @returns {boolean}
267
295
  */
268
296
  isBusy() {
269
- return this._inMessage;
297
+ return this._inMessage || this._continuing;
270
298
  }
271
299
 
272
300
  // ---------------------------------------------------------------------------
@@ -462,6 +490,10 @@ class PiBridge extends EventEmitter {
462
490
  callback(event);
463
491
  } else if (!event.success) {
464
492
  logger.error(`[${this.logName}] Command failed: ${event.error}`);
493
+ // OMP reports a failed prompt after the run's last agent_end. If
494
+ // that was a pause, nothing may resume it, and a run left paused
495
+ // keeps the bridge busy for good.
496
+ if (event.command === 'prompt' && this._paused) this._handleAgentEnd({});
465
497
  this.emit('error', { error: new Error(event.error || 'Unknown command error') });
466
498
  } else {
467
499
  logger.debug(`[${this.logName}] Command acknowledged: ${JSON.stringify(event).substring(0, 200)}`);
@@ -469,6 +501,11 @@ class PiBridge extends EventEmitter {
469
501
  break;
470
502
 
471
503
  case 'agent_start':
504
+ // A paused OMP run resumes in a new agent loop (see _handleAgentEnd)
505
+ this._paused = false;
506
+ logger.debug(`[${this.logName}] ${type}`);
507
+ this.emit('status', { status: 'working' });
508
+ break;
472
509
  case 'turn_start':
473
510
  logger.debug(`[${this.logName}] ${type}`);
474
511
  this.emit('status', { status: 'working' });
@@ -486,10 +523,20 @@ class PiBridge extends EventEmitter {
486
523
  break;
487
524
 
488
525
  default:
489
- logger.debug(`[${this.logName}] Unhandled event type: ${type}`);
526
+ this._handleOtherEvent(event);
490
527
  }
491
528
  }
492
529
 
530
+ /**
531
+ * Handle an event type the shared switch in _handleLine does not recognize.
532
+ * Subclasses override this for CLI-specific events (see OmpBridge) and fall
533
+ * back to super for anything they do not recognize either.
534
+ * @param {Object} event - The parsed event
535
+ */
536
+ _handleOtherEvent(event) {
537
+ logger.debug(`[${this.logName}] Unhandled event type: ${event.type}`);
538
+ }
539
+
493
540
  /**
494
541
  * Handle a message_update event containing streaming content deltas.
495
542
  * @param {Object} event - The message_update event
@@ -547,12 +594,32 @@ class PiBridge extends EventEmitter {
547
594
  /**
548
595
  * Handle agent_end event which signals the completion of the agent's work.
549
596
  * Emits 'complete' with the full accumulated text.
550
- * @param {Object} _event - The agent_end event
597
+ *
598
+ * OMP marks a scheduling pause with `isTerminal: false` — an async job
599
+ * result, a queued advisor steer, or a compaction/retry continuation will
600
+ * resume the loop, and a terminal agent_end follows. Completing on the pause
601
+ * would persist a truncated reply and finalize the chat UI while the agent
602
+ * keeps working, so keep accumulating instead. Pi never sets the field, so
603
+ * every Pi agent_end is terminal.
604
+ *
605
+ * The pause stays open (isBusy) until the terminal agent_end, or until
606
+ * abort(), a failed prompt, close(), or process exit ends it through this
607
+ * method.
608
+ * @param {Object} event - The agent_end event
551
609
  */
552
- _handleAgentEnd(_event) {
610
+ _handleAgentEnd(event) {
611
+ if (event?.isTerminal === false) {
612
+ this._continuing = true;
613
+ this._paused = true;
614
+ logger.debug(`[${this.logName}] Non-terminal agent_end; waiting for the agent to resume`);
615
+ return;
616
+ }
617
+
553
618
  const fullText = this._accumulatedText;
554
619
  this._accumulatedText = '';
555
620
  this._inMessage = false;
621
+ this._continuing = false;
622
+ this._paused = false;
556
623
 
557
624
  logger.debug(`[${this.logName}] Agent ended, accumulated ${fullText.length} chars`);
558
625
  this.emit('complete', { fullText });
@@ -33,6 +33,9 @@ const CHAT_TOOLS = 'read,bash,grep,find,ls';
33
33
  // comment block in src/ai/omp-provider.js for detail.
34
34
  const OMP_CHAT_TOOLS = 'read,bash,grep,glob,task';
35
35
 
36
+ /** Error code sendMessage() sets when the agent still owns the previous turn. */
37
+ const SESSION_BUSY = 'SESSION_BUSY';
38
+
36
39
  class ChatSessionManager {
37
40
  /**
38
41
  * @param {Database} db - better-sqlite3 database instance
@@ -66,7 +69,7 @@ class ChatSessionManager {
66
69
  const selector = model || providerDef?.model || null;
67
70
 
68
71
  // Canonicalise BEFORE the INSERT. Both the request and `chat_providers.<id>.model`
69
- // may name a model by alias (`opus` -> `opus-4.8-xhigh`); storing the alias would
72
+ // may name a model by alias (`opus` -> `opus-5.5-xhigh`); storing the alias would
70
73
  // leave the sessions list, the hook payload, and the picker's checkmark disagreeing
71
74
  // with the catalog. `resolution.id` is exactly what to store: the canonical id when
72
75
  // known, the raw selector for a passthrough (raw CLI strings are supported), and
@@ -165,7 +168,10 @@ class ChatSessionManager {
165
168
  }
166
169
 
167
170
  if (session.bridge.isBusy()) {
168
- throw new Error(`Session ${sessionId} is currently processing a message`);
171
+ // Checked before the message is stored, so a rejected send leaves no trace.
172
+ const busy = new Error(`Session ${sessionId} is currently processing a message`);
173
+ busy.code = SESSION_BUSY;
174
+ throw busy;
169
175
  }
170
176
 
171
177
  // Build the message for the agent: initialContext > context > userMessage
@@ -844,3 +850,4 @@ class ChatSessionManager {
844
850
  }
845
851
 
846
852
  module.exports = ChatSessionManager;
853
+ module.exports.SESSION_BUSY = SESSION_BUSY;
package/src/config.js CHANGED
@@ -68,12 +68,12 @@ const DEFAULT_CONFIG = {
68
68
  single_port: true, // When true, reuse a single server on the configured port; new invocations delegate to the running server
69
69
  theme: "light",
70
70
  default_provider: "claude", // AI provider: 'claude', 'antigravity', 'codex', 'copilot', 'opencode', 'cursor-agent', 'pi', 'omp', 'muse'
71
- default_model: "opus", // Model within the provider (e.g., 'opus' for Claude, 'gemini-3.8-flash-high' for Antigravity)
71
+ default_model: "opus-5.5-high", // Model within the provider (e.g., 'opus-5.5-high' for Claude, 'gemini-3.8-flash-high' for Antigravity)
72
72
  tours: {
73
73
  enabled: false, // When true, the guided-tour feature is available (toolbar button visible, etc.)
74
74
  auto_generate: true, // When true, a tour generation job is kicked off automatically on review load
75
75
  provider: "", // Provider for agentic tour generation. Empty = falls back to summaries.provider, then default_provider
76
- model: "" // Model for tour generation. Empty = falls back to summaries.model resolution
76
+ model: "" // Model for tour generation. Empty = uses summaries.model, then the provider's default model, then default_model
77
77
  },
78
78
  summaries: {
79
79
  enabled: false, // When true, the hunk-summaries feature is available (toolbar button + per-file toggles visible)
@@ -233,7 +233,7 @@ function getSummaryProvider(config) {
233
233
  }
234
234
 
235
235
  /**
236
- * Gets the summary model for summary/tour generation
236
+ * Gets the model for hunk-summary generation
237
237
  * Resolution order: summaries.model → providerClass fast-tier → provider
238
238
  * default (when the summary provider differs from the global default
239
239
  * provider) → default_model
@@ -291,15 +291,36 @@ function getTourProvider(config) {
291
291
 
292
292
  /**
293
293
  * Gets the model for tour generation.
294
- * Resolution order: tours.model → summaries.model → providerClass fast-tier → default_model
294
+ * Resolution order: tours.model → summaries.model → providerClass built-in
295
+ * default → default_model
296
+ *
297
+ * Unlike getSummaryModel, this does not pick the fast tier: a tour is an
298
+ * agentic walk of the codebase, which calls for the provider's default model.
299
+ * The provider default wins even when the tour provider IS the global
300
+ * default provider — configs written before a default-model change still
301
+ * carry the old global `default_model`, and that should not decide the tour
302
+ * model. An explicit `summaries.model` still applies. Providers with no
303
+ * built-in default (e.g. OpenCode returns null) fall through to
304
+ * default_model.
305
+ *
306
+ * Known limitation (same as getSummaryModel): this reads the provider class's
307
+ * STATIC built-in default, so per-provider config overrides
308
+ * (`providers.<id>.models` / `default_model` / `disabled_models`) are not
309
+ * applied here.
310
+ *
295
311
  * @param {Object} config - Configuration object
296
- * @param {Function} [providerClass] - Optional provider class with static getModels()
312
+ * @param {Function} [providerClass] - Optional provider class with static getDefaultModel()
297
313
  * @returns {string} - Model name
298
314
  */
299
315
  function getTourModel(config, providerClass = null) {
300
- const explicit = config && config.tours && config.tours.model;
316
+ const explicit = (config && config.tours && config.tours.model)
317
+ || (config && config.summaries && config.summaries.model);
301
318
  if (explicit) return explicit;
302
- return getSummaryModel(config, providerClass);
319
+ if (providerClass && typeof providerClass.getDefaultModel === 'function') {
320
+ const providerDefault = providerClass.getDefaultModel();
321
+ if (providerDefault) return providerDefault;
322
+ }
323
+ return getDefaultModel(config);
303
324
  }
304
325
 
305
326
  /**
package/src/main.js CHANGED
@@ -230,18 +230,18 @@ OPTIONS:
230
230
  --model <name> Override the AI model. Claude Code is the default provider.
231
231
  Available models: opus, sonnet, haiku (Claude Code);
232
232
  also: fable-5.1-xhigh, fable-5.1-high,
233
- fable-5-xhigh, fable-5-high, opus-5-xhigh,
234
- opus-5-high, opus-4.8-xhigh, opus-4.8-high,
235
- opus-4.7-xhigh, opus-4.7-high, opus-4.6-high,
236
- opus-4.6-1m, sonnet-5-xhigh, sonnet-5-high,
237
- sonnet-4.6
238
- (default is opus-5-high; opus is Opus 4.8 XHigh)
233
+ fable-5-xhigh, fable-5-high, opus-5.5-xhigh,
234
+ opus-5.5-high, opus-5.5-medium, opus-5.5-low,
235
+ opus-5-xhigh, opus-5-high,
236
+ sonnet-5-xhigh, sonnet-5-high, sonnet-4.6
237
+ (default is opus-5.5-high; opus is Opus 5.5 XHigh;
238
+ a saved default_model wins over the default)
239
239
  or use provider-specific models with Antigravity/Codex
240
240
  --provider <name> Override the AI provider for headless modes
241
241
  (--ai-draft / --ai-review). Defaults to the
242
242
  repo/app default provider (claude). Pair with
243
243
  --model when the model belongs to a non-default
244
- provider (e.g. --provider codex --model gpt-5.5).
244
+ provider (e.g. --provider codex --model gpt-5.6-sol-high).
245
245
  Available: claude, antigravity, codex, copilot,
246
246
  opencode, cursor-agent, pi, omp, muse
247
247
  --council <handle> Run analysis with a saved council (multi-voice). Handle is a
@@ -152,7 +152,7 @@ function sanitizeSingleConfig(config) {
152
152
  // to the provider's own default rather than forwarding an invalid pair. Unknown
153
153
  // providers (custom/unavailable, not in the registry) pass through unchanged.
154
154
  // A model "belongs" to the provider if config.model matches a model id OR one of
155
- // its aliases (e.g. 'opus' is an alias of the canonical 'opus-4.8-xhigh'). Matching
155
+ // its aliases (e.g. 'opus' is an alias of the canonical 'opus-5.5-xhigh'). Matching
156
156
  // id-only would wrongly treat a valid alias as a mismatched pair and silently coerce
157
157
  // it to the provider default.
158
158
  let normalizedModel = config.model;
@@ -23,6 +23,7 @@ const { buildChatStartedPayload, buildChatResumedPayload, buildChatHookContext,
23
23
  const { resolveFormat } = require('../utils/comment-formatter');
24
24
  const { getAllChatProviders, getAllCachedChatAvailability } = require('../chat/chat-providers');
25
25
  const { getChatModelCatalog, canonicalChatModel } = require('../chat/chat-models');
26
+ const { SESSION_BUSY } = require('../chat/session-manager');
26
27
  const { resolveLoadSkills } = require('../config');
27
28
 
28
29
  /**
@@ -511,6 +512,15 @@ router.post('/api/chat/session/:id/message', async (req, res) => {
511
512
  logger.debug(`[ChatRoute] Message stored as ID ${result.id}, awaiting agent response via WebSocket`);
512
513
  res.json({ data: { messageId: result.id } });
513
514
  } catch (error) {
515
+ if (error.code === SESSION_BUSY) {
516
+ // The agent still owns its previous turn — e.g. an OMP run paused on a
517
+ // background job, seen from a page reloaded mid-reply. The message was
518
+ // not stored, so the client can send it again once the reply finishes.
519
+ logger.warn(`Chat message rejected: ${error.message}`);
520
+ return res.status(409).json({
521
+ error: 'The agent is still working on its previous reply. Wait for it to finish, then send your message again.'
522
+ });
523
+ }
514
524
  logger.error(`Error sending chat message: ${error.message}`);
515
525
  res.status(500).json({ error: 'Failed to send message' });
516
526
  }
@@ -129,7 +129,7 @@ const REGISTRY = [
129
129
  description: "Model within the default provider for the Default Provider/Model analysis and single-model tasks.",
130
130
  group: 'ai',
131
131
  type: 'string',
132
- default: 'opus',
132
+ default: 'opus-5.5-high',
133
133
  editable: true,
134
134
  restartRequired: false
135
135
  },
@@ -230,7 +230,7 @@ const REGISTRY = [
230
230
  {
231
231
  key: 'tours.model',
232
232
  label: 'Tours model',
233
- description: 'Model for tour generation. Empty falls back to summaries model resolution.',
233
+ description: "Model for tour generation. Empty uses the summaries model if set, then the provider's default model.",
234
234
  group: 'tours',
235
235
  type: 'string',
236
236
  default: '',