@volter/teams 0.1.26 → 0.1.27

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volter/teams",
3
- "version": "0.1.26",
3
+ "version": "0.1.27",
4
4
  "type": "module",
5
5
  "description": "Volter Teams, the neutral team plane: machine identity and daemon core, the local door and server link, admission from machine grants, product doors, and the Teams server's neutral routes (company RFC 0008).",
6
6
  "license": "MIT",
package/viewer/viewer.mjs CHANGED
@@ -125,15 +125,19 @@ async function showSession(session, control) {
125
125
  try {
126
126
  const response = await fetch(`${base}/messages?tail=300`, { headers: await headers() });
127
127
  if (!response.ok) throw new Error(`reading the session failed (${response.status})`);
128
- apply(await response.json());
128
+ const body = await response.json();
129
+ apply(body);
130
+ return body;
129
131
  } finally { reading = null; }
130
132
  })());
131
- // The follow stream: a snapshot, then an event each time the session changed (read it again). It ends when the
132
- // token does or the connection drops; it is reopened with a fresh token from where it left off.
133
+ // The snapshot is read whole (a busy session's is over the follow stream's 1 MB buffer, which ended the stream
134
+ // before it was sent); the follow stream then carries only the events after that snapshot's cursor, and each one
135
+ // means "read again". It ends when the token does or the connection drops, and is reopened from where it left off.
133
136
  let cursor = null;
134
137
  for (;;) {
135
138
  try {
136
- const response = await fetch(`${base}/events?tail=300${cursor ? `&after=${encodeURIComponent(cursor)}` : ''}`, { headers: await headers() });
139
+ if (!cursor) cursor = String((await read()).event_cursor ?? '') || null;
140
+ const response = await fetch(`${base}/events?${cursor ? `after=${encodeURIComponent(cursor)}` : 'tail=1'}`, { headers: await headers() });
137
141
  if (!response.ok) throw new Error(`following the session failed (${response.status})`);
138
142
  view.update({ live: true });
139
143
  status('');