Chat: unnamed chats take the harness title, harness default per folder, word-safe tables, Send later
- New chat: a cleared Name creates the chat without an operator title; the list shows the harness's own title, or the default name until it has one. The server no longer records "New chat" for a blank title and OpenCode is created without a title so it names the session itself. - New chat harness defaults to the one last used in the chosen folder, else anywhere, else OpenCode; remembered on the device per server. - Markdown tables wrap at word boundaries and never go below a column's longest word (tokens over ~40 characters may break); a table whose words cannot fit scrolls sideways with the code block affordance. - Composer: right-click, long-press, Shift+F10 or the context menu key on Send opens Send later... (30 min, 1 h, tomorrow 9:00, usage reset, pick a time), sent through the same path with send_at. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../domain/chat_default_name.dart';
|
||||
|
||||
export '../../domain/chat_default_name.dart' show chatBackendLabel;
|
||||
|
||||
/// The web's directory prompt, also the directory picker's label.
|
||||
const String chatCreatePrompt = 'Where should this chat live?';
|
||||
|
||||
@@ -25,15 +29,6 @@ String chatDirectoryLabel(String choice, List<String> directories) {
|
||||
return '$chatHomeLabel — $home';
|
||||
}
|
||||
|
||||
/// The web's names for the chat harnesses; an unknown one shows as sent.
|
||||
String chatBackendLabel(String backend) => switch (backend) {
|
||||
'codex' => 'Codex',
|
||||
'claude' => 'Claude',
|
||||
'pi' => 'Pi',
|
||||
'opencode' => 'OpenCode',
|
||||
_ => backend,
|
||||
};
|
||||
|
||||
/// The create dialog's server catalog area: loading, error with retry, the
|
||||
/// directory choices and, only when the server offers more than one, the
|
||||
/// harness choice.
|
||||
@@ -101,13 +96,18 @@ class ChatCatalogFields extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
if (backends.length > 1)
|
||||
MaterialPickerField(
|
||||
fieldKey: const Key('chat-create-backend'),
|
||||
label: 'Chat harness',
|
||||
value: backend,
|
||||
values: backends,
|
||||
labelOf: chatBackendLabel,
|
||||
onSelected: onBackend,
|
||||
// Keyed by the value so the harness remembered for a folder,
|
||||
// read after the field first shows, replaces its initial value.
|
||||
KeyedSubtree(
|
||||
key: ValueKey('chat-create-backend-$backend'),
|
||||
child: MaterialPickerField(
|
||||
fieldKey: const Key('chat-create-backend'),
|
||||
label: 'Chat harness',
|
||||
value: backend,
|
||||
values: backends,
|
||||
labelOf: chatBackendLabel,
|
||||
onSelected: onBackend,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../core/api_gateway.dart';
|
||||
import '../../../../core/servers/server_scope.dart';
|
||||
import '../../data/chat_create_harness_store.dart';
|
||||
import '../../data/chat_create_prompt_store.dart';
|
||||
import '../../data/chat_repository.dart';
|
||||
import '../../data/directory_listing.dart';
|
||||
@@ -20,6 +21,7 @@ const String chatCreateInstructionsHelper =
|
||||
"repository's AGENTS.md and skills.";
|
||||
const String chatCreateModelNote =
|
||||
"New chats start with the server's default model.";
|
||||
const String chatCreateNameHelper = "Leave empty to use the harness's title";
|
||||
|
||||
class ChatDraft {
|
||||
const ChatDraft({
|
||||
@@ -29,6 +31,7 @@ class ChatDraft {
|
||||
required this.instructions,
|
||||
});
|
||||
|
||||
/// The operator's name for the chat; empty leaves naming to the harness.
|
||||
final String title;
|
||||
final String directory;
|
||||
final String backend;
|
||||
@@ -45,6 +48,7 @@ Future<JsonMap?> showChatCreateDialog(
|
||||
required Future<JsonMap> Function(ChatDraft draft, String operationId)
|
||||
onSubmit,
|
||||
ChatCreatePromptStore? prompts,
|
||||
ChatCreateHarnessStore? harnesses,
|
||||
}) {
|
||||
final dialog = ServerContext.forServer(
|
||||
context,
|
||||
@@ -54,6 +58,7 @@ Future<JsonMap?> showChatCreateDialog(
|
||||
operationId: operationId,
|
||||
onSubmit: onSubmit,
|
||||
prompts: prompts,
|
||||
harnesses: harnesses,
|
||||
),
|
||||
);
|
||||
return showDialog<JsonMap>(context: context, builder: (_) => dialog);
|
||||
@@ -66,11 +71,15 @@ class CreateChatDialog extends StatefulWidget {
|
||||
required this.operationId,
|
||||
required this.onSubmit,
|
||||
this.prompts,
|
||||
this.harnesses,
|
||||
});
|
||||
|
||||
/// The last first-prompt choice per harness and directory.
|
||||
final ChatCreatePromptStore? prompts;
|
||||
|
||||
/// The harness last used per directory and anywhere.
|
||||
final ChatCreateHarnessStore? harnesses;
|
||||
|
||||
final ChatRepository repository;
|
||||
final String operationId;
|
||||
final Future<JsonMap> Function(ChatDraft draft, String operationId) onSubmit;
|
||||
@@ -85,12 +94,21 @@ class _CreateChatDialogState extends State<CreateChatDialog> {
|
||||
SharedPreferencesChatCreatePromptStore(
|
||||
serverId: serverStorageScope(serverIdentity(widget.repository.gateway)),
|
||||
);
|
||||
late final ChatCreateHarnessStore _harnesses =
|
||||
widget.harnesses ??
|
||||
SharedPreferencesChatCreateHarnessStore(
|
||||
serverId: serverStorageScope(serverIdentity(widget.repository.gateway)),
|
||||
);
|
||||
final _instructions = TextEditingController();
|
||||
final _name = TextEditingController();
|
||||
|
||||
/// The name follows the folder and harness until the operator edits it.
|
||||
bool _nameEdited = false;
|
||||
|
||||
/// An explicit harness pick is kept unless the next folder remembers one.
|
||||
bool _backendTouched = false;
|
||||
int _harnessRecall = 0;
|
||||
|
||||
/// Whether the new chat starts with the prompt below.
|
||||
bool _sendPrompt = false;
|
||||
|
||||
@@ -142,14 +160,12 @@ class _CreateChatDialogState extends State<CreateChatDialog> {
|
||||
_directory = chatDirectoryChoices(_directories).contains(_directory)
|
||||
? _directory
|
||||
: chatHomeDirectory;
|
||||
_backend = _backends.contains(_backend)
|
||||
_backend = _backendTouched && _backends.contains(_backend)
|
||||
? _backend
|
||||
: _backends.contains('opencode')
|
||||
? 'opencode'
|
||||
: _backends.first;
|
||||
: chatDefaultHarness(_backends);
|
||||
_loading = false;
|
||||
});
|
||||
_choiceChanged();
|
||||
_directoryChanged();
|
||||
} catch (error) {
|
||||
if (!mounted || attempt != _attempt) return;
|
||||
setState(() {
|
||||
@@ -159,6 +175,31 @@ class _CreateChatDialogState extends State<CreateChatDialog> {
|
||||
}
|
||||
}
|
||||
|
||||
/// A folder pick: the name follows at once, and the harness last used there
|
||||
/// (else anywhere) becomes the default once read, unless the operator
|
||||
/// picked a harness and this folder remembers none.
|
||||
Future<void> _directoryChanged() async {
|
||||
_choiceChanged();
|
||||
final directory = _directory ?? chatHomeDirectory;
|
||||
final recall = ++_harnessRecall;
|
||||
final remembered = await Future.wait([
|
||||
_harnesses.read(directory),
|
||||
_harnesses.readLast(),
|
||||
]);
|
||||
if (!mounted || recall != _harnessRecall || _backends.isEmpty) return;
|
||||
final here = remembered[0];
|
||||
final next = _backendTouched && !_backends.contains(here)
|
||||
? _backend
|
||||
: chatDefaultHarness(
|
||||
_backends,
|
||||
directoryLast: here,
|
||||
anywhereLast: remembered[1],
|
||||
);
|
||||
if (next == _backend) return;
|
||||
setState(() => _backend = next);
|
||||
_choiceChanged();
|
||||
}
|
||||
|
||||
bool get _catalogReady => !_loading && _catalogError == null;
|
||||
bool get _promptReady => !_sendPrompt || _instructions.text.trim().isNotEmpty;
|
||||
|
||||
@@ -249,7 +290,7 @@ class _CreateChatDialogState extends State<CreateChatDialog> {
|
||||
_directory = chosen;
|
||||
}
|
||||
});
|
||||
_choiceChanged();
|
||||
_directoryChanged();
|
||||
}
|
||||
|
||||
Future<void> _submit() async {
|
||||
@@ -270,9 +311,7 @@ class _CreateChatDialogState extends State<CreateChatDialog> {
|
||||
final name = _name.text.trim();
|
||||
final session = await widget.onSubmit(
|
||||
ChatDraft(
|
||||
title: name.isEmpty
|
||||
? defaultChatName(directory, chatBackendLabel(backend))
|
||||
: name,
|
||||
title: name,
|
||||
directory: directory,
|
||||
backend: backend,
|
||||
instructions: sendPrompt ? promptText : '',
|
||||
@@ -281,6 +320,7 @@ class _CreateChatDialogState extends State<CreateChatDialog> {
|
||||
);
|
||||
// Only an actually sent prompt becomes Last used. Starting a promptless
|
||||
// chat must not erase a saved preset (or wait for its pending read).
|
||||
unawaited(_harnesses.write(directory, backend));
|
||||
if (sendPrompt) {
|
||||
unawaited(
|
||||
_prompts.write(backend, directory, (
|
||||
@@ -316,10 +356,14 @@ class _CreateChatDialogState extends State<CreateChatDialog> {
|
||||
backend: _backend,
|
||||
onDirectory: (value) {
|
||||
setState(() => _directory = value);
|
||||
_choiceChanged();
|
||||
_directoryChanged();
|
||||
},
|
||||
onBackend: (value) {
|
||||
setState(() => _backend = value);
|
||||
setState(() {
|
||||
_backend = value;
|
||||
_backendTouched = true;
|
||||
});
|
||||
_harnessRecall++;
|
||||
_choiceChanged();
|
||||
},
|
||||
onRetry: _loadCatalog,
|
||||
@@ -332,6 +376,7 @@ class _CreateChatDialogState extends State<CreateChatDialog> {
|
||||
key: const Key('chat-create-name'),
|
||||
controller: _name,
|
||||
onChanged: (_) => _nameEdited = true,
|
||||
decoration: const InputDecoration(helperText: chatCreateNameHelper),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
ChatPromptChooser(
|
||||
|
||||
Reference in New Issue
Block a user