Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
-- name: GetUser :one
SELECT * FROM "user"
WHERE id = $1;
-- name: GetUserByEmail :one
SELECT * FROM "user"
WHERE email = $1;
-- name: GetUsersByIDs :many
-- Batch lookup from the GLOBAL user table (not gated on membership, so departed
-- members still render). Used to enrich attribution initiator / originator refs on
-- task responses without an N+1 (MUL-4302 §9). Returns only the display fields.
SELECT id, name, email, avatar_url FROM "user"
WHERE id = ANY(@ids::uuid[]);
-- name: CreateUser :one
INSERT INTO "user" (name, email, avatar_url)
VALUES ($1, $2, $3)
RETURNING *;
-- name: UpdateUser :one
-- Patches the user-controlled profile fields. Each parameter follows
-- COALESCE-on-NULL semantics so the handler can omit any field it
-- doesn't intend to write.
--
-- `timezone` (Viewing-tz preference) participates in
-- the same shape but uses sqlc.narg + a sentinel-string convention:
-- the handler passes the empty string "" to mean "clear back to NULL"
-- (browser-detected fallback), an IANA name like "Asia/Shanghai" to
-- pin a value, and `sqlc.narg('timezone') IS NULL` (no value at all)
-- to leave the existing column untouched. Folding it into UpdateUser
-- rather than carrying a dedicated UpdateUserTimezone keeps the
-- profile-patch shape uniform between Preferences fields.
UPDATE "user" SET
name = COALESCE($2, name),
avatar_url = COALESCE($3, avatar_url),
language = COALESCE($4, language),
profile_description = COALESCE(sqlc.narg('profile_description'), profile_description),
timezone = CASE
WHEN sqlc.narg('timezone')::text IS NULL THEN timezone
WHEN sqlc.narg('timezone')::text = '' THEN NULL
ELSE sqlc.narg('timezone')::text
END,
updated_at = now()
WHERE id = $1
RETURNING *;
-- name: MarkUserOnboarded :one
UPDATE "user" SET
onboarded_at = COALESCE(onboarded_at, now()),
updated_at = now()
WHERE id = $1
RETURNING *;
-- name: PatchUserOnboarding :one
-- Partial update of the user's onboarding decision fields. Currently only the
-- questionnaire JSONB is patchable — the v2 attempt at persisting Step 3
-- runtime choice on the user row was reverted; that state now lives in a
-- frontend Zustand transient store.
UPDATE "user" SET
onboarding_questionnaire = COALESCE(sqlc.narg('questionnaire'), onboarding_questionnaire),
updated_at = now()
WHERE id = sqlc.arg('id')
RETURNING *;
-- name: AdvanceWhatsNewSeenVersion :one
-- Only moves forward: an older client reporting an older release must not
-- resurface highlights a newer client already dismissed. Both sides are
-- validated MAJOR.MINOR.PATCH strings, so the int[] casts cannot fail and
-- compare numerically (0.7.10 > 0.7.9). No row comes back when the stored
-- version is already at or past the requested one.
UPDATE "user" SET
whats_new_seen_version = sqlc.arg('version')::text,
updated_at = now()
WHERE id = sqlc.arg('id')
AND (
whats_new_seen_version IS NULL
OR string_to_array(whats_new_seen_version, '.')::int[] < string_to_array(sqlc.arg('version')::text, '.')::int[]
)
RETURNING *;
-- name: ClaimStarPromptShowing :one
-- Grants one showing of the star prompt, atomically, so two tabs or devices
-- reacting to the same moment cannot both show it. No row comes back when the
-- user already starred, used up the showings, is inside the cooldown, or has
-- an account newer than the cutoff.
UPDATE "user" SET
star_prompt_shown_count = star_prompt_shown_count + 1,
star_prompt_last_shown_at = now()
WHERE id = sqlc.arg('id')
AND star_prompt_starred_at IS NULL
AND star_prompt_shown_count < sqlc.arg('max_showings')::int
AND created_at <= sqlc.arg('created_before')::timestamptz
AND (star_prompt_last_shown_at IS NULL OR star_prompt_last_shown_at <= sqlc.arg('shown_before')::timestamptz)
RETURNING *;
-- name: MarkStarPromptStarred :one
-- Keeps the first click time; repeating the call is a no-op.
UPDATE "user" SET
star_prompt_starred_at = COALESCE(star_prompt_starred_at, now())
WHERE id = $1
RETURNING *;
-- name: JoinCloudWaitlist :one
-- Records interest in cloud runtimes. Does NOT mark onboarding
-- complete — the user still has to pick a real path (CLI / Skip)
-- in Step 3. Repeating the call overwrites email + reason.
UPDATE "user" SET
cloud_waitlist_email = $2,
cloud_waitlist_reason = $3,
updated_at = now()
WHERE id = $1
RETURNING *;