@staff0rd/assist 0.713.1 → 0.713.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.
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import { Command } from "commander";
6
6
  // package.json
7
7
  var package_default = {
8
8
  name: "@staff0rd/assist",
9
- version: "0.713.1",
9
+ version: "0.713.3",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -41793,8 +41793,8 @@ function startTranscriptTitleGeneration(session, notify2) {
41793
41793
  runSessionTitleGeneration(session, context, notify2);
41794
41794
  }
41795
41795
  function titleSource(session) {
41796
- if (session.commandType === "claude")
41797
- return session.initialPrompt?.trim() ? void 0 : "first-message";
41796
+ if (session.commandType === "claude" && !session.initialPrompt?.trim())
41797
+ return "first-message";
41798
41798
  if (session.activity?.itemName) return void 0;
41799
41799
  const prompt = sessionTitlePrompt(session);
41800
41800
  if (!prompt || !isReferenceOnlyPrompt(prompt)) return void 0;
@@ -43702,6 +43702,35 @@ var VerifyTracker = class {
43702
43702
  }
43703
43703
  };
43704
43704
 
43705
+ // src/commands/sessions/daemon/withRepoGroups.ts
43706
+ function withRepoGroups(sessions) {
43707
+ const existence = /* @__PURE__ */ new Map();
43708
+ const exists = (dir) => {
43709
+ const cached = existence.get(dir);
43710
+ if (cached !== void 0) return cached;
43711
+ const result = repoDirExists(dir);
43712
+ existence.set(dir, result);
43713
+ return result;
43714
+ };
43715
+ return sessions.map((session) => {
43716
+ const repoGroup = repoGroupForCwd(session.cwd);
43717
+ const dir = repoGroup?.clone || session.cwd;
43718
+ const cwdMissing = Boolean(dir) && !exists(dir);
43719
+ if (!repoGroup && !cwdMissing) return session;
43720
+ return {
43721
+ ...session,
43722
+ ...repoGroup && { repoGroup },
43723
+ ...cwdMissing && { cwdMissing }
43724
+ };
43725
+ });
43726
+ }
43727
+
43728
+ // src/commands/sessions/daemon/collectHistory.ts
43729
+ async function collectHistory(linked) {
43730
+ const [local, remote] = await Promise.all([discoverSessions(), linked]);
43731
+ return withRepoGroups(local).concat(remote);
43732
+ }
43733
+
43705
43734
  // src/commands/sessions/daemon/links/connectLinkWebSocket.ts
43706
43735
  import WebSocket from "ws";
43707
43736
  var HANDSHAKE_TIMEOUT_MS = 5e3;
@@ -43930,7 +43959,7 @@ var LaunchCircuitBreaker = class {
43930
43959
 
43931
43960
  // src/commands/sessions/daemon/links/LinkRelayState.ts
43932
43961
  var MAX_SCROLLBACK2 = 256 * 1024;
43933
- function createRelayState(node, viewers, onSessionsChanged) {
43962
+ function createRelayState(node, { viewers, onSessionsChanged, onHistoryChanged }) {
43934
43963
  return {
43935
43964
  node,
43936
43965
  sessions: [],
@@ -43938,7 +43967,8 @@ function createRelayState(node, viewers, onSessionsChanged) {
43938
43967
  pendingCreators: [],
43939
43968
  historyWaiters: [],
43940
43969
  viewers,
43941
- onSessionsChanged
43970
+ onSessionsChanged,
43971
+ onHistoryChanged
43942
43972
  };
43943
43973
  }
43944
43974
  function broadcastToViewers(state, msg) {
@@ -43987,7 +44017,7 @@ function createLinkContext(spec, deps2) {
43987
44017
  return {
43988
44018
  spec,
43989
44019
  deps: deps2,
43990
- relay: createRelayState(spec.name, deps2.viewers, deps2.onSessionsChanged),
44020
+ relay: createRelayState(spec.name, deps2),
43991
44021
  breaker: new LaunchCircuitBreaker(`link ${spec.name} ws`),
43992
44022
  tunnel: deps2.tunnel(spec),
43993
44023
  socket: null,
@@ -44299,10 +44329,18 @@ var relayToCreator = (label2) => (state, msg) => {
44299
44329
  daemonLog(`link ${state.node} ws: ${msg.type} with no pending creator`);
44300
44330
  };
44301
44331
  var relayHistory = (state, msg) => {
44302
- const sessions = msg.sessions ?? [];
44303
- state.historyWaiters.shift()?.(
44304
- sessions.map((s) => ({ ...s, node: state.node }))
44305
- );
44332
+ const sessions = (msg.sessions ?? []).map((s) => ({
44333
+ ...s,
44334
+ node: state.node
44335
+ }));
44336
+ const changed = JSON.stringify(sessions) !== JSON.stringify(state.lastHistory);
44337
+ state.lastHistory = sessions;
44338
+ const waiter = state.historyWaiters.shift();
44339
+ if (waiter) waiter(sessions);
44340
+ else if (changed) {
44341
+ daemonLog(`link ${state.node} ws: late history reply changed, pushing`);
44342
+ state.onHistoryChanged();
44343
+ }
44306
44344
  };
44307
44345
  var relays = {
44308
44346
  sessions: relayLinkSessions,
@@ -44335,6 +44373,7 @@ function onHello(ctx, msg) {
44335
44373
  ctx.breaker.clear();
44336
44374
  ctx.lastError = void 0;
44337
44375
  setLinkState(ctx, "connected");
44376
+ ctx.deps.onHistoryChanged();
44338
44377
  ctx.onCompatible();
44339
44378
  }
44340
44379
  function onLinkLine(ctx, line) {
@@ -44391,7 +44430,7 @@ function requestLinkHistory(ctx) {
44391
44430
  const index3 = waiters.indexOf(settle);
44392
44431
  if (index3 !== -1) waiters.splice(index3, 1);
44393
44432
  daemonLog(`link ${ctx.spec.name} ws: history timed out`);
44394
- resolve25([]);
44433
+ resolve25(ctx.relay.lastHistory ?? []);
44395
44434
  }, HISTORY_TIMEOUT_MS);
44396
44435
  timer.unref?.();
44397
44436
  waiters.push(settle);
@@ -44480,7 +44519,8 @@ var NodeLinks = class {
44480
44519
  const deps2 = linkDeps(this.options, {
44481
44520
  viewers: () => this.clients.viewers(),
44482
44521
  onSessionsChanged: this.onSessionsChanged,
44483
- onStateChanged: () => broadcast(this.clients.viewers(), this.nodes())
44522
+ onStateChanged: () => broadcast(this.clients.viewers(), this.nodes()),
44523
+ onHistoryChanged: () => void this.broadcastHistory()
44484
44524
  });
44485
44525
  reconcileLinks(this.links, specs, (spec) => new NodeLink(spec, deps2));
44486
44526
  this.onSessionsChanged();
@@ -44493,6 +44533,13 @@ var NodeLinks = class {
44493
44533
  for (const link3 of this.all()) link3.replayScrollback(client);
44494
44534
  }
44495
44535
  history = async () => (await Promise.all(this.all().map((link3) => link3.history()))).flat();
44536
+ broadcastHistory = async () => {
44537
+ const sessions = await collectHistory(this.history());
44538
+ daemonLog(
44539
+ `links: pushing history (${sessions.length} sessions) to viewers`
44540
+ );
44541
+ broadcast(this.clients.viewers(), { type: "history", sessions });
44542
+ };
44496
44543
  nodes = () => ({
44497
44544
  type: "nodes",
44498
44545
  local: this.localNode(),
@@ -45312,37 +45359,10 @@ function routed(local) {
45312
45359
  };
45313
45360
  }
45314
45361
 
45315
- // src/commands/sessions/daemon/withRepoGroups.ts
45316
- function withRepoGroups(sessions) {
45317
- const existence = /* @__PURE__ */ new Map();
45318
- const exists = (dir) => {
45319
- const cached = existence.get(dir);
45320
- if (cached !== void 0) return cached;
45321
- const result = repoDirExists(dir);
45322
- existence.set(dir, result);
45323
- return result;
45324
- };
45325
- return sessions.map((session) => {
45326
- const repoGroup = repoGroupForCwd(session.cwd);
45327
- const dir = repoGroup?.clone || session.cwd;
45328
- const cwdMissing = Boolean(dir) && !exists(dir);
45329
- if (!repoGroup && !cwdMissing) return session;
45330
- return {
45331
- ...session,
45332
- ...repoGroup && { repoGroup },
45333
- ...cwdMissing && { cwdMissing }
45334
- };
45335
- });
45336
- }
45337
-
45338
45362
  // src/commands/sessions/daemon/lifecycleHandlers.ts
45339
45363
  async function handleHistory(client, manager) {
45340
45364
  const linked = manager.clients.isPeer(client) ? [] : manager.links.history();
45341
- const [local, remote] = await Promise.all([discoverSessions(), linked]);
45342
- sendTo(client, {
45343
- type: "history",
45344
- sessions: withRepoGroups(local).concat(remote)
45345
- });
45365
+ sendTo(client, { type: "history", sessions: await collectHistory(linked) });
45346
45366
  }
45347
45367
  function handleFetchTranscript(client, _manager, data) {
45348
45368
  const sessionId = data.sessionId;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.713.1",
3
+ "version": "0.713.3",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {