openwriter 0.22.1 → 0.23.0

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/ws.js CHANGED
@@ -8,6 +8,7 @@ import { removeDocFromAllWorkspaces } from './workspaces.js';
8
8
  import { canonicalizeIdentifier } from './helpers.js';
9
9
  import { nodeTextPreview, diagLog } from './pending-overlay.js';
10
10
  import { generateRequestId, withRequestId } from './logger.js';
11
+ import { recordActivity, loadActivityTail } from './activity-log.js';
11
12
  /** Walk a doc and return a per-pending-node summary for diagnostic logging.
12
13
  * Produces lines like "nodeId/status text=\"...\" orig=\"...\"" — empty
13
14
  * if the doc has no pending nodes. adr: adr/pending-overlay-model.md */
@@ -210,6 +211,13 @@ export function setupWebSocket(server) {
210
211
  type: 'pending-docs-changed',
211
212
  pendingDocs: getPendingDocInfo(),
212
213
  }));
214
+ // Seed the right-rail Activity tab with persisted history (newest-first).
215
+ // The disk log is the source of truth; the client mirrors what we send.
216
+ // adr: adr/right-rail.md
217
+ ws.send(JSON.stringify({
218
+ type: 'activity-log',
219
+ entries: loadActivityTail(),
220
+ }));
213
221
  // Rehydrate in-flight writing spinners across app refreshes
214
222
  const pendingWritesSnapshot = getPendingWritesSnapshot();
215
223
  if (pendingWritesSnapshot.length > 0) {
@@ -562,6 +570,14 @@ export function broadcastWritingStarted(title, target, key) {
562
570
  if (ws.readyState === WebSocket.OPEN)
563
571
  ws.send(msg);
564
572
  }
573
+ // Right-rail Activity: each agent write produces one entry, emitted at
574
+ // start (target info is richest here, and the spinner-in-sidebar already
575
+ // signals in-progress completion). adr: adr/right-rail.md
576
+ broadcastActivityEvent({
577
+ kind: 'writing-started',
578
+ headline: `Agent wrote in ${title || 'Untitled'}`,
579
+ filename: target?.wsFilename,
580
+ });
565
581
  return writeKey;
566
582
  }
567
583
  // key omitted → clear all (legacy single-write flows). Pass a key for multi-doc.
@@ -621,6 +637,33 @@ export function broadcastCommentsChanged(filename) {
621
637
  ws.send(msg);
622
638
  }
623
639
  }
640
+ /**
641
+ * Record an agent-attributed activity event AND push it to every connected
642
+ * client. The on-disk log is authoritative; broadcast is purely for live UI.
643
+ * adr: adr/right-rail.md
644
+ */
645
+ export function broadcastActivityEvent(partial) {
646
+ const event = recordActivity(partial);
647
+ const msg = JSON.stringify({ type: 'activity-event', event });
648
+ for (const ws of clients) {
649
+ if (ws.readyState === WebSocket.OPEN)
650
+ ws.send(msg);
651
+ }
652
+ }
653
+ /**
654
+ * Push a fresh activity-log seed to all connected clients. Used on profile
655
+ * switch — the buffer has been cleared by clearAllCaches(), so the next
656
+ * loadActivityTail() reads from the new profile's disk log. Clients replace
657
+ * their entire in-memory list on receipt, so cross-profile leakage clears.
658
+ * adr: adr/right-rail.md
659
+ */
660
+ export function broadcastActivityLogSeed() {
661
+ const msg = JSON.stringify({ type: 'activity-log', entries: loadActivityTail() });
662
+ for (const ws of clients) {
663
+ if (ws.readyState === WebSocket.OPEN)
664
+ ws.send(msg);
665
+ }
666
+ }
624
667
  export function broadcastSyncStatus(status) {
625
668
  lastSyncStatus = status;
626
669
  const msg = JSON.stringify({ type: 'sync-status', ...status });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openwriter",
3
- "version": "0.22.1",
3
+ "version": "0.23.0",
4
4
  "description": "The open-source writing surface for AI agents. Markdown-native editor with pending change review — your agent writes, you accept or reject.",
5
5
  "type": "module",
6
6
  "license": "MIT",