Chat: /new continues the same chat on a fresh session
The composer's /new used to create a separate chat. It now sends chat_new_session. The server starts a fresh native session on the chat's own harness (OpenCode, Codex or Claude Code) and re-keys the operator_sessions row in one transaction. The chat keeps its title, directory, backend, colour, star, model and mode. The old row is kept unlisted with replaced_by, and its native session stays resumable. The reply and the chat_session_changed push carry previous_id, so every client swaps the row in place and an open conversation follows it to the fresh, empty transcript with a notice.
This commit is contained in:
@@ -16,7 +16,7 @@ class _ModeScreenGateway implements ApiGateway {
|
||||
_claude('s', 'Wire chat', mode: 'default', name: 'Ask for permission'),
|
||||
];
|
||||
|
||||
/// The `chat_session` a create replies with.
|
||||
/// The `chat_session` a `/new` replies with, for the chat `s`.
|
||||
JsonMap created = _claude('n1', 'New chat');
|
||||
|
||||
/// Holds list reads while set, so a test can look before the re-read lands.
|
||||
@@ -33,8 +33,10 @@ class _ModeScreenGateway implements ApiGateway {
|
||||
final rows = [...sessions];
|
||||
await listGate?.future;
|
||||
return {'chat_sessions': rows};
|
||||
case 'chat_create':
|
||||
return {'chat_session': created};
|
||||
case 'chat_new_session':
|
||||
return {
|
||||
'chat_session': {...created, 'previous_id': 's'},
|
||||
};
|
||||
case 'chat_messages':
|
||||
return {
|
||||
'chat_history': {
|
||||
@@ -234,7 +236,7 @@ void main() {
|
||||
}
|
||||
|
||||
testWidgets(
|
||||
'a created chat whose reply names its mode shows it before the list re-reads',
|
||||
'a new session whose reply names its mode shows it before the list re-reads',
|
||||
(tester) async {
|
||||
final gateway = _ModeScreenGateway()
|
||||
..created = _claude('n1', 'New chat', mode: 'plan', name: 'Plan');
|
||||
@@ -258,7 +260,7 @@ void main() {
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'a created chat whose reply lacks its mode shows it when the list re-reads',
|
||||
'a new session whose reply lacks its mode shows it when the list re-reads',
|
||||
(tester) async {
|
||||
final gateway = _ModeScreenGateway();
|
||||
await _pump(
|
||||
@@ -271,12 +273,9 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
gateway
|
||||
..listGate = Completer<void>()
|
||||
..sessions = [
|
||||
_claude('n1', 'New chat', mode: 'plan', name: 'Plan'),
|
||||
...gateway.sessions,
|
||||
];
|
||||
..sessions = [_claude('n1', 'New chat', mode: 'plan', name: 'Plan')];
|
||||
await runNew(tester);
|
||||
// The row is open on the create reply, which names no mode.
|
||||
// The row is open on the /new reply, which names no mode.
|
||||
expect(find.text('New chat'), findsWidgets);
|
||||
expect(_shown(tester), isNull);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user