d1390994cc
The server reads the commands Claude Code's initialize response lists (bundled, user, project, plugin and claude.ai-synced skills plus CLI commands, with descriptions and argument hints), drops terminal-only ones, and serves them per chat over a new chat_commands request without waiting for a CLI start. The composer palette lists them after the recorded commands; choosing one inserts "/<name> " and sending passes it to the harness as an ordinary prompt. Codex, OpenCode and Pi chats reply with an empty list. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
79 lines
2.6 KiB
Dart
79 lines
2.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../domain/chat_commands.dart';
|
|
|
|
/// The command palette above the composer: the recorded commands matching the
|
|
/// slash word, each with its own `/name` and summary, then the session's
|
|
/// harness commands and skills with their argument hint and description.
|
|
///
|
|
/// Rows are standard Material `ListTile`s, so typography, colours and text
|
|
/// scaling stay the theme's. The list is content-sized and never imposes a fixed height;
|
|
/// a viewport-bound scroll keeps a tall text scale reachable.
|
|
class ChatCommandPalette extends StatelessWidget {
|
|
const ChatCommandPalette({
|
|
super.key,
|
|
required this.commands,
|
|
required this.selectedIndex,
|
|
required this.onSelected,
|
|
});
|
|
|
|
final List<ChatCommand> commands;
|
|
|
|
/// The highlighted row. Callers clamp it to this list.
|
|
final int selectedIndex;
|
|
|
|
final ValueChanged<ChatCommand> onSelected;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
if (commands.isEmpty) return const SizedBox.shrink();
|
|
return ConstrainedBox(
|
|
constraints: BoxConstraints(
|
|
maxHeight: MediaQuery.sizeOf(context).height * 0.4,
|
|
),
|
|
child: SingleChildScrollView(
|
|
child: Semantics(
|
|
container: true,
|
|
label: 'Command suggestions',
|
|
child: _materialRows(context),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _materialRows(BuildContext context) {
|
|
return Card(
|
|
key: const Key('chat-command-palette'),
|
|
margin: EdgeInsets.zero,
|
|
clipBehavior: Clip.antiAlias,
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
for (var index = 0; index < commands.length; index += 1)
|
|
ListTile(
|
|
key: ValueKey<String>('chat-command-${commands[index].name}'),
|
|
selected: index == selectedIndex,
|
|
title: Text(
|
|
commands[index].fromHarness
|
|
? commands[index].usage
|
|
: '/${commands[index].name}',
|
|
),
|
|
// A skill's description can run to a paragraph; two lines
|
|
// identify it without crowding the list.
|
|
subtitle: commands[index].summary.isEmpty
|
|
? null
|
|
: Text(
|
|
commands[index].summary,
|
|
maxLines: commands[index].fromHarness ? 2 : null,
|
|
overflow: commands[index].fromHarness
|
|
? TextOverflow.ellipsis
|
|
: null,
|
|
),
|
|
onTap: () => onSelected(commands[index]),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|