Chat stack: groups of open chats, synced with the open-chat set
A chat dropped onto the middle of another makes a named group (asked at once, "Group N" by default); onto a group it joins, a group dropped onto a chat takes it in, groups merge. The top level shows each group as a small pile with its name and count; a tap opens it in place under a header that leads back (also the scrim, Back and Escape). In a group, dropping a chat on the header leaves the group; a group of one dissolves. The close button ungroups a dropped group with Undo. Rename, Ungroup, Close all (with Undo), Move to group and Remove from group are in the group menu and as semantic actions. Each open-chat entry carries its group name (protocol field "group", omitted when ungrouped; older clients ignore it), stored and pushed by the server like the order; names are trimmed, printable, at most 80 characters. Needs a server restart to keep groups. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -140,7 +140,7 @@ func validChatWorkspaceEntries(ctx context.Context, request protocol.ChatOpenWor
|
||||
return nil, err
|
||||
}
|
||||
if open {
|
||||
valid = append(valid, protocol.ChatOpenWorkspaceEntry{SessionID: id, Floating: entry.Floating})
|
||||
valid = append(valid, protocol.ChatOpenWorkspaceEntry{SessionID: id, Floating: entry.Floating, Group: entry.Group})
|
||||
}
|
||||
}
|
||||
return valid, nil
|
||||
|
||||
@@ -193,3 +193,30 @@ func TestChatOpenWorkspaceFollowsARestartedChat(t *testing.T) {
|
||||
t.Fatalf("stored workspace after /new = %+v", read)
|
||||
}
|
||||
}
|
||||
|
||||
// TestChatOpenWorkspaceSyncsGroups pins that a chat's group travels with its
|
||||
// entry: stored on a write, pushed to the other connection and read back.
|
||||
func TestChatOpenWorkspaceSyncsGroups(t *testing.T) {
|
||||
store := newOperatorStore(t)
|
||||
ctx, _, conns := dialChatConns(t, Options{Chat: scriptedChat(), OperatorRegistry: store}, 2)
|
||||
for _, id := range []string{"ses_a", "ses_b", "ses_c"} {
|
||||
if err := store.RecordOperatorSession(ctx, id, "/work", id, protocol.ChatSessionTagOperator); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
writeChat(t, ctx, conns[0], workspaceWrite("w1", 0,
|
||||
protocol.ChatOpenWorkspaceEntry{SessionID: "ses_a", Group: "Work"},
|
||||
protocol.ChatOpenWorkspaceEntry{SessionID: "ses_b", Group: "Work"},
|
||||
protocol.ChatOpenWorkspaceEntry{SessionID: "ses_c"}))
|
||||
if reply := readUntil(t, ctx, conns[0], protocol.ChatOpenWorkspace).ChatOpenWorkspace; reply.Revision != 1 || reply.Entries[1].Group != "Work" {
|
||||
t.Fatalf("grouped write reply = %+v", reply)
|
||||
}
|
||||
push := readWorkspacePush(t, ctx, conns[1], 1)
|
||||
if push.Entries[0].Group != "Work" || push.Entries[1].Group != "Work" || push.Entries[2].Group != "" {
|
||||
t.Fatalf("grouped push = %+v", push)
|
||||
}
|
||||
writeChat(t, ctx, conns[1], workspaceWrite("w2", 1, protocol.ChatOpenWorkspaceEntry{SessionID: "ses_a", Group: " bad"}))
|
||||
if failed := readUntil(t, ctx, conns[1], protocol.Error); failed.Error == "" {
|
||||
t.Fatal("a malformed group name was accepted")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user