web: shared chat stars, pipeline mini graphs and agent questions

- Persist chat stars in the operator-session registry (chat_star) so every
  browser/device shows the same Starred group; migrate old local stars once.
- Add a compact pipeline graph shape to list responses and draw a lightweight
  list miniature; replace the cryptic id/version line with the stage count.
- Surface OpenCode form questions as a chat card (chat_answer), replay a
  pending form to late subscribers, and notify for background questions.
- Make the mobile dock's Search cell equal to every destination, keep the
  tab row visible with 100svh, and let Source use the full pane height.
- Let a fresh sign-in auto-connect to its own origin; use a Lax session cookie
  with Expires so Remember me survives app/link launches.
- Keep shipped starters and the skill agnostic: no repository paths, project
  areas or personal device commands; add Diagnose/Fix and Research starters.
- Refresh the installed skill and document the new browser conventions.
This commit is contained in:
2026-10-20 03:11:37 +01:00
parent caae8a8038
commit 526c19fc21
46 changed files with 1547 additions and 611 deletions
+27 -5
View File
@@ -30,6 +30,10 @@ type OperatorSession struct {
// so every client sees the same thing; the session and its history are never
// deleted, and reopening clears it back to 0.
ClosedAt int64
// StarredAt is the epoch-millisecond time the operator starred this session,
// or 0 while unstarred. It lives on the server so the starred group is shared
// by every browser and device.
StarredAt int64
}
// ChatCreateBootstrap is the durable progress record for one chat_create
@@ -58,7 +62,8 @@ func (s *Store) initOperatorSessions() error {
_, err := s.db.Exec(`CREATE TABLE IF NOT EXISTS operator_sessions (
session_id TEXT PRIMARY KEY, directory TEXT NOT NULL, title TEXT NOT NULL DEFAULT '',
tag TEXT NOT NULL DEFAULT '', created_at INTEGER NOT NULL, last_used_at INTEGER NOT NULL,
closed_at INTEGER NOT NULL DEFAULT 0, ephemeral INTEGER NOT NULL DEFAULT 0);
closed_at INTEGER NOT NULL DEFAULT 0, starred_at INTEGER NOT NULL DEFAULT 0,
ephemeral INTEGER NOT NULL DEFAULT 0);
CREATE INDEX IF NOT EXISTS operator_sessions_recent ON operator_sessions(last_used_at DESC);`)
if err != nil {
return err
@@ -134,6 +139,11 @@ func (s *Store) migrateOperatorSessions() error {
if err := s.addColumnIfMissing("operator_sessions", "closed_at", "INTEGER NOT NULL DEFAULT 0"); err != nil {
return err
}
// starred_at records the shared star. Existing sessions default to 0
// (unstarred); the column is independent of closed_at.
if err := s.addColumnIfMissing("operator_sessions", "starred_at", "INTEGER NOT NULL DEFAULT 0"); err != nil {
return err
}
// ephemeral marks a chat created for automated verification. It is hidden from
// OperatorSessions but still a real row, so the session stays usable and
// closable. Existing rows default to 0 (a normal, listed chat).
@@ -202,14 +212,26 @@ func (s *Store) ReopenOperatorSession(ctx context.Context, sessionID string) err
return err
}
// SetOperatorSessionStar records the shared star state in one UPDATE. A session
// id that is not an operator session updates no row and is not an error, so a
// pipeline-owned run session is never affected.
func (s *Store) SetOperatorSessionStar(ctx context.Context, sessionID string, starred bool) error {
at := int64(0)
if starred {
at = time.Now().UnixMilli()
}
_, err := s.db.ExecContext(ctx, "UPDATE operator_sessions SET starred_at=? WHERE session_id=?", at, sessionID)
return err
}
// OperatorSession returns one operator session by id. found is false when the id
// is not a recorded operator session (so a pipeline-owned run session is never
// returned). It is one indexed lookup and never mutates the row.
func (s *Store) OperatorSession(ctx context.Context, sessionID string) (OperatorSession, bool, error) {
var session OperatorSession
row := s.db.QueryRowContext(ctx, `SELECT session_id,directory,title,tag,created_at,last_used_at,closed_at
row := s.db.QueryRowContext(ctx, `SELECT session_id,directory,title,tag,created_at,last_used_at,closed_at,starred_at
FROM operator_sessions WHERE session_id=? AND tag <> ''`, sessionID)
if err := row.Scan(&session.ID, &session.Directory, &session.Title, &session.Tag, &session.CreatedAt, &session.UpdatedAt, &session.ClosedAt); err != nil {
if err := row.Scan(&session.ID, &session.Directory, &session.Title, &session.Tag, &session.CreatedAt, &session.UpdatedAt, &session.ClosedAt, &session.StarredAt); err != nil {
if errors.Is(err, sql.ErrNoRows) {
return OperatorSession{}, false, nil
}
@@ -228,7 +250,7 @@ FROM operator_sessions WHERE session_id=? AND tag <> ''`, sessionID)
// operator can still see and reopen what they finished. It is one bounded
// statement; recency is never mutated here.
func (s *Store) OperatorSessions(ctx context.Context) ([]OperatorSession, error) {
rows, err := s.db.QueryContext(ctx, `SELECT session_id,directory,title,tag,created_at,last_used_at,closed_at
rows, err := s.db.QueryContext(ctx, `SELECT session_id,directory,title,tag,created_at,last_used_at,closed_at,starred_at
FROM operator_sessions WHERE tag <> '' AND ephemeral = 0 ORDER BY last_used_at DESC, session_id LIMIT ?`, operatorSessionListLimit)
if err != nil {
return nil, err
@@ -237,7 +259,7 @@ FROM operator_sessions WHERE tag <> '' AND ephemeral = 0 ORDER BY last_used_at D
sessions := []OperatorSession{}
for rows.Next() {
var session OperatorSession
if err := rows.Scan(&session.ID, &session.Directory, &session.Title, &session.Tag, &session.CreatedAt, &session.UpdatedAt, &session.ClosedAt); err != nil {
if err := rows.Scan(&session.ID, &session.Directory, &session.Title, &session.Tag, &session.CreatedAt, &session.UpdatedAt, &session.ClosedAt, &session.StarredAt); err != nil {
return nil, err
}
sessions = append(sessions, session)
@@ -0,0 +1,53 @@
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)
}
}
+22 -2
View File
@@ -118,7 +118,8 @@ func (s *Store) Directory() string { return s.dir }
func (s *Store) List(ctx context.Context) ([]protocol.PipelineSummary, error) {
rows, err := s.db.QueryContext(ctx, `SELECT p.id, p.name, v.version,
json_array_length(v.graph_json, '$.stages'),
strftime('%Y-%m-%dT%H:%M:%SZ', p.created_at), strftime('%Y-%m-%dT%H:%M:%SZ', v.created_at)
strftime('%Y-%m-%dT%H:%M:%SZ', p.created_at), strftime('%Y-%m-%dT%H:%M:%SZ', v.created_at),
v.graph_json
FROM pipelines p JOIN pipeline_versions v ON v.pipeline_id=p.id
WHERE v.version=(SELECT MAX(version) FROM pipeline_versions WHERE pipeline_id=p.id)
ORDER BY p.name, p.id`)
@@ -129,9 +130,28 @@ ORDER BY p.name, p.id`)
result := []protocol.PipelineSummary{}
for rows.Next() {
var item protocol.PipelineSummary
if err := rows.Scan(&item.ID, &item.Name, &item.Version, &item.Stages, &item.CreatedAt, &item.UpdatedAt); err != nil {
var graphJSON string
if err := rows.Scan(&item.ID, &item.Name, &item.Version, &item.Stages, &item.CreatedAt, &item.UpdatedAt, &graphJSON); err != nil {
return nil, err
}
var shape protocol.Graph
if err := json.Unmarshal([]byte(graphJSON), &shape); err == nil && len(shape.Stages) > 0 {
// A list needs the drawing, not the definition: strip prompts,
// configs, tools, limits, notifications and checks so one list reply
// cannot leak a whole pipeline source or grow into a large payload.
shape.Settings = nil
for index := range shape.Stages {
stage := &shape.Stages[index]
stage.Prompt = ""
stage.Output = ""
stage.Configs = nil
stage.Blocks = nil
stage.Memory = nil
stage.Notify = nil
stage.Limits = nil
}
item.Shape = &shape
}
result = append(result, item)
}
return result, rows.Err()