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:
@@ -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) {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user