Show the chat mode control as soon as the session names its mode

A created chat's reply carried no mode, and the chat destination kept the
first row it opened for the whole visit, ignoring later list re-reads, so the
mode control only appeared after closing and reopening the chat. The server
now names the mode on a created row, and the destination adopts each listed
row that a re-read changed (excluding the live running flag), so the open
conversation follows new, refreshed and other-device mode changes in place.
This commit is contained in:
2026-11-02 16:37:35 +00:00
parent d78cbe3f66
commit 1a9fc74999
4 changed files with 345 additions and 10 deletions
+3 -1
View File
@@ -293,7 +293,9 @@ func (m *chatManager) CreateBackend(ctx context.Context, title, directory, backe
m.mu.Lock()
m.cache[session.ID] = backend
m.mu.Unlock()
return session, nil
// The created row names its mode like a listed one, so the opened chat
// shows the mode control at once rather than after the list re-reads.
return m.withMode(ctx, session), nil
}
func (m *chatManager) Create(ctx context.Context, title, directory string) (protocol.ChatSession, error) {
+14
View File
@@ -100,3 +100,17 @@ func TestChatModeIsStoredAppliedAndSurvivesRestart(t *testing.T) {
t.Fatalf("stored mode not re-applied before turns: %v", fake.applied)
}
}
// A created chat names its mode like a listed row, so the client shows the
// mode control without re-reading the list.
func TestCreatedChatNamesItsMode(t *testing.T) {
fake := &modedChat{fakeChat: scriptedChat()}
manager := &chatManager{claude: fake, cache: map[string]string{}}
session, err := manager.CreateBackend(context.Background(), "chat", "/fixture", "claude")
if err != nil {
t.Fatal(err)
}
if session.Mode != "default" || session.ModeName != "Ask" {
t.Fatalf("created session names %q/%q, want the harness default", session.Mode, session.ModeName)
}
}