diff --git a/.pql/changelog/ticket_history/2026-05.sql b/.pql/changelog/ticket_history/2026-05.sql index 08bba666..cdd3ea03 100644 --- a/.pql/changelog/ticket_history/2026-05.sql +++ b/.pql/changelog/ticket_history/2026-05.sql @@ -2216,3 +2216,5 @@ INSERT INTO ticket_history (ticket_id, field, old_value, new_value, changed_by, INSERT INTO ticket_history (ticket_id, field, old_value, new_value, changed_by, changed_at, created_at, updated_at, deleted_at, hash, canonical_version) VALUES ('T-148', 'status', 'backlog', 'in_progress', NULL, '2026-05-23 14:51:55', '2026-05-23 14:51:55', '2026-05-23 14:51:55', NULL, '3002f91cea5919aaefc3e4bc530c7ac2', 1) ON CONFLICT(hash) DO NOTHING; INSERT INTO ticket_history (ticket_id, field, old_value, new_value, changed_by, changed_at, created_at, updated_at, deleted_at, hash, canonical_version) VALUES ('T-141', 'status', 'backlog', 'in_progress', NULL, '2026-05-23 14:51:55', '2026-05-23 14:51:55', '2026-05-23 14:51:55', NULL, '76975080bd78de4d6f69937fd256d4ef', 1) ON CONFLICT(hash) DO NOTHING; INSERT INTO ticket_history (ticket_id, field, old_value, new_value, changed_by, changed_at, created_at, updated_at, deleted_at, hash, canonical_version) VALUES ('T-148', 'status', 'in_progress', 'done', NULL, '2026-05-23 15:05:29', '2026-05-23 15:05:29', '2026-05-23 15:05:29', NULL, 'd9d9e4c96d94060f929c7c09935d127c', 1) ON CONFLICT(hash) DO NOTHING; +INSERT INTO ticket_history (ticket_id, field, old_value, new_value, changed_by, changed_at, created_at, updated_at, deleted_at, hash, canonical_version) VALUES ('T-141', 'status', 'in_progress', 'done', NULL, '2026-05-23 20:49:44', '2026-05-23 20:49:44', '2026-05-23 20:49:44', NULL, 'fb2405478b0d422d39a924ccedec5022', 1) ON CONFLICT(hash) DO NOTHING; +INSERT INTO ticket_history (ticket_id, field, old_value, new_value, changed_by, changed_at, created_at, updated_at, deleted_at, hash, canonical_version) VALUES ('T-157', 'status', 'backlog', 'in_progress', NULL, '2026-05-23 20:52:47', '2026-05-23 20:52:47', '2026-05-23 20:52:47', NULL, 'b2b31ab5fe70fb5027773775b0945bd5', 1) ON CONFLICT(hash) DO NOTHING; diff --git a/.pql/changelog/tickets/2026-05.sql b/.pql/changelog/tickets/2026-05.sql index 9e378d8d..663b1883 100644 --- a/.pql/changelog/tickets/2026-05.sql +++ b/.pql/changelog/tickets/2026-05.sql @@ -2644,3 +2644,16 @@ Acceptance: roster matches list-panes/config; each row mirrors the member''s mod INSERT INTO tickets (id, type, parent_id, title, description, status, priority, assigned_to, team, decision_ref, created_at, updated_at, deleted_at, hash, canonical_version) VALUES ('T-148', 'task', 'T-132', 'Claude transcript disk-usage indicator + cleanup button', 'Surface transcript/session disk usage in the Claude panel with a cleanup affordance so the user can pick and choose what to remove. Per-session sizes (the /*.jsonl files + subagents/), a total, and a button to delete selected sessions'' transcripts. User-driven only — clide never auto-deletes transcript content. Future/''at some point'' per user. Relates to T-146 (session ids) and D-75.', 'done', 'low', NULL, NULL, NULL, '2026-05-23 07:03:18', '2026-05-23 15:05:29', NULL, '90efd726ef844874609653bf21fcfa5c', 1) ON CONFLICT(id) DO UPDATE SET type=excluded.type, parent_id=excluded.parent_id, title=excluded.title, description=excluded.description, status=excluded.status, priority=excluded.priority, assigned_to=excluded.assigned_to, team=excluded.team, decision_ref=excluded.decision_ref, updated_at=excluded.updated_at, deleted_at=excluded.deleted_at, hash=excluded.hash, canonical_version=excluded.canonical_version WHERE excluded.updated_at > tickets.updated_at OR (excluded.updated_at = tickets.updated_at AND excluded.hash > tickets.hash); INSERT INTO tickets (id, type, parent_id, title, description, status, priority, assigned_to, team, decision_ref, created_at, updated_at, deleted_at, hash, canonical_version) VALUES ('T-157', 'task', 'T-132', 'Team sidebar: live per-member status (mode + context)', 'Extend the Claude meta sidebar (T-141) roster rows with each teammate''s LIVE status — permission-mode badge (default/accept-edits/plan/bypass) and context-token usage — mirroring the per-session strip (T-145/T-150). The data exists: TeamObserver creates a TranscriptPublisher per teammate whose statusStream emits SessionStatus, but it is NEVER published to the MessageBus. Wire it: in team_observer _joined, subscribe to the publisher''s statusStream and publish {agentId, model, permissionMode, contextTokens} to a new ClaudeConversation.memberStatusChannel; cancel on _left. The sidebar subscribes to that channel and updates the matching roster row. Do NOT re-tail transcripts (D-75) — reuse the existing stream. Acceptance: a running team shows each member''s mode badge + context tokens, updating live; module is the single status-forwarding point; tests; coverage >= floor.', 'backlog', 'low', NULL, NULL, NULL, '2026-05-23 20:48:31', '2026-05-23 20:48:31', NULL, 'e7b13a20df653bee06b7b7ac031d29db', 1) ON CONFLICT(id) DO UPDATE SET type=excluded.type, parent_id=excluded.parent_id, title=excluded.title, description=excluded.description, status=excluded.status, priority=excluded.priority, assigned_to=excluded.assigned_to, team=excluded.team, decision_ref=excluded.decision_ref, updated_at=excluded.updated_at, deleted_at=excluded.deleted_at, hash=excluded.hash, canonical_version=excluded.canonical_version WHERE excluded.updated_at > tickets.updated_at OR (excluded.updated_at = tickets.updated_at AND excluded.hash > tickets.hash); INSERT INTO tickets (id, type, parent_id, title, description, status, priority, assigned_to, team, decision_ref, created_at, updated_at, deleted_at, hash, canonical_version) VALUES ('T-158', 'task', 'T-132', 'Team sidebar: account/team token budget (blocked on upstream)', 'Show the account/subscription usage budget (5-hour + weekly limits, % used, reset times) in the Claude meta sidebar (T-141). BLOCKED: this data is not programmatically exposed under subscription (OAuth) auth as of claude 2.1.150 — verified empirically + via docs (2026-05-23). /usage is TUI-only (headless ''claude -p /usage'' returns only a one-liner); stats-cache.json has activity counts only; the stream-json rate_limit_event is undocumented + needs a billed turn; ''claude auth status --json'' shows plan only. A ''claude usage --json'' + a /v1/organizations/{org}/usage/subscription endpoint are an OPEN, unshipped feature request (GitHub anthropics/claude-code#44328). Revisit when #44328 ships or an API-key usage path exists. See project memory ''claude-usage-budget-not-exposed''.', 'backlog', 'low', NULL, NULL, NULL, '2026-05-23 20:48:38', '2026-05-23 20:48:38', NULL, '4e239019c4cf4982bd653e5dd2c96990', 1) ON CONFLICT(id) DO UPDATE SET type=excluded.type, parent_id=excluded.parent_id, title=excluded.title, description=excluded.description, status=excluded.status, priority=excluded.priority, assigned_to=excluded.assigned_to, team=excluded.team, decision_ref=excluded.decision_ref, updated_at=excluded.updated_at, deleted_at=excluded.deleted_at, hash=excluded.hash, canonical_version=excluded.canonical_version WHERE excluded.updated_at > tickets.updated_at OR (excluded.updated_at = tickets.updated_at AND excluded.hash > tickets.hash); +INSERT INTO tickets (id, type, parent_id, title, description, status, priority, assigned_to, team, decision_ref, created_at, updated_at, deleted_at, hash, canonical_version) VALUES ('T-141', 'task', 'T-132', 'Team-meta sidebar (roster + token budget)', 'New sidebar panel (contributed to Slots.sidebar), visible only in team mode: a roster row per team member that MIRRORS the per-session status surfaced by T-145, plus team-wide meta. + +Per-member row: +- Identity from the team config + observer: name, agentType, color; membership/lifecycle from TeamMemberJoined/Left. +- Mirror of T-145''s shared status: current model, permission-mode badge (accept-edits / plan / default / bypass), context-window usage %. Consume the SAME status source/event T-145 emits — do NOT re-tail transcripts or re-parse CC internals here (D-75). +- Live status verb + elapsed-since-last-activity + down/up token deltas from that same status feed. + +Team-wide: +- Team/account token budget pulled from the Anthropic usage API on a timer (distinct from per-conversation context above). + +Acceptance: roster matches list-panes/config; each row mirrors the member''s model + accept-edits/plan badge + context-usage; status verb and token deltas update live; account budget refreshes on its timer; panel appears only when a team is active. Depends on T-145 (status source) + T-139 (done). +', 'done', 'medium', NULL, NULL, NULL, '2026-05-22 15:59:34', '2026-05-23 20:49:44', NULL, 'c9e79b9986f436abadba095d77d540f7', 1) ON CONFLICT(id) DO UPDATE SET type=excluded.type, parent_id=excluded.parent_id, title=excluded.title, description=excluded.description, status=excluded.status, priority=excluded.priority, assigned_to=excluded.assigned_to, team=excluded.team, decision_ref=excluded.decision_ref, updated_at=excluded.updated_at, deleted_at=excluded.deleted_at, hash=excluded.hash, canonical_version=excluded.canonical_version WHERE excluded.updated_at > tickets.updated_at OR (excluded.updated_at = tickets.updated_at AND excluded.hash > tickets.hash); +INSERT INTO tickets (id, type, parent_id, title, description, status, priority, assigned_to, team, decision_ref, created_at, updated_at, deleted_at, hash, canonical_version) VALUES ('T-157', 'task', 'T-132', 'Team sidebar: live per-member status (mode + context)', 'Extend the Claude meta sidebar (T-141) roster rows with each teammate''s LIVE status — permission-mode badge (default/accept-edits/plan/bypass) and context-token usage — mirroring the per-session strip (T-145/T-150). The data exists: TeamObserver creates a TranscriptPublisher per teammate whose statusStream emits SessionStatus, but it is NEVER published to the MessageBus. Wire it: in team_observer _joined, subscribe to the publisher''s statusStream and publish {agentId, model, permissionMode, contextTokens} to a new ClaudeConversation.memberStatusChannel; cancel on _left. The sidebar subscribes to that channel and updates the matching roster row. Do NOT re-tail transcripts (D-75) — reuse the existing stream. Acceptance: a running team shows each member''s mode badge + context tokens, updating live; module is the single status-forwarding point; tests; coverage >= floor.', 'in_progress', 'low', NULL, NULL, NULL, '2026-05-23 20:48:31', '2026-05-23 20:52:47', NULL, '386818f67d3cbcc1a1b7a528c2baaca1', 1) ON CONFLICT(id) DO UPDATE SET type=excluded.type, parent_id=excluded.parent_id, title=excluded.title, description=excluded.description, status=excluded.status, priority=excluded.priority, assigned_to=excluded.assigned_to, team=excluded.team, decision_ref=excluded.decision_ref, updated_at=excluded.updated_at, deleted_at=excluded.deleted_at, hash=excluded.hash, canonical_version=excluded.canonical_version WHERE excluded.updated_at > tickets.updated_at OR (excluded.updated_at = tickets.updated_at AND excluded.hash > tickets.hash); diff --git a/CHANGELOG.md b/CHANGELOG.md index 86754d84..4593a47d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,10 +18,11 @@ heading, and (b) bumping `pubspec.yaml` `version:` in the same commit. ### Added -- Claude meta sidebar (T-141) — an always-pickable left-panel tab showing - Claude activity (the latest day's messages/sessions/tool-calls plus - lifetime totals, from `stats-cache.json`) and, when a tmux team is - running, a roster of its members (colour · name · agent type · model). +- Claude meta sidebar (T-141, T-157) — an always-pickable left-panel tab + showing Claude activity (the latest day's messages/sessions/tool-calls + plus lifetime totals, from `stats-cache.json`) and, when a tmux team is + running, a roster of its members (colour · name · agent type · model) + with each member's live permission-mode and context once it's active. - Claude session storage view (T-148) — the `claude.session-storage` command opens a modal listing the workspace's session transcripts with their on-disk sizes and a total, each removable with a two-click diff --git a/lib/builtin/claude/src/claude_meta_sidebar.dart b/lib/builtin/claude/src/claude_meta_sidebar.dart index 288a8473..4ab41f41 100644 --- a/lib/builtin/claude/src/claude_meta_sidebar.dart +++ b/lib/builtin/claude/src/claude_meta_sidebar.dart @@ -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 { ClaudeStats _stats = const ClaudeStats(); final List _members = []; + final Map _memberStatus = {}; StreamSubscription? _joinSub; StreamSubscription? _leftSub; + StreamSubscription? _statusSub; Timer? _timer; late final Future Function() _load; bool _subscribed = false; @@ -71,13 +75,28 @@ class _ClaudeMetaSidebarState extends State { super.didChangeDependencies(); if (_subscribed) return; _subscribed = true; - final events = ClideKernel.of(context).events; - _joinSub = events.on().listen((m) { + final kernel = ClideKernel.of(context); + _joinSub = kernel.events.on().listen((m) { if (_members.any((x) => x.agentId == m.agentId)) return; setState(() => _members.add(m)); }); - _leftSub = events.on().listen((m) { - setState(() => _members.removeWhere((x) => x.agentId == m.agentId)); + _leftSub = kernel.events.on().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 { _timer?.cancel(); _joinSub?.cancel(); _leftSub?.cancel(); + _statusSub?.cancel(); super.dispose(); } @@ -151,7 +171,14 @@ class _ClaudeMetaSidebarState extends State { 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( diff --git a/lib/builtin/claude/src/team_observer.dart b/lib/builtin/claude/src/team_observer.dart index f50c81bf..12ebe352 100644 --- a/lib/builtin/claude/src/team_observer.dart +++ b/lib/builtin/claude/src/team_observer.dart @@ -131,10 +131,14 @@ Future discoverTeam(String workspacePath, {required String teamsBas typedef PaneLister = Future> 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? statusSub; } /// Watches a workspace's tmux team and emits [TeamMemberJoined] / @@ -230,14 +234,22 @@ class TeamObserver { Future _joined(TeamConfig config, TeamMember m) async { final path = await _resolveTranscript(config, m); TranscriptPublisher? pub; + StreamSubscription? 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 _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)); } diff --git a/lib/builtin/claude/src/transcript_publisher.dart b/lib/builtin/claude/src/transcript_publisher.dart index b8e782bd..e9afd985 100644 --- a/lib/builtin/claude/src/transcript_publisher.dart +++ b/lib/builtin/claude/src/transcript_publisher.dart @@ -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 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 { diff --git a/test/builtin/claude/claude_meta_sidebar_test.dart b/test/builtin/claude/claude_meta_sidebar_test.dart index 5f09bf96..6efd41c3 100644 --- a/test/builtin/claude/claude_meta_sidebar_test.dart +++ b/test/builtin/claude/claude_meta_sidebar_test.dart @@ -1,5 +1,7 @@ import 'package:clide/builtin/claude/src/claude_meta_sidebar.dart'; import 'package:clide/builtin/claude/src/claude_stats.dart'; +import 'package:clide/builtin/claude/src/transcript_publisher.dart'; +import 'package:clide/builtin/claude/src/transcript_reader.dart'; import 'package:clide/kernel/kernel.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -58,6 +60,35 @@ void main() { expect(find.text('No team active.'), findsOneWidget); }); + testWidgets('folds live per-member status (mode + context) into the roster row', (tester) async { + await tester.pumpWidget(harness(f, sidebar())); + await tester.pumpAndSettle(); + + f.services.events.emit(const TeamMemberJoined( + team: 't', + agentId: 'a1', + name: 'Scout', + agentType: 'explorer', + paneId: '%1', + color: 'blue', + )); + await tester.pump(); + await tester.pump(); + + f.services.messages.publish( + ClaudeConversation.publisher, + ClaudeConversation.memberStatusChannel, + ClaudeConversation.memberStatusData( + 'a1', + const SessionStatus(model: 'claude-opus-4-7', permissionMode: 'acceptEdits', contextTokens: 21000), + ), + ); + await tester.pump(); + await tester.pump(); + + expect(find.text('explorer · opus 4.7 · accept-edits · 21k ctx'), findsOneWidget); + }); + testWidgets('degrades to a no-activity message with empty stats', (tester) async { await tester.pumpWidget(harness(f, sidebar())); await tester.pumpAndSettle(); diff --git a/test/builtin/claude/transcript_publisher_test.dart b/test/builtin/claude/transcript_publisher_test.dart index 26808533..ba57722c 100644 --- a/test/builtin/claude/transcript_publisher_test.dart +++ b/test/builtin/claude/transcript_publisher_test.dart @@ -79,5 +79,20 @@ void main() { test('teammateChannel namespaces by agentId', () { expect(ClaudeConversation.teammateChannel('coder@team-x'), 'conversation/coder@team-x'); }); + + test('memberStatusData encodes agentId + present status fields (T-157)', () { + final full = ClaudeConversation.memberStatusData( + 'coder@team-x', + const SessionStatus(model: 'claude-opus-4-7', permissionMode: 'plan', contextTokens: 21000), + ); + expect(full, { + 'agentId': 'coder@team-x', + 'model': 'claude-opus-4-7', + 'permissionMode': 'plan', + 'contextTokens': 21000, + }); + // Absent fields are omitted (only agentId is always present). + expect(ClaudeConversation.memberStatusData('a', const SessionStatus()), {'agentId': 'a'}); + }); }); }