route slash commands: TUI-only builtins become local notices (T-411)
clide forwards composer input to a headless (stream-json) CLI, where the
TUI's interactive commands don't exist. A known-but-TUI-only command
errored raw ("/x isn't available in this environment", rendered as fake
claude prose); an un-advertised one (e.g. /effort on 2.1.175) was worse —
bracket-pasted to the model as literal text, burning a real turn.
Probed claude 2.1.175 for ground truth: the initialize handshake's
slash_commands advertises skills + the headless builtins only; forwarded
local-command output comes back as an assistant message with model
"<synthetic>"; set_effort is not a control subtype; /usage works headless.
- slash_commands.dart: SlashRoute routing table (owned > advertised >
TUI-only catalog > forward) + kTuiOnlyCommands with clide-native hints
+ tuiOnlyNotice(). One source of truth replacing ad-hoc checks.
- claude_pane._send routes 'unavailable' to a local notice card; nothing
reaches the session.
- transcript_reader: AssistantTextMessage.synthetic ("<synthetic>" model)
so CLI-local output is distinguishable; "<synthetic>" no longer
clobbers the tracked model in SessionStatus (latent /usage bug).
- conversation_view: synthetic output renders as a muted framed "clide"
card (T-306 styling), never coral Claude prose.
- kFallbackSlashCommands trimmed to the genuinely-headless builtin set —
it doubles as the router's advertised fallback, and the old list's
TUI-only entries would have routed to a raw CLI error.
Board (rides this commit): T-414 gains the user's sidebar styling-pass
note; T-416 filed — surface Claude Code Workflow runs in convo/status.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -833,6 +833,15 @@ void main() {
|
||||
expect(find.text('no independent source to follow'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('synthetic CLI-local output renders as a muted "clide" card, not claude prose (T-411)', (tester) async {
|
||||
await pumpWith(tester, [
|
||||
AssistantTextMessage(uuid: 's1', timestamp: _t, isSidechain: false, text: "/effort isn't available in this environment.", synthetic: true),
|
||||
]);
|
||||
expect(find.text('clide'), findsOneWidget);
|
||||
expect(find.text('claude'), findsNothing);
|
||||
expect(find.textContaining("isn't available"), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('an ordinary Bash card has no live-tail segment (T-325)', (tester) async {
|
||||
await pumpWith(tester, [
|
||||
AssistantToolUse(uuid: 'b2', timestamp: _t, isSidechain: false, toolUseId: 'tb2', name: 'Bash', input: const {'command': 'ls -la'}),
|
||||
|
||||
@@ -136,4 +136,58 @@ void main() {
|
||||
expect(r.cursor, 10);
|
||||
});
|
||||
});
|
||||
|
||||
group('routeSlashCommand (T-411)', () {
|
||||
// The probed 2.1.175 shape: skills + headless builtins.
|
||||
const advertised = ['compact', 'context', 'usage', 'whats-next', 'git-commit'];
|
||||
|
||||
test('non-command text routes null (normal message send)', () {
|
||||
expect(routeSlashCommand('hello world', advertised: advertised), isNull);
|
||||
expect(routeSlashCommand('multi\n/line', advertised: advertised), isNull);
|
||||
});
|
||||
|
||||
test('a path-like leading slash is an unknown token → forward (stays literal)', () {
|
||||
expect(routeSlashCommand('/tmp/x.log explain', advertised: advertised), SlashRoute.forward);
|
||||
});
|
||||
|
||||
test('owned beats everything', () {
|
||||
for (final t in ['/clear', '/resume', '/fork', '/model opus']) {
|
||||
expect(routeSlashCommand(t, advertised: advertised), SlashRoute.owned, reason: t);
|
||||
}
|
||||
});
|
||||
|
||||
test('advertised commands (skills + headless builtins) forward', () {
|
||||
expect(routeSlashCommand('/compact', advertised: advertised), SlashRoute.forward);
|
||||
expect(routeSlashCommand('/usage', advertised: advertised), SlashRoute.forward);
|
||||
expect(routeSlashCommand('/whats-next', advertised: advertised), SlashRoute.forward);
|
||||
});
|
||||
|
||||
test('a known TUI-only builtin routes unavailable', () {
|
||||
for (final t in ['/effort high', '/status', '/permissions', '/doctor', '/login']) {
|
||||
expect(routeSlashCommand(t, advertised: advertised), SlashRoute.unavailable, reason: t);
|
||||
}
|
||||
});
|
||||
|
||||
test('an advertised name shadows the TUI-only catalog (a skill named like a builtin forwards)', () {
|
||||
expect(routeSlashCommand('/status', advertised: ['status']), SlashRoute.forward);
|
||||
});
|
||||
|
||||
test('an unknown token forwards (stays literal text downstream)', () {
|
||||
expect(routeSlashCommand('/no-such-thing', advertised: advertised), SlashRoute.forward);
|
||||
});
|
||||
});
|
||||
|
||||
group('tuiOnlyNotice (T-411)', () {
|
||||
test('carries the clide-native pointer when the catalog has one', () {
|
||||
final n = tuiOnlyNotice('status');
|
||||
expect(n, contains('/status is a Claude Code TUI command'));
|
||||
expect(n, contains('Activity tab'));
|
||||
});
|
||||
|
||||
test('plain notice when there is no pointer', () {
|
||||
final n = tuiOnlyNotice('terminal-setup');
|
||||
expect(n, contains('/terminal-setup is a Claude Code TUI command'));
|
||||
expect(n, isNot(contains('→')));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -640,6 +640,16 @@ void main() {
|
||||
expect(statuses.last.permissionMode, 'plan', reason: 'only ExitPlanMode exits plan mode');
|
||||
});
|
||||
|
||||
test('addLocalNotice emits a synthetic clide item and sends nothing (T-411)', () async {
|
||||
final before = proc.writes.length;
|
||||
session.addLocalNotice('/status is a Claude Code TUI command');
|
||||
await Future<void>.delayed(Duration.zero);
|
||||
final notice = items.whereType<AssistantTextMessage>().single;
|
||||
expect(notice.synthetic, isTrue);
|
||||
expect(notice.text, contains('/status'));
|
||||
expect(proc.writes.length, before); // nothing went to the CLI
|
||||
});
|
||||
|
||||
test('resolvePrompt(deny) writes a deny decision with a message', () async {
|
||||
proc.emit(canUseTool('req-3'));
|
||||
await Future<void>.delayed(Duration.zero);
|
||||
|
||||
@@ -524,6 +524,51 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
group('synthetic CLI-local output (T-411)', () {
|
||||
String syntheticEvent(String text) => jsonEncode({
|
||||
'type': 'assistant',
|
||||
'uuid': 'syn1',
|
||||
'timestamp': '2026-06-12T10:00:00.000Z',
|
||||
'message': {
|
||||
'role': 'assistant',
|
||||
'model': '<synthetic>',
|
||||
'content': [
|
||||
{'type': 'text', 'text': text},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
test('a "<synthetic>" assistant message parses with synthetic: true', () {
|
||||
final parsed = parseTranscriptChunk(syntheticEvent("/effort isn't available in this environment."));
|
||||
final msg = parsed.items.whereType<AssistantTextMessage>().single;
|
||||
expect(msg.synthetic, isTrue);
|
||||
expect(msg.text, contains("isn't available"));
|
||||
});
|
||||
|
||||
test('"<synthetic>" never clobbers the tracked model', () {
|
||||
final parsed = parseTranscriptChunk(syntheticEvent('usage text'));
|
||||
expect(parsed.status.model, isNull);
|
||||
});
|
||||
|
||||
test('a real assistant message stays non-synthetic', () {
|
||||
final chunk = jsonEncode({
|
||||
'type': 'assistant',
|
||||
'uuid': 'a2',
|
||||
'timestamp': '2026-06-12T10:00:00.000Z',
|
||||
'message': {
|
||||
'role': 'assistant',
|
||||
'model': 'claude-fable-5',
|
||||
'content': [
|
||||
{'type': 'text', 'text': 'hello'},
|
||||
],
|
||||
},
|
||||
});
|
||||
final parsed = parseTranscriptChunk(chunk);
|
||||
expect(parsed.items.whereType<AssistantTextMessage>().single.synthetic, isFalse);
|
||||
expect(parsed.status.model, 'claude-fable-5');
|
||||
});
|
||||
});
|
||||
|
||||
group('TranscriptReader — append streaming (filesystem)', () {
|
||||
late Directory tempBase;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user