route Claude transcript content through the MessageBus
test / unit + widget + golden + a11y (push) Failing after 26s
test / integration_test (xvfb) (push) Has been skipped
test / bundle smoke (xvfb 5s) (push) Has been skipped
test / daemon subprocess + web WASM smoke (push) Has been skipped
test / dart doc (lib API) (push) Failing after 23s

The Claude pane owned a TranscriptReader directly via the controller.
Insert a TranscriptPublisher that tails the transcript and republishes
each ConversationItem onto the kernel MessageBus; the view's controller
subscribes through ConversationController.fromBus. The subscription is
attached before the reader's first poll, so the initial tail isn't
missed on the broadcast bus.

This decouples reading from rendering: the team work (T-139/T-140) can
run one observer that publishes per-agent channels while the lead tile
and each teammate tile subscribe independently.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-22 23:03:17 +02:00
co-authored by Claude Opus 4.7
parent a6ed22405f
commit 0b942db251
6 changed files with 205 additions and 8 deletions
+13 -3
View File
@@ -11,6 +11,8 @@ import 'conversation_controller.dart';
import 'conversation_view.dart';
import 'session_naming.dart';
import 'tmux_session.dart' as tmux;
import 'transcript_publisher.dart';
import 'transcript_reader.dart';
class ClaudePane extends StatefulWidget {
const ClaudePane({
@@ -38,6 +40,7 @@ class _ClaudePaneState extends State<ClaudePane> {
StreamSubscription<DaemonEvent>? _eventSub;
ConversationController? _conversation;
TranscriptPublisher? _feed;
String? _paneId;
String? _sessionName;
String? _error;
@@ -60,6 +63,8 @@ class _ClaudePaneState extends State<ClaudePane> {
void dispose() {
_conversation?.dispose();
_conversation = null;
unawaited(_feed?.dispose());
_feed = null;
_eventSub?.cancel();
_eventSub = null;
final id = _paneId;
@@ -194,9 +199,14 @@ class _ClaudePaneState extends State<ClaudePane> {
if (!mounted) return;
_paneId = resp.data['id'] as String?;
// Render the conversation natively from the transcript (T-137/D-75)
// rather than the PTY's TUI output. claude runs in tmux; we tail its
// transcript JSONL for the workspace.
_conversation = ConversationController.forWorkspace(repoRoot);
// rather than the PTY's TUI output. claude runs in tmux; a reader
// tails its transcript JSONL and a publisher fans the items onto the
// kernel MessageBus, which the view's controller subscribes to. The
// subscription is wired before the reader's first poll so the initial
// tail is never missed.
final messages = _kernel()!.messages;
_feed = TranscriptPublisher(messages: messages, reader: TranscriptReader(repoRoot));
_conversation = ConversationController.fromBus(messages: messages);
_subscribe();
setState(() {});
}
@@ -9,7 +9,9 @@ library;
import 'dart:async';
import 'package:clide/builtin/claude/src/transcript_publisher.dart';
import 'package:clide/builtin/claude/src/transcript_reader.dart';
import 'package:clide/kernel/src/events/message_bus.dart';
import 'package:flutter/foundation.dart';
class ConversationController extends ChangeNotifier {
@@ -23,11 +25,18 @@ class ConversationController extends ChangeNotifier {
_sub = stream.listen(_onItem);
}
/// Convenience: build a controller backed by a live [TranscriptReader]
/// for [workspacePath].
factory ConversationController.forWorkspace(String workspacePath) {
final reader = TranscriptReader(workspacePath);
return ConversationController(stream: reader.stream, onDispose: reader.dispose);
/// Build a controller fed from the kernel [MessageBus] — it consumes
/// the [ConversationItem]s a [TranscriptPublisher] writes onto
/// [publisher]/[channel]. Decouples the view from the reader so several
/// panels can render the same conversation (team work, T-139/T-140).
factory ConversationController.fromBus({
required MessageBus messages,
String channel = ClaudeConversation.leadChannel,
Future<void> Function()? onDispose,
}) {
final stream =
messages.subscribe(publisher: ClaudeConversation.publisher, channel: channel).map((m) => m.data[ClaudeConversation.itemKey] as ConversationItem);
return ConversationController(stream: stream, onDispose: onDispose);
}
final Future<void> Function()? _onDispose;
@@ -0,0 +1,60 @@
/// Bridges a [TranscriptReader] onto the kernel [MessageBus] (epic T-132,
/// D-75).
///
/// One reader tails a workspace transcript; this publisher republishes
/// every [ConversationItem] as a bus [Message]. Any number of Claude
/// panels can then subscribe to the same conversation via the bus instead
/// of each owning its own reader — the decoupling the team panels
/// (T-139/T-140) need, where a single observer feeds the lead tile plus a
/// tile per teammate.
library;
import 'dart:async';
import 'package:clide/builtin/claude/src/transcript_reader.dart';
import 'package:clide/kernel/src/events/message_bus.dart';
/// Bus addressing for Claude conversation content.
abstract final class ClaudeConversation {
/// Publisher id under which conversation items are published.
static const publisher = 'builtin.claude';
/// Channel for the lead (or single) Claude pane's conversation.
static const leadChannel = 'conversation';
/// Channel for a teammate's conversation (team work, T-139/T-140).
static String teammateChannel(String agentId) => 'conversation/$agentId';
/// Key under which the [ConversationItem] travels in a [Message]'s data.
static const itemKey = 'item';
}
class TranscriptPublisher {
/// Starts republishing [reader]'s items onto [messages] under
/// [ClaudeConversation.publisher] / [channel]. The subscription is
/// attached synchronously, so a controller that subscribes before the
/// reader's first poll never misses the initial tail.
TranscriptPublisher({
required MessageBus messages,
required TranscriptReader reader,
this.channel = ClaudeConversation.leadChannel,
}) : _messages = messages,
_reader = reader {
_sub = _reader.stream.listen((item) {
_messages.publish(ClaudeConversation.publisher, channel, {
ClaudeConversation.itemKey: item,
});
});
}
final MessageBus _messages;
final TranscriptReader _reader;
final String channel;
late final StreamSubscription<ConversationItem> _sub;
/// Stops publishing and tears down the underlying reader.
Future<void> dispose() async {
await _sub.cancel();
await _reader.dispose();
}
}