@supanadit/morse-web 0.14.0 → 0.14.1

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.
package/dist/server.mjs CHANGED
@@ -1409,24 +1409,29 @@ var PiRpcAgent = class {
1409
1409
  provider: model.provider,
1410
1410
  modelId: model.id
1411
1411
  });
1412
- this.patchState({ model: data ? toModelRef(data) : model });
1413
- await this.refreshThinkingLevels();
1412
+ const thinking = await this.readThinkingLevels();
1413
+ this.patchState({
1414
+ model: data ? toModelRef(data) : model,
1415
+ ...thinking
1416
+ });
1414
1417
  }
1415
1418
  /**
1416
- * Re-read the levels the current model supports, and the level pi actually
1417
- * settled the session on (a model without reasoning resets it to `off`).
1419
+ * The levels the current model supports, and the level pi settled on (a model
1420
+ * without reasoning resets it to `off`). Returns a patch with nothing to say
1421
+ * when pi did not answer, so the caller keeps the last known levels instead of
1422
+ * inventing the full list — a failed refresh must not make the picker wrong.
1418
1423
  */
1419
- async refreshThinkingLevels() {
1424
+ async readThinkingLevels() {
1420
1425
  const [levels, state] = await Promise.all([
1421
1426
  this.client.request({ type: "get_available_thinking_levels" }).catch(() => void 0),
1422
1427
  this.client.request({ type: "get_state" }).catch(() => void 0)
1423
1428
  ]);
1424
1429
  const available = dedupeThinkingLevels((levels?.levels ?? []).map(toThinkingLevel).filter(isDefined2));
1425
1430
  const thinkingLevel = state ? toThinkingLevel(state.thinkingLevel) : void 0;
1426
- this.patchState({
1427
- availableThinkingLevels: available.length > 0 ? available : [...THINKING_LEVELS],
1431
+ return {
1432
+ ...available.length > 0 ? { availableThinkingLevels: available } : {},
1428
1433
  ...thinkingLevel !== void 0 ? { thinkingLevel } : {}
1429
- });
1434
+ };
1430
1435
  }
1431
1436
  async setThinkingLevel(level) {
1432
1437
  await this.client.request({ type: "set_thinking_level", level });