Files
multica/server/pkg/db/generated/chat_pinned_agent.sql.go
Lambda 68cd730fec feat(chat): Chat V2 — first-class IM-style Chat tab (MUL-4171)
Replace the floating chat FAB/window with a first-class Chat tab under
Inbox, laid out as an IM-style two-pane surface (thread list + conversation).

Highlights:
- New Chat page (packages/views/chat/chat-page.tsx) with URL-addressable
  session selection; web + desktop routing wired up. Removes the old
  chat-fab / chat-window / resize-handles / context-items paths.
- IM thread list: agent avatar + last-message preview + IM timestamp, red
  unread *count* badge (read-cursor model), presence-gated typing vs waiting.
  Rename lives only in the conversation header ⋯ menu (not the list hover).
- Per-session conversation header (rename / view agent / delete), agent-aware
  empty state (avatar + name + description + starter prompts), and a
  deterministic clean-title derivation from the first message.
- Server: read-cursor unread model (migration 145) and per-user pinned agents
  (migration 146, dedicated chat_pinned_agent table + handler/queries).
  New-agent welcome chat auto-enqueues a real agent run (LLM intro, no
  static template).
- Design: fade the global --border token; borderless list headers on
  Chat/Inbox, kept (faded) on the conversation header.

Verified: pnpm typecheck (all packages), go build ./..., go vet, gofmt.
Co-authored-by: multica-agent <github@multica.ai>
2026-07-08 15:12:57 +08:00

121 lines
3.3 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.31.1
// source: chat_pinned_agent.sql
package db
import (
"context"
"github.com/jackc/pgx/v5/pgtype"
)
const createChatPinnedAgent = `-- name: CreateChatPinnedAgent :one
INSERT INTO chat_pinned_agent (workspace_id, user_id, agent_id, position)
VALUES ($1, $2, $3, $4)
ON CONFLICT (workspace_id, user_id, agent_id)
DO UPDATE SET position = chat_pinned_agent.position
RETURNING id, workspace_id, user_id, agent_id, position, created_at
`
type CreateChatPinnedAgentParams struct {
WorkspaceID pgtype.UUID `json:"workspace_id"`
UserID pgtype.UUID `json:"user_id"`
AgentID pgtype.UUID `json:"agent_id"`
Position float64 `json:"position"`
}
// Idempotent: pinning an already-pinned agent is a no-op that returns the
// existing row (DO UPDATE keeps `:one` from hitting a no-rows error).
func (q *Queries) CreateChatPinnedAgent(ctx context.Context, arg CreateChatPinnedAgentParams) (ChatPinnedAgent, error) {
row := q.db.QueryRow(ctx, createChatPinnedAgent,
arg.WorkspaceID,
arg.UserID,
arg.AgentID,
arg.Position,
)
var i ChatPinnedAgent
err := row.Scan(
&i.ID,
&i.WorkspaceID,
&i.UserID,
&i.AgentID,
&i.Position,
&i.CreatedAt,
)
return i, err
}
const deleteChatPinnedAgent = `-- name: DeleteChatPinnedAgent :exec
DELETE FROM chat_pinned_agent
WHERE workspace_id = $1 AND user_id = $2 AND agent_id = $3
`
type DeleteChatPinnedAgentParams struct {
WorkspaceID pgtype.UUID `json:"workspace_id"`
UserID pgtype.UUID `json:"user_id"`
AgentID pgtype.UUID `json:"agent_id"`
}
func (q *Queries) DeleteChatPinnedAgent(ctx context.Context, arg DeleteChatPinnedAgentParams) error {
_, err := q.db.Exec(ctx, deleteChatPinnedAgent, arg.WorkspaceID, arg.UserID, arg.AgentID)
return err
}
const getMaxChatPinnedAgentPosition = `-- name: GetMaxChatPinnedAgentPosition :one
SELECT COALESCE(MAX(position), 0)::float8 AS max_position
FROM chat_pinned_agent
WHERE workspace_id = $1 AND user_id = $2
`
type GetMaxChatPinnedAgentPositionParams struct {
WorkspaceID pgtype.UUID `json:"workspace_id"`
UserID pgtype.UUID `json:"user_id"`
}
func (q *Queries) GetMaxChatPinnedAgentPosition(ctx context.Context, arg GetMaxChatPinnedAgentPositionParams) (float64, error) {
row := q.db.QueryRow(ctx, getMaxChatPinnedAgentPosition, arg.WorkspaceID, arg.UserID)
var max_position float64
err := row.Scan(&max_position)
return max_position, err
}
const listChatPinnedAgents = `-- name: ListChatPinnedAgents :many
SELECT id, workspace_id, user_id, agent_id, position, created_at FROM chat_pinned_agent
WHERE workspace_id = $1 AND user_id = $2
ORDER BY position ASC, created_at ASC
`
type ListChatPinnedAgentsParams struct {
WorkspaceID pgtype.UUID `json:"workspace_id"`
UserID pgtype.UUID `json:"user_id"`
}
func (q *Queries) ListChatPinnedAgents(ctx context.Context, arg ListChatPinnedAgentsParams) ([]ChatPinnedAgent, error) {
rows, err := q.db.Query(ctx, listChatPinnedAgents, arg.WorkspaceID, arg.UserID)
if err != nil {
return nil, err
}
defer rows.Close()
items := []ChatPinnedAgent{}
for rows.Next() {
var i ChatPinnedAgent
if err := rows.Scan(
&i.ID,
&i.WorkspaceID,
&i.UserID,
&i.AgentID,
&i.Position,
&i.CreatedAt,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}