openmausbot 0.1.83 → 0.1.84

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.
@@ -60,7 +60,9 @@ export function buildNotification(kind, bot, threadId, detail, extra) {
60
60
  ? `${who}'s routine is waiting`
61
61
  : kind === "turn-failed"
62
62
  ? `${who} couldn't start`
63
- : `${who} finished`;
63
+ : kind === "incident"
64
+ ? `${who} hit a problem`
65
+ : `${who} finished`;
64
66
  // A "finished" with nothing to say is not worth a notification — the
65
67
  // badge in the sidebar already carries that much.
66
68
  if (kind === "done" && !body)
@@ -29,7 +29,7 @@ export const taskWireProjectionIsExact = true;
29
29
  /** The typed wire projection for one task. Pairs with the assertion above:
30
30
  * returning WireTask means an undeclared server field cannot ride silently. */
31
31
  export function toWireTask(task) {
32
- const { resumeCursors: _resumeCursors, lastInstanceId: _lastInstanceId, ...wire } = task;
32
+ const { resumeCursors: _resumeCursors, lastInstanceId: _lastInstanceId, handedMessages: _handedMessages, ...wire } = task;
33
33
  return wire;
34
34
  }
35
35
  const TASK_PATCH_FIELDS = [
@@ -1080,6 +1080,13 @@ export class Store {
1080
1080
  t.activeLeafId = full.id;
1081
1081
  mdb.appendMessage(threadId, full);
1082
1082
  this.emit({ type: "message", threadId, message: full });
1083
+ // The message frame alone leaves every client on the OLD branch: a
1084
+ // client adopts a new message as its leaf only when it chains onto the
1085
+ // current leaf, and this one is a sibling of the edited message, not a
1086
+ // child of the reply. Say where the conversation now points, as
1087
+ // setActiveLeaf does, or the edit shows only after the next full bot
1088
+ // snapshot — in practice, once the reply has arrived.
1089
+ this.emit({ type: "thread", threadId, activeLeafId: full.id });
1083
1090
  return full;
1084
1091
  }
1085
1092
  /** Point the visible conversation at the branch containing `messageId`,
@@ -1503,6 +1510,16 @@ export class Store {
1503
1510
  task.lastInstanceId = instanceId;
1504
1511
  this.saveBots();
1505
1512
  }
1513
+ setHandedMessages(botId, threadId, instanceId, state) {
1514
+ const task = this.taskByThread(botId, threadId);
1515
+ if (!task || JSON.stringify(task.handedMessages?.[instanceId]) === JSON.stringify(state))
1516
+ return;
1517
+ // Other instances keep a record only while it still describes their session.
1518
+ const live = Object.entries(task.handedMessages ?? {})
1519
+ .filter(([id, record]) => id !== instanceId && record.session !== undefined && record.session === task.resumeCursors[id]);
1520
+ task.handedMessages = { ...Object.fromEntries(live), [instanceId]: state };
1521
+ this.saveBots();
1522
+ }
1506
1523
  /** Bank one settled turn onto its task. Called once per turn.completed;
1507
1524
  * the running per-driver token indicator is deliberately not used here
1508
1525
  * because its meaning differs by driver. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openmausbot",
3
- "version": "0.1.83",
3
+ "version": "0.1.84",
4
4
  "description": "Run the OpenMausBot server anywhere and pair your devices to it",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",