feat(panel): Chat follows the workspace's chat on the central live layer, and its read loop and cursor are gone

Merged
CH
8d ago
+351-182

Part of making workspace chat live over Neon Realtime. On main (#3923 has merged). One change: the window's Chat follows the chat stream, and its read loop and cursor are gone.

What changes

  • The hook follows instead of looping. While Chat is on, use-workspace-chat.ts keeps the listed workspace's codingAgents.chatFollow stream open (#3923) and takes in each push whole:
    • the roster, the channels and the messages it holds replace what was held, so a message that leaves the live read (past a channel's newest 200, other than an open ask) goes too
    • a message held newer by touchedSeq is kept, so a push that crosses a write's own answer never sets it back
  • Write overlay kept. What the window wrote, a channel or a message, is laid over each push that may have been read before the write landed. It stays until a push holds it as written, or 30 s have passed since the write was answered.
  • Errors and retries. A chat that couldn't be read, or whose stream ends while it's still followed, shows Try again, which follows it from scratch. A push that arrives after the window let the stream go is dropped.
  • Writes are unchanged.
  • Web tab. The same stream runs in a web tab through its in-process act port. No web-specific code is needed.

The held read is retired in #3933. The service's held route stays for released desktops.

Tests

  • use-workspace-chat.test.ts, rewritten for pushes:
    • following, merging, and an older push not setting anything back
    • failure and Try again
    • switching workspace or account
    • post keys, answers that weren't taken, and reads-to
    • channel writes: a stale push sets nothing back, and the overlay is let go once a push holds the write, or at the next push
  • use-tasks-tab.test.ts: Chat on follows (and Chat off doesn't). The task's Chat tab, the narrow room's rail, and channel links now run on pushes.
  • Checks run one at a time on the stack's top: tsc per touched package, biome, oxlint, knip, discarded-effect, the repository checks, and the affected vitest suites.

To check by hand

With Chat on (Realtime off by default, so the held poll answers within about a second) in the desktop app or a web tab:

  1. Post from another account or an agent. It should appear straight away.
  2. Answer an ask in one window. The other window should update too.