show live per-member status in the team sidebar
test / unit + widget + golden + a11y (push) Failing after 31s
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 29s
test / unit + widget + golden + a11y (push) Failing after 31s
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 29s
The teammate status was emitted by each TranscriptPublisher's statusStream
but never reached the bus. The observer now forwards it onto a shared
member-status channel ({agentId, model, permissionMode, contextTokens});
the meta sidebar subscribes and folds each member's live permission-mode
and context-token count into its roster row. No re-tailing — reuses the
existing stream (D-75).
T-157.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -13,8 +13,10 @@ import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:clide/builtin/claude/src/claude_stats.dart';
|
||||
import 'package:clide/builtin/claude/src/claude_status.dart' show shortModelLabel;
|
||||
import 'package:clide/builtin/claude/src/claude_status.dart' show formatTokenCount, permissionModeLabel, shortModelLabel;
|
||||
import 'package:clide/builtin/claude/src/team_panel_host.dart' show teamColor;
|
||||
import 'package:clide/builtin/claude/src/transcript_publisher.dart' show ClaudeConversation;
|
||||
import 'package:clide/builtin/claude/src/transcript_reader.dart' show SessionStatus;
|
||||
import 'package:clide/kernel/kernel.dart';
|
||||
import 'package:clide/widgets/widgets.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
@@ -37,8 +39,10 @@ class ClaudeMetaSidebar extends StatefulWidget {
|
||||
class _ClaudeMetaSidebarState extends State<ClaudeMetaSidebar> {
|
||||
ClaudeStats _stats = const ClaudeStats();
|
||||
final List<TeamMemberJoined> _members = [];
|
||||
final Map<String, SessionStatus> _memberStatus = {};
|
||||
StreamSubscription<TeamMemberJoined>? _joinSub;
|
||||
StreamSubscription<TeamMemberLeft>? _leftSub;
|
||||
StreamSubscription<Message>? _statusSub;
|
||||
Timer? _timer;
|
||||
late final Future<ClaudeStats> Function() _load;
|
||||
bool _subscribed = false;
|
||||
@@ -71,13 +75,28 @@ class _ClaudeMetaSidebarState extends State<ClaudeMetaSidebar> {
|
||||
super.didChangeDependencies();
|
||||
if (_subscribed) return;
|
||||
_subscribed = true;
|
||||
final events = ClideKernel.of(context).events;
|
||||
_joinSub = events.on<TeamMemberJoined>().listen((m) {
|
||||
final kernel = ClideKernel.of(context);
|
||||
_joinSub = kernel.events.on<TeamMemberJoined>().listen((m) {
|
||||
if (_members.any((x) => x.agentId == m.agentId)) return;
|
||||
setState(() => _members.add(m));
|
||||
});
|
||||
_leftSub = events.on<TeamMemberLeft>().listen((m) {
|
||||
setState(() => _members.removeWhere((x) => x.agentId == m.agentId));
|
||||
_leftSub = kernel.events.on<TeamMemberLeft>().listen((m) {
|
||||
setState(() {
|
||||
_members.removeWhere((x) => x.agentId == m.agentId);
|
||||
_memberStatus.remove(m.agentId);
|
||||
});
|
||||
});
|
||||
// Live per-member status forwarded by the observer (T-157).
|
||||
_statusSub = kernel.messages.subscribe(channel: ClaudeConversation.memberStatusChannel).listen((msg) {
|
||||
final agentId = msg.data['agentId'] as String?;
|
||||
if (agentId == null || !mounted) return;
|
||||
setState(() {
|
||||
_memberStatus[agentId] = SessionStatus(
|
||||
model: msg.data['model'] as String?,
|
||||
permissionMode: msg.data['permissionMode'] as String?,
|
||||
contextTokens: msg.data['contextTokens'] as int?,
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -91,6 +110,7 @@ class _ClaudeMetaSidebarState extends State<ClaudeMetaSidebar> {
|
||||
_timer?.cancel();
|
||||
_joinSub?.cancel();
|
||||
_leftSub?.cancel();
|
||||
_statusSub?.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@@ -151,7 +171,14 @@ class _ClaudeMetaSidebarState extends State<ClaudeMetaSidebar> {
|
||||
|
||||
Widget _memberRow(SurfaceTokens tokens, TeamMemberJoined m) {
|
||||
final color = teamColor(m.color, fallback: tokens.globalForeground);
|
||||
final sub = [m.agentType, if (m.model != null) shortModelLabel(m.model!)].join(' · ');
|
||||
final st = _memberStatus[m.agentId];
|
||||
final model = st?.model ?? m.model; // prefer the live model once it's known
|
||||
final sub = [
|
||||
m.agentType,
|
||||
if (model != null) shortModelLabel(model),
|
||||
if (st?.permissionMode != null) permissionModeLabel(st!.permissionMode!),
|
||||
if (st?.contextTokens != null) '${formatTokenCount(st!.contextTokens!)} ctx',
|
||||
].join(' · ');
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||
child: Row(
|
||||
|
||||
@@ -131,10 +131,14 @@ Future<TeamConfig?> discoverTeam(String workspacePath, {required String teamsBas
|
||||
typedef PaneLister = Future<Set<String>> Function();
|
||||
|
||||
class _LiveMember {
|
||||
_LiveMember(this.member, this.team, this.publisher);
|
||||
_LiveMember(this.member, this.team, this.publisher, this.statusSub);
|
||||
final TeamMember member;
|
||||
final String team;
|
||||
final TranscriptPublisher? publisher;
|
||||
|
||||
/// Forwards the member's status onto [ClaudeConversation.memberStatusChannel]
|
||||
/// (T-157); cancelled when the member leaves.
|
||||
final StreamSubscription<SessionStatus>? statusSub;
|
||||
}
|
||||
|
||||
/// Watches a workspace's tmux team and emits [TeamMemberJoined] /
|
||||
@@ -230,14 +234,22 @@ class TeamObserver {
|
||||
Future<void> _joined(TeamConfig config, TeamMember m) async {
|
||||
final path = await _resolveTranscript(config, m);
|
||||
TranscriptPublisher? pub;
|
||||
StreamSubscription<SessionStatus>? statusSub;
|
||||
if (path != null) {
|
||||
pub = TranscriptPublisher(
|
||||
messages: _messages,
|
||||
reader: TranscriptReader(m.cwd ?? workspacePath, file: path, projectsBase: _projectsBase),
|
||||
channel: ClaudeConversation.teammateChannel(m.agentId),
|
||||
);
|
||||
// Forward this member's status onto the shared status channel so the
|
||||
// team sidebar can show its mode + context without re-tailing (T-157).
|
||||
statusSub = pub.statusStream.listen((s) => _messages.publish(
|
||||
ClaudeConversation.publisher,
|
||||
ClaudeConversation.memberStatusChannel,
|
||||
ClaudeConversation.memberStatusData(m.agentId, s),
|
||||
));
|
||||
}
|
||||
_live[m.agentId] = _LiveMember(m, config.team, pub);
|
||||
_live[m.agentId] = _LiveMember(m, config.team, pub, statusSub);
|
||||
_events.emit(TeamMemberJoined(
|
||||
team: config.team,
|
||||
agentId: m.agentId,
|
||||
@@ -254,6 +266,7 @@ class TeamObserver {
|
||||
Future<void> _left(String agentId) async {
|
||||
final live = _live.remove(agentId);
|
||||
if (live == null) return;
|
||||
await live.statusSub?.cancel();
|
||||
await live.publisher?.dispose();
|
||||
_events.emit(TeamMemberLeft(team: live.team, agentId: agentId, paneId: live.member.tmuxPaneId));
|
||||
}
|
||||
|
||||
@@ -31,6 +31,18 @@ abstract final class ClaudeConversation {
|
||||
|
||||
/// Key under which the [ConversationItem] travels in a [Message]'s data.
|
||||
static const itemKey = 'item';
|
||||
|
||||
/// Shared channel carrying each team member's live status (T-157). Every
|
||||
/// message identifies its member via the `agentId` key.
|
||||
static const memberStatusChannel = 'member-status';
|
||||
|
||||
/// Encode [status] for [agentId] as a [memberStatusChannel] message body.
|
||||
static Map<String, Object?> memberStatusData(String agentId, SessionStatus status) => {
|
||||
'agentId': agentId,
|
||||
if (status.model != null) 'model': status.model,
|
||||
if (status.permissionMode != null) 'permissionMode': status.permissionMode,
|
||||
if (status.contextTokens != null) 'contextTokens': status.contextTokens,
|
||||
};
|
||||
}
|
||||
|
||||
class TranscriptPublisher {
|
||||
|
||||
Reference in New Issue
Block a user