ff36e777c9
Enter inserts a newline and Ctrl/Cmd+Enter sends; slash commands still run on Enter. Chat renames are stored in the server registry so every device sees the same title, with a one-time upload of old local titles. The star no longer covers the row status, and shell frames patch the background bar in place so the composer stays mounted while streaming.
93 lines
3.1 KiB
Go
93 lines
3.1 KiB
Go
package pipeline
|
|
|
|
import (
|
|
"context"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
// TestOperatorSessionStarIsSharedAndReversible proves the server-side star
|
|
// contract: starring records starred_at on the registry row, listing returns it,
|
|
// unstarring clears it, and the OpenCode session id and other fields are never
|
|
// changed. This is what makes the Starred group visible from every browser.
|
|
func TestOperatorSessionStarIsSharedAndReversible(t *testing.T) {
|
|
ctx := context.Background()
|
|
store, err := Open(filepath.Join(t.TempDir(), "star.db"))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
defer store.Close()
|
|
if err := store.RecordOperatorSession(ctx, "ses_a", "/work/a", "A", "operator"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := store.SetOperatorSessionStar(ctx, "ses_a", true); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
starred, found, err := store.OperatorSession(ctx, "ses_a")
|
|
if err != nil || !found {
|
|
t.Fatalf("starred lookup: found=%v err=%v", found, err)
|
|
}
|
|
if starred.StarredAt <= 0 {
|
|
t.Fatalf("star did not record starred_at: %+v", starred)
|
|
}
|
|
listed, err := store.OperatorSessions(ctx)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(listed) != 1 || listed[0].StarredAt != starred.StarredAt {
|
|
t.Fatalf("list did not return the shared star: %+v", listed)
|
|
}
|
|
if err := store.SetOperatorSessionStar(ctx, "ses_a", false); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
plain, found, err := store.OperatorSession(ctx, "ses_a")
|
|
if err != nil || !found {
|
|
t.Fatalf("unstarred lookup: found=%v err=%v", found, err)
|
|
}
|
|
if plain.StarredAt != 0 {
|
|
t.Fatalf("unstar did not clear starred_at: %+v", plain)
|
|
}
|
|
if plain.ID != "ses_a" || plain.Directory != "/work/a" || plain.Title != "A" || plain.Tag != "operator" {
|
|
t.Fatalf("star toggling changed other session fields: %+v", plain)
|
|
}
|
|
}
|
|
|
|
// TestOperatorSessionTitleIsShared proves the shared rename contract: the
|
|
// registry title is updated without changing the OpenCode session id, other
|
|
// fields or recency, and listing returns the new title for every client.
|
|
func TestOperatorSessionTitleIsShared(t *testing.T) {
|
|
ctx := context.Background()
|
|
store, err := Open(filepath.Join(t.TempDir(), "rename.db"))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
defer store.Close()
|
|
if err := store.RecordOperatorSession(ctx, "ses_a", "/work/a", "New chat", "operator"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
before, found, err := store.OperatorSession(ctx, "ses_a")
|
|
if err != nil || !found {
|
|
t.Fatalf("lookup: found=%v err=%v", found, err)
|
|
}
|
|
if err := store.SetOperatorSessionTitle(ctx, "ses_a", "Shared name"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
after, found, err := store.OperatorSession(ctx, "ses_a")
|
|
if err != nil || !found {
|
|
t.Fatalf("lookup after rename: found=%v err=%v", found, err)
|
|
}
|
|
if after.Title != "Shared name" {
|
|
t.Fatalf("title = %q", after.Title)
|
|
}
|
|
if after.ID != before.ID || after.Directory != before.Directory || after.UpdatedAt != before.UpdatedAt {
|
|
t.Fatalf("rename changed unrelated fields:\nbefore %+v\nafter %+v", before, after)
|
|
}
|
|
listed, err := store.OperatorSessions(ctx)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(listed) != 1 || listed[0].Title != "Shared name" {
|
|
t.Fatalf("list did not return the shared title: %+v", listed)
|
|
}
|
|
}
|