thinkpool-pair 0.6.17 → 0.6.19

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.
Files changed (2) hide show
  1. package/bridge.mjs +22 -6
  2. package/package.json +1 -1
package/bridge.mjs CHANGED
@@ -435,6 +435,11 @@ function openStructured({ id, model, resume, log }) {
435
435
  openStructured({ id, model, log: entry.log })
436
436
  return
437
437
  }
438
+ // Stamp a wall-clock ts on every transcript event so the web client can
439
+ // sort agent turns chronologically against room chat/whispers on reload
440
+ // (the client merges the replayed log with persisted human lines). Used
441
+ // for ordering only — agent timestamps are never displayed.
442
+ if (typeof evt.ts !== 'number') evt.ts = Date.now()
438
443
  // Chrome events (mode / usage / clear) are transient state, not transcript —
439
444
  // broadcast + print them, but keep them out of the persisted/replayed log.
440
445
  const chrome = evt.kind === 'mode' || evt.kind === 'usage' || evt.kind === 'clear'
@@ -587,16 +592,27 @@ channel
587
592
  s.log.push(evt); if (s.log.length > STRUCTURED_LOG_MAX) s.log.shift()
588
593
  bcast('code-event', { term: payload.term, evt })
589
594
  }
590
- // Most slash commands (/compact, /clear, …) are processed by the SDK when
591
- // sent as a turn. Two need special handling:
592
- // /model <name> is disabled headlessroute to the setModel control.
593
- // /clear also wipes the on-screen transcript (parity with the CLI).
595
+ // Session controls (/model, /clear) are NOT agent turns they change the
596
+ // shared session config. Emitting a `you` line for them strands the reader's
597
+ // inferred "working…" state (no turnno result to clear it; the old bug).
598
+ // Instead announce a control line both readers see. /compact + any other
599
+ // slash still flow through as a real, self-terminating turn.
600
+ const ctlLine = (ctlText) => {
601
+ const evt = { kind: 'control', text: ctlText, by: payload.by, cid: payload.cid }
602
+ s.log.push(evt); if (s.log.length > STRUCTURED_LOG_MAX) s.log.shift()
603
+ bcast('code-event', { term: payload.term, evt })
604
+ }
594
605
  const mm = text.match(/^\/model\b\s*(\S+)?/)
595
- if (mm) { echoYou(); if (mm[1]) s.session.setModel(mm[1]); else s.session.listModels(); return }
606
+ if (mm) {
607
+ if (mm[1]) { s.session.setModel(mm[1]); ctlLine(`switched model → ${mm[1]}`) }
608
+ else { ctlLine('use /model <name> to switch — e.g. opus, sonnet, haiku') }
609
+ return
610
+ }
596
611
  if (/^\/clear\s*$/.test(text)) {
597
- echoYou(); s.session.sendTurn(text)
612
+ s.session.sendTurn(text)
598
613
  s.log = []; bcast('code-event', { term: payload.term, evt: { kind: 'clear' } })
599
614
  flushSession(room, payload.term, { sessionId: s.session?.sessionId || null, log: [] })
615
+ ctlLine('context cleared. You can continue with these answers in mind.')
600
616
  return
601
617
  }
602
618
  s.session.sendTurn(text)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thinkpool-pair",
3
- "version": "0.6.17",
3
+ "version": "0.6.19",
4
4
  "description": "Share a local coding-agent CLI (Claude Code, Codex, Gemini, Aider, …) into a ThinkPool Code room, live.",
5
5
  "type": "module",
6
6
  "bin": {