Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

MUL-8047: chore(server): remove the pre-v3 desktop onboarding shim (#9291)

Jiayuan Zhang86020b88a4ae
diff --git a/apps/mobile/data/schemas.ts b/apps/mobile/data/schemas.ts
index 436155225d..afbe16baa4 100644
--- a/apps/mobile/data/schemas.ts
+++ b/apps/mobile/data/schemas.ts
@@ -486,7 +486,6 @@ export const UserSchema: z.ZodType<User> = z.object({
avatar_url: z.string().nullable().default(null),
onboarded_at: z.string().nullable().default(null),
onboarding_questionnaire: z.record(z.string(), z.unknown()).default({}),
- starter_content_state: z.string().nullable().default(null),
language: z.string().nullable().default(null),
profile_description: z.string().default(""),
timezone: z.string().nullable().default(null),
@@ -504,7 +503,6 @@ export const EMPTY_USER: User = {
avatar_url: null,
onboarded_at: null,
onboarding_questionnaire: {},
- starter_content_state: null,
language: null,
profile_description: "",
timezone: null,
diff --git a/apps/ui-lab/src/product-fixtures.ts b/apps/ui-lab/src/product-fixtures.ts
index 3afbe8b8dc..920cc03b35 100644
--- a/apps/ui-lab/src/product-fixtures.ts
+++ b/apps/ui-lab/src/product-fixtures.ts
@@ -34,7 +34,6 @@ export const user: User = {
avatar_url: null,
onboarded_at: time,
onboarding_questionnaire: {},
- starter_content_state: "imported",
language: "en",
profile_description: "",
timezone: "Asia/Shanghai",
diff --git a/apps/web/test/helpers.tsx b/apps/web/test/helpers.tsx
index d1358ea4ba..6118e1b24f 100644
--- a/apps/web/test/helpers.tsx
+++ b/apps/web/test/helpers.tsx
@@ -11,9 +11,6 @@ export const mockUser: User = {
avatar_url: null,
onboarded_at: "2026-01-01T00:00:00Z",
onboarding_questionnaire: {},
- // Matches real server behavior for anyone who onboarded before this
- // field shipped — migration 054 backfills 'skipped_legacy'.
- starter_content_state: "skipped_legacy",
language: null,
timezone: null,
profile_description: "",
diff --git a/packages/core/api/schemas.ts b/packages/core/api/schemas.ts
index a4999b3011..79743b76b4 100644
--- a/packages/core/api/schemas.ts
+++ b/packages/core/api/schemas.ts
@@ -2553,7 +2553,6 @@ export const UserSchema = z.object({
avatar_url: z.string().nullable().default(null),
onboarded_at: z.string().nullable().default(null),
onboarding_questionnaire: z.record(z.string(), z.unknown()).default({}),
- starter_content_state: z.string().nullable().default(null),
language: z.string().nullable().default(null),
profile_description: z.string().default(""),
timezone: z.string().nullable().default(null),
@@ -2568,7 +2567,6 @@ export const EMPTY_USER: User = {
avatar_url: null,
onboarded_at: null,
onboarding_questionnaire: {},
- starter_content_state: null,
language: null,
profile_description: "",
timezone: null,
diff --git a/packages/core/onboarding/needs-backfill.test.ts b/packages/core/onboarding/needs-backfill.test.ts
index e2fc00ed0b..25a2401080 100644
--- a/packages/core/onboarding/needs-backfill.test.ts
+++ b/packages/core/onboarding/needs-backfill.test.ts
@@ -12,7 +12,6 @@ const BASE_USER: User = {
avatar_url: null,
onboarded_at: "2025-01-01T00:00:00Z",
onboarding_questionnaire: {},
- starter_content_state: "imported",
language: null,
profile_description: "",
timezone: null,
diff --git a/packages/core/types/workspace.ts b/packages/core/types/workspace.ts
index b9788ace68..46821e6e81 100644
--- a/packages/core/types/workspace.ts
+++ b/packages/core/types/workspace.ts
@@ -66,14 +66,6 @@ export interface User {
* returns an object (defaults to `{}`), never null.
*/
onboarding_questionnaire: Record<string, unknown>;
- /**
- * Legacy column from the removed starter-content dialog. The column is
- * still written to (always 'imported' for new accounts after the
- * mark-onboarded paths run) so older desktop builds — which still render
- * the dialog on NULL — don't show it to anyone created on a newer server.
- * Kept as `string | null` for forward compatibility.
- */
- starter_content_state: string | null;
/** Preferred UI language. null means "follow client/system". */
language: string | null;
/**
diff --git a/server/cmd/server/router.go b/server/cmd/server/router.go
index ffb6234d38..6bad7ffb5d 100644
--- a/server/cmd/server/router.go
+++ b/server/cmd/server/router.go
@@ -1658,14 +1658,6 @@ func NewRouterWithOptions(pool *pgxpool.Pool, hub *realtime.Hub, bus *events.Bus
r.Patch("/api/me/onboarding", h.PatchOnboarding)
r.Post("/api/me/onboarding/complete", h.CompleteOnboarding)
r.Post("/api/me/onboarding/cloud-waitlist", h.JoinCloudWaitlist)
- // DEPRECATED — shim routes for desktop < v3 during the rollout
- // window. v3 frontend creates the Helper agent + starter issue
- // via generic CreateAgent / CreateIssue and only calls /complete
- // here. Remove once X-Client-Version telemetry confirms zero
- // pre-v3 desktops are still calling these. Handlers live in
- // server/internal/handler/onboarding_shim.go.
- r.Post("/api/me/onboarding/runtime-bootstrap", h.BootstrapOnboardingRuntime)
- r.Post("/api/me/onboarding/no-runtime-bootstrap", h.BootstrapOnboardingNoRuntime)
r.Post("/api/cli-token", h.IssueCliToken)
// Sliding session renewal for clients that hold the session as a
// string (Desktop, mobile). Browsers get theirs re-issued inline by
diff --git a/server/internal/handler/auth.go b/server/internal/handler/auth.go
index 6f4cfbe7b6..389281cff4 100644
--- a/server/internal/handler/auth.go
+++ b/server/internal/handler/auth.go
@@ -71,7 +71,6 @@ type UserResponse struct {
Timezone *string `json:"timezone"`
OnboardedAt *string `json:"onboarded_at"`
OnboardingQuestionnaire json.RawMessage `json:"onboarding_questionnaire"`
- StarterContentState *string `json:"starter_content_state"`
ProfileDescription string `json:"profile_description"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
@@ -100,7 +99,6 @@ func (h *Handler) userToResponse(u db.User) UserResponse {
Timezone: textToPtr(u.Timezone),
OnboardedAt: timestampToPtr(u.OnboardedAt),
OnboardingQuestionnaire: json.RawMessage(q),
- StarterContentState: textToPtr(u.StarterContentState),
ProfileDescription: u.ProfileDescription,
CreatedAt: timestampToString(u.CreatedAt),
UpdatedAt: timestampToString(u.UpdatedAt),
diff --git a/server/internal/handler/onboarding_shim.go b/server/internal/handler/onboarding_shim.go
deleted file mode 100644
index 33e9bef228..0000000000
--- a/server/internal/handler/onboarding_shim.go
+++ /dev/null
@@ -1,623 +0,0 @@
-// onboarding_shim.go — DEPRECATED endpoints kept alive for desktop < v3.
-//
-// Background: pre-v3 desktop builds call BootstrapOnboardingRuntime /
-// BootstrapOnboardingNoRuntime during their onboarding flow. Current
-// clients no longer use the runtime bootstrap path; they create only Mika
-// and start the real interactive onboarding chat before completing setup.
-// Removing this endpoint would still break an old installed desktop
-// talking to a newer server.
-//
-// These handlers are intentionally minimal copies of the pre-v3
-// implementation, condensed to inline DB calls (no OnboardingService /
-// WorkspaceContentService layer — that abstraction died with v3). They
-// remain valid until telemetry on the X-Client-Version header confirms
-// every active desktop install has aged out, at which point this entire
-// file + the two router entries + the 5 tests should be deleted.
-//
-// DO NOT add features here. DO NOT change behavior. The contract is "what
-// pre-v3 desktop expects".
-package handler
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "log/slog"
- "net/http"
- "strings"
- "unicode/utf8"
-
- "github.com/jackc/pgx/v5/pgtype"
-
- "github.com/multica-ai/multica/server/internal/analytics"
- "github.com/multica-ai/multica/server/internal/issueguard"
- "github.com/multica-ai/multica/server/internal/logger"
- obsmetrics "github.com/multica-ai/multica/server/internal/metrics"
- "github.com/multica-ai/multica/server/internal/middleware"
- "github.com/multica-ai/multica/server/internal/service"
- db "github.com/multica-ai/multica/server/pkg/db/generated"
- "github.com/multica-ai/multica/server/pkg/dbid"
- "github.com/multica-ai/multica/server/pkg/protocol"
-)
-
-// Runtime bootstrap is just workspace_id + runtime_id, but keep a separate
-// small cap so this endpoint cannot be used as bulk storage.
-const runtimeBootstrapBodyLimit = 8 * 1024
-
-// maxStarterPromptLen caps the user-supplied StarterPrompt on
-// bootstrapOnboardingRuntimeRequest. The prompt becomes the seeded
-// onboarding issue's description, so it needs room for a real paragraph
-// or two without inviting bulk payload. 2 KiB matches pre-v3 cap.
-const maxStarterPromptLen = 2 * 1024
-
-const (
- onboardingAssistantName = "Multica Helper"
- onboardingIssueTitle = "Start here: learn Multica with Multica Helper"
- onboardingAgentCreationSource = "multica_helper"
-
- // noRuntimeIssueTitle MUST match the pre-v3 service constant so
- // LockAndFindActiveDuplicate dedupes correctly across desktop versions.
- noRuntimeIssueTitle = "Connect a runtime to start using agents"
-)
-
-const onboardingAssistantDescription = "Built-in workspace assistant. Answers Multica questions and runs CLI operations."
-
-const onboardingAssistantAvatarURL = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 128 128'%3E%3Cdefs%3E%3ClinearGradient id='t' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0%25' stop-color='%2323242C'/%3E%3Cstop offset='100%25' stop-color='%2313141A'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect width='128' height='128' rx='28' fill='url(%23t)'/%3E%3Cg stroke='%23FFFFFF' stroke-width='13' stroke-linecap='round'%3E%3Cline x1='64' y1='32' x2='64' y2='96'/%3E%3Cline x1='32' y1='64' x2='96' y2='64'/%3E%3Cline x1='41.4' y1='41.4' x2='86.6' y2='86.6'/%3E%3Cline x1='86.6' y1='41.4' x2='41.4' y2='86.6'/%3E%3C/g%3E%3C/svg%3E"
-
-// onboardingAssistantInstructions is the system prompt persisted on every
-// Multica Helper agent created by this shim. Pre-v3 desktop submits a
-// starter prompt from the historical workspace OnboardingHelperModal; that prompt
-// becomes the issue body, while this constant becomes the agent's identity
-// block in CLAUDE.md / AGENTS.md / GEMINI.md.
-const onboardingAssistantInstructions = `You are Multica Helper, the built-in AI assistant for this Multica workspace. Your role is to help any member use Multica better — answer questions, give advice, and execute workspace operations on their behalf.
-
-## What Multica is
-
-Multica is a source-available, AI-native team workspace (source: https://github.com/multica-ai/multica). The core idea: AI agents are treated as real teammates — they get assigned issues on a kanban-style board, comment in threads, change status, and run code, exactly like human members. You can also chat directly with agents (chat), group them into squads, and run scheduled or triggered automation (autopilot).
-
-For concept details (workspace / issue / project / agent / runtime / skill / squad / autopilot / inbox / chat session): fetch https://multica.ai/docs via WebFetch — that's authoritative. For the "why" or implementation, fetch the GitHub repo above. Never paraphrase concepts from memory.
-
-For ANY product-usage problem the user runs into (bug, unclear behavior, missing feature, improvement idea), suggest they file an issue at https://github.com/multica-ai/multica/issues — that's the official feedback channel.
-
-## What you can do
-
-Your toolbox is the ` + "`multica`" + ` CLI. It's already on your PATH and authenticated as the workspace owner.
-
-Your full capability surface = whatever ` + "`multica --help`" + ` shows. Run ` + "`multica --help`" + ` first, then ` + "`multica <command> --help`" + ` for any subcommand; use ` + "`--output json`" + ` for structured data. The CLI is your manifest — never invent commands or flags.
-
-A few things you can actually do (non-exhaustive — ` + "`--help`" + ` is the source of truth):
-- Create issues, post comments
-- Create or iterate on agents
-- Manage projects, squads, autopilots, skills, runtimes, etc.
-
-## Tone
-
-Be concise and direct, like a colleague. Respond in the user's language (Chinese in, Chinese out). When pointing at a UI location, name the exact path ("Settings → Agents → New"); when pointing at a doc, link to the specific page, not the homepage. Never fabricate URLs, flags, or file paths.`
-
-const onboardingIssueDescription = `Welcome to Multica.
-
-This is your guided first run. Multica Helper is assigned to this issue and will help you try the core workflow:
-
-1. Read Multica Helper's first comment.
-2. Reply with something you want to build, fix, write, or plan.
-3. @mention Multica Helper when you want it to continue.
-4. Open Agents and Runtimes later when you want to customize the teammate or the computer it runs on.
-
-You can close this issue when the workflow makes sense.`
-
-type bootstrapOnboardingRuntimeRequest struct {
- WorkspaceID string `json:"workspace_id"`
- RuntimeID string `json:"runtime_id"`
- StarterPrompt string `json:"starter_prompt,omitempty"`
-}
-
-type bootstrapOnboardingRuntimeResponse struct {
- WorkspaceID string `json:"workspace_id"`
- AgentID string `json:"agent_id"`
- IssueID string `json:"issue_id"`
-}
-
-type bootstrapOnboardingNoRuntimeRequest struct {
- WorkspaceID string `json:"workspace_id"`
-}
-
-type bootstrapOnboardingNoRuntimeResponse struct {
- WorkspaceID string `json:"workspace_id"`
- IssueID string `json:"issue_id"`
-}
-
-// BootstrapOnboardingRuntime — DEPRECATED, kept for desktop < v3.
-//
-// Creates or reuses one "Multica Helper" agent on the supplied runtime,
-// creates or reuses one onboarding issue assigned to it, then marks the
-// user onboarded. Single transaction.
-func (h *Handler) BootstrapOnboardingRuntime(w http.ResponseWriter, r *http.Request) {
- userID, ok := requireUserID(w, r)
- if !ok {
- return
- }
- r.Body = http.MaxBytesReader(w, r.Body, runtimeBootstrapBodyLimit)
- var req bootstrapOnboardingRuntimeRequest
- if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
- writeError(w, http.StatusBadRequest, "invalid request body")
- return
- }
- if req.WorkspaceID == "" {
- writeError(w, http.StatusBadRequest, "workspace_id is required")
- return
- }
- if req.RuntimeID == "" {
- writeError(w, http.StatusBadRequest, "runtime_id is required")
- return
- }
- req.StarterPrompt = strings.TrimSpace(req.StarterPrompt)
- if utf8.RuneCountInString(req.StarterPrompt) > maxStarterPromptLen {
- writeError(w, http.StatusBadRequest, fmt.Sprintf("starter_prompt exceeds %d characters", maxStarterPromptLen))
- return
- }
- wsUUID, ok := parseUUIDOrBadRequest(w, req.WorkspaceID, "workspace_id")
- if !ok {
- return
- }
- runtimeUUID, ok := parseUUIDOrBadRequest(w, req.RuntimeID, "runtime_id")
- if !ok {
- return
- }
- req.WorkspaceID = uuidToString(wsUUID)
- issueCountPolicy := service.ResolveIssueCountPolicy(r.Context(), h.Entitlements, wsUUID)
-
- tx, err := h.TxStarter.Begin(r.Context())
- if err != nil {
- writeError(w, http.StatusInternalServerError, "failed to start onboarding")
- return
- }
- defer tx.Rollback(r.Context())
- qtx := h.Queries.WithTx(tx)
-
- member, err := qtx.GetMemberByUserAndWorkspace(r.Context(), db.GetMemberByUserAndWorkspaceParams{
- UserID: parseUUID(userID),
- WorkspaceID: wsUUID,
- })
- if err != nil {
- writeError(w, http.StatusForbidden, "not a member of this workspace")
- return
- }
-
- runtime, err := qtx.GetAgentRuntimeForWorkspace(r.Context(), db.GetAgentRuntimeForWorkspaceParams{
- ID: runtimeUUID,
- WorkspaceID: wsUUID,
- })
- if err != nil {
- writeError(w, http.StatusBadRequest, "invalid runtime_id")
- return
- }
- if !canUseRuntimeForAgent(member, runtime) {
- writeError(w, http.StatusForbidden, "this runtime is private; only its owner can create agents on it")
- return
- }
-
- agents, err := qtx.ListAgents(r.Context(), wsUUID)
- if err != nil {
- writeError(w, http.StatusInternalServerError, "failed to list agents")
- return
- }
- isFirstAgent := len(agents) == 0
-
- var assistant db.Agent
- assistantCreated := false
- for _, existing := range agents {
- if existing.Name == onboardingAssistantName && existing.Visibility == "workspace" {
- assistant = existing
- break
- }
- }
- if !assistant.ID.Valid {
- assistant, err = qtx.CreateAgent(r.Context(), db.CreateAgentParams{
- WorkspaceID: wsUUID,
- Name: onboardingAssistantName,
- Description: onboardingAssistantDescription,
- AvatarUrl: pgtype.Text{String: onboardingAssistantAvatarURL, Valid: true},
- RuntimeMode: runtime.RuntimeMode,
- RuntimeConfig: []byte("{}"),
- RuntimeID: runtime.ID,
- Visibility: "workspace",
- MaxConcurrentTasks: 6,
- OwnerID: parseUUID(userID),
- Instructions: onboardingAssistantInstructions,
- CustomEnv: []byte("{}"),
- CustomArgs: []byte("[]"),
- McpConfig: nil,
- Model: pgtype.Text{},
- })
- if err != nil {
- slog.Warn("bootstrap onboarding (shim): create assistant failed", append(logger.RequestAttrs(r), "error", err, "workspace_id", req.WorkspaceID)...)
- writeError(w, http.StatusInternalServerError, "failed to create onboarding assistant")
- return
- }
- assistantCreated = true
- }
-
- var emptyUUID pgtype.UUID
- issue, foundIssue, err := issueguard.LockAndFindActiveDuplicate(
- r.Context(), qtx, wsUUID, emptyUUID, emptyUUID, onboardingIssueTitle, false,
- )
- if err != nil {
- slog.Warn("bootstrap onboarding (shim): duplicate issue check failed", append(logger.RequestAttrs(r), "error", err, "workspace_id", req.WorkspaceID)...)
- writeError(w, http.StatusInternalServerError, "failed to create onboarding issue")
- return
- }
- issueCreated := false
- if !foundIssue {
- issueNumber, err := service.AllocateIssueNumber(r.Context(), qtx, wsUUID, issueCountPolicy)
- if err != nil {
- if writeIssueLimitReached(w, err) {
- return
- }
- writeError(w, http.StatusInternalServerError, "failed to allocate issue number")
- return
- }
- description := onboardingIssueDescription
- if req.StarterPrompt != "" {
- description = req.StarterPrompt
- }
- issue, err = qtx.CreateIssue(r.Context(), db.CreateIssueParams{
- ID: dbid.NewV7(),
- WorkspaceID: wsUUID,
- Title: onboardingIssueTitle,
- Description: strOrNullText(description),
- Status: "todo",
- Priority: "high",
- AssigneeType: pgtype.Text{String: "agent", Valid: true},
- AssigneeID: assistant.ID,
- CreatorType: "member",
- CreatorID: parseUUID(userID),
- ParentIssueID: emptyUUID,
- Position: 0,
- Number: issueNumber,
- ProjectID: emptyUUID,
- })
- if err != nil {
- slog.Warn("bootstrap onboarding (shim): create issue failed", append(logger.RequestAttrs(r), "error", err, "workspace_id", req.WorkspaceID)...)
- writeError(w, http.StatusInternalServerError, "failed to create onboarding issue")
- return
- }
- issueCreated = true
- }
-
- // Mark onboarded. COALESCE in MarkUserOnboarded preserves the original
- // timestamp on re-entries, so this is idempotent.
- before, err := qtx.GetUser(r.Context(), parseUUID(userID))
- if err != nil {
- writeError(w, http.StatusInternalServerError, "failed to load user")
- return
- }
- firstCompletion := !before.OnboardedAt.Valid
- updatedUser, err := qtx.MarkUserOnboarded(r.Context(), parseUUID(userID))
- if err != nil {
- writeError(w, http.StatusInternalServerError, "failed to mark onboarded")
- return
- }
- // Claim starter_content_state so pre-v3 desktop builds (which still
- // gate the legacy "starter content" import dialog on NULL) don't pop
- // it for users created by this shim path.
- if err := claimStarterContentStateIfUnset(r.Context(), qtx, parseUUID(userID), before.StarterContentState); err != nil {
- writeError(w, http.StatusInternalServerError, "failed to record starter content state")
- return
- }
-
- if err := tx.Commit(r.Context()); err != nil {
- writeError(w, http.StatusInternalServerError, "failed to finish onboarding")
- return
- }
-
- if assistantCreated {
- resp := h.agentToResponse(assistant)
- h.publish(protocol.EventAgentCreated, req.WorkspaceID, "member", userID, map[string]any{"agent": resp})
- obsmetrics.RecordEvent(h.Analytics, h.Metrics, analytics.AgentCreated(
- userID, req.WorkspaceID, uuidToString(assistant.ID),
- runtime.Provider, runtime.RuntimeMode, onboardingAgentCreationSource, isFirstAgent,
- ))
- }
- if issueCreated {
- prefix := h.getIssuePrefix(r.Context(), issue.WorkspaceID)
- resp := issueToResponse(issue, prefix)
- h.fillStatusCategory(r.Context(), issue.WorkspaceID, &resp)
- h.publish(protocol.EventIssueCreated, req.WorkspaceID, "member", userID, map[string]any{"issue": resp})
- platform, _, _ := middleware.ClientMetadataFromContext(r.Context())
- obsmetrics.RecordEvent(h.Analytics, h.Metrics, analytics.IssueCreated(
- userID, req.WorkspaceID, uuidToString(issue.ID),
- uuidToString(assistant.ID), "", "", analytics.SourceOnboarding,
- platform,
- ))
- if h.shouldEnqueueAgentTask(r.Context(), issue) {
- h.TaskService.EnqueueTaskForIssue(r.Context(), issue)
- }
- }
- if firstCompletion {
- onboardedAt := ""
- if updatedUser.OnboardedAt.Valid {
- onboardedAt = updatedUser.OnboardedAt.Time.UTC().Format("2006-01-02T15:04:05Z07:00")
- }
- obsmetrics.RecordEvent(h.Analytics, h.Metrics, analytics.OnboardingCompleted(
- userID, req.WorkspaceID, analytics.OnboardingPathFull,
- onboardedAt, updatedUser.CloudWaitlistEmail.Valid,
- ))
- }
-
- writeJSON(w, http.StatusOK, bootstrapOnboardingRuntimeResponse{
- WorkspaceID: req.WorkspaceID,
- AgentID: uuidToString(assistant.ID),
- IssueID: uuidToString(issue.ID),
- })
-}
-
-// BootstrapOnboardingNoRuntime — DEPRECATED, kept for desktop < v3.
-//
-// Creates or reuses one "install a runtime" guide issue (assigned to the
-// member themselves) and marks onboarding complete. The user explicitly
-// skipped the runtime step, so we unconditionally seed regardless of any
-// pre-existing runtime on the workspace.
-func (h *Handler) BootstrapOnboardingNoRuntime(w http.ResponseWriter, r *http.Request) {
- userID, ok := requireUserID(w, r)
- if !ok {
- return
- }
- r.Body = http.MaxBytesReader(w, r.Body, runtimeBootstrapBodyLimit)
- var req bootstrapOnboardingNoRuntimeRequest
- if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
- writeError(w, http.StatusBadRequest, "invalid request body")
- return
- }
- if req.WorkspaceID == "" {
- writeError(w, http.StatusBadRequest, "workspace_id is required")
- return
- }
- wsUUID, ok := parseUUIDOrBadRequest(w, req.WorkspaceID, "workspace_id")
- if !ok {
- return
- }
- req.WorkspaceID = uuidToString(wsUUID)
- issueCountPolicy := service.ResolveIssueCountPolicy(r.Context(), h.Entitlements, wsUUID)
-
- tx, err := h.TxStarter.Begin(r.Context())
- if err != nil {
- writeError(w, http.StatusInternalServerError, "failed to start onboarding")
- return
- }
- defer tx.Rollback(r.Context())
- qtx := h.Queries.WithTx(tx)
-
- userBefore, err := qtx.GetUser(r.Context(), parseUUID(userID))
- if err != nil {
- writeError(w, http.StatusInternalServerError, "failed to load user")
- return
- }
-
- if _, err := qtx.GetMemberByUserAndWorkspace(r.Context(), db.GetMemberByUserAndWorkspaceParams{
- UserID: parseUUID(userID),
- WorkspaceID: wsUUID,
- }); err != nil {
- writeError(w, http.StatusForbidden, "not a member of this workspace")
- return
- }
-
- var emptyUUID pgtype.UUID
- existing, foundIssue, err := issueguard.LockAndFindActiveDuplicate(
- r.Context(), qtx, wsUUID, emptyUUID, emptyUUID, noRuntimeIssueTitle, false,
- )
- if err != nil {
- slog.Warn("bootstrap no-runtime onboarding (shim): duplicate issue check failed", append(logger.RequestAttrs(r), "error", err, "workspace_id", req.WorkspaceID)...)
- writeError(w, http.StatusInternalServerError, "failed to create onboarding issue")
- return
- }
-
- var issue db.Issue
- issueCreated := false
- if foundIssue {
- issue = existing
- } else {
- issueNumber, err := service.AllocateIssueNumber(r.Context(), qtx, wsUUID, issueCountPolicy)
- if err != nil {
- if writeIssueLimitReached(w, err) {
- return
- }
- writeError(w, http.StatusInternalServerError, "failed to allocate issue number")
- return
- }
- issue, err = qtx.CreateIssue(r.Context(), db.CreateIssueParams{
- ID: dbid.NewV7(),
- WorkspaceID: wsUUID,
- Title: noRuntimeIssueTitle,
- Description: strOrNullText(noRuntimeIssueDescription(userBefore.Language)),
- Status: "todo",
- Priority: "high",
- AssigneeType: pgtype.Text{String: "member", Valid: true},
- AssigneeID: parseUUID(userID),
- CreatorType: "member",
- CreatorID: parseUUID(userID),
- ParentIssueID: emptyUUID,
- Position: 0,
- Number: issueNumber,
- ProjectID: emptyUUID,
- })
- if err != nil {
- slog.Warn("bootstrap no-runtime onboarding (shim): create issue failed", append(logger.RequestAttrs(r), "error", err, "workspace_id", req.WorkspaceID)...)
- writeError(w, http.StatusInternalServerError, "failed to create onboarding issue")
- return
- }
- issueCreated = true
- }
-
- firstCompletion := !userBefore.OnboardedAt.Valid
- updatedUser, err := qtx.MarkUserOnboarded(r.Context(), parseUUID(userID))
- if err != nil {
- writeError(w, http.StatusInternalServerError, "failed to mark onboarded")
- return
- }
- if err := claimStarterContentStateIfUnset(r.Context(), qtx, parseUUID(userID), userBefore.StarterContentState); err != nil {
- writeError(w, http.StatusInternalServerError, "failed to record starter content state")
- return
- }
-
- if err := tx.Commit(r.Context()); err != nil {
- writeError(w, http.StatusInternalServerError, "failed to finish onboarding")
- return
- }
-
- if issueCreated {
- prefix := h.getIssuePrefix(r.Context(), issue.WorkspaceID)
- resp := issueToResponse(issue, prefix)
- h.fillStatusCategory(r.Context(), issue.WorkspaceID, &resp)
- h.publish(protocol.EventIssueCreated, req.WorkspaceID, "member", userID, map[string]any{"issue": resp})
- platform2, _, _ := middleware.ClientMetadataFromContext(r.Context())
- obsmetrics.RecordEvent(h.Analytics, h.Metrics, analytics.IssueCreated(
- userID, req.WorkspaceID, uuidToString(issue.ID),
- "", "", "", analytics.SourceOnboarding,
- platform2,
- ))
- }
- if firstCompletion {
- onboardedAt := ""
- if updatedUser.OnboardedAt.Valid {
- onboardedAt = updatedUser.OnboardedAt.Time.UTC().Format("2006-01-02T15:04:05Z07:00")
- }
- obsmetrics.RecordEvent(h.Analytics, h.Metrics, analytics.OnboardingCompleted(
- userID, req.WorkspaceID, analytics.OnboardingPathRuntimeSkipped,
- onboardedAt, updatedUser.CloudWaitlistEmail.Valid,
- ))
- }
-
- writeJSON(w, http.StatusOK, bootstrapOnboardingNoRuntimeResponse{
- WorkspaceID: req.WorkspaceID,
- IssueID: uuidToString(issue.ID),
- })
-}
-
-// noRuntimeIssueDescription picks the EN or ZH copy based on the user's
-// language preference. ZH selected on any "zh*" prefix (zh, zh-CN, zh-Hans).
-// Matches pre-v3 service.workspace_content.go behavior 1:1.
-func noRuntimeIssueDescription(language pgtype.Text) string {
- if language.Valid && strings.HasPrefix(language.String, "zh") {
- return zhNoRuntimeIssueDescription()
- }
- return enNoRuntimeIssueDescription()
-}
-
-func enNoRuntimeIssueDescription() string {
- return strings.Join([]string{
- "Welcome to Multica.",
- "",
- "Agents need a runtime before they can execute work. You can still use Multica as a lightweight project-management workspace while you install one.",
- "",
- "## Try Multica first",
- "",
- "Before the runtime is ready, you can:",
- "",
- "1. Create a project for your current work.",
- "2. Create a few issues and move them across backlog, todo, in_progress, and done.",
- "3. Add priorities, labels, comments, and subscriptions.",
- "4. Use Inbox to track assignments and mentions.",
- "",
- "That gives you the project-management layer first. Once a runtime is connected, agents can start working from the same issues.",
- "",
- "## Install your first agent runtime",
- "",
- "Full guide: https://multica.ai/docs/install-agent-runtime",
- "",
- "For English users, the fastest first path is Codex:",
- "",
- "1. Make sure Node.js is installed.",
- "2. Install Codex:",
- " npm i -g @openai/codex",
- "3. Sign in:",
- " codex",
- "4. Confirm your terminal can find it:",
- " which codex",
- " codex --version",
- "5. Restart the Multica daemon:",
- " multica daemon restart",
- " If you use the desktop app, restarting the app is enough.",
- "6. Return to Runtimes and refresh. You should see a Codex runtime online.",
- "7. Create your first agent from that runtime, then assign an issue to the agent and set status to todo.",
- "",
- "Codex reference: https://developers.openai.com/codex/cli",
- "",
- "When the runtime is connected, you can create Multica Helper for a guided first run.",
- }, "\n")
-}
-
-func zhNoRuntimeIssueDescription() string {
- return strings.Join([]string{
- "欢迎来到 Multica。",
- "",
- "智能体需要先连上运行时才能执行工作。运行时还没准备好时,你也可以先把 Multica 当作轻量项目管理工具体验起来。",
- "",
- "## 先体验项目管理功能",
- "",
- "运行时安装前,你可以先做这些事:",
- "",
- "1. 为当前工作创建一个项目。",
- "2. 新建几个 issue,并在 backlog、todo、in_progress、done 之间流转。",
- "3. 给 issue 加优先级、标签、评论和订阅。",
- "4. 用收件箱追踪分配给你的事项和 @mention。",
- "",
- "这样你先熟悉项目管理层。连上运行时后,智能体会直接在这些 issue 上开始工作。",
- "",
- "## 安装第一个 Agent 运行时",
- "",
- "完整文档:https://multica.ai/docs/install-agent-runtime",
- "",
- "中文用户建议先装 Kimi CLI:",
- "",
- "1. 在 macOS / Linux 终端安装 Kimi CLI:",
- " curl -LsSf https://code.kimi.com/install.sh | bash",
- " Windows PowerShell:",
- " Invoke-RestMethod https://code.kimi.com/install.ps1 | Invoke-Expression",
- "2. 确认终端能找到 Kimi:",
- " kimi --version",
- "3. 在你想让 Kimi 工作的项目目录里启动一次:",
- " kimi",
- "4. 首次启动后输入 /login,按提示完成 Kimi Code 或 API key 配置。",
- "5. 重启 Multica 守护进程:",
- " multica daemon restart",
- " 如果你用桌面端,重启 app 即可。",
- "6. 回到 Runtimes 页面刷新。你应该能看到一个在线的 Kimi 运行时。",
- "7. 用这个运行时创建第一个智能体,再把一个 issue 分配给它,并把状态切到 todo。",
- "",
- "Kimi CLI 官方文档:https://moonshotai.github.io/kimi-cli/zh/guides/getting-started.html",
- "",
- "运行时连上后,你就可以创建 Multica Helper,开始一次有智能体参与的上手引导。",
- }, "\n")
-}
-
-// strOrNullText converts an empty-meaning-absent string into a nullable
-// pgtype.Text. Local helper used only by this shim file.
-func strOrNullText(s string) pgtype.Text {
- if s == "" {
- return pgtype.Text{}
- }
- return pgtype.Text{String: s, Valid: true}
-}
-
-// claimStarterContentStateIfUnset transitions starter_content_state from NULL
-// to 'imported'. Older desktop builds render a "starter content" import
-// dialog when this column is NULL — claiming it here suppresses the dialog
-// for users who completed onboarding through this shim path.
-//
-// Only the shim cares about this column. v3 frontend doesn't read it, and
-// the v3 CompleteOnboarding handler intentionally leaves it alone.
-func claimStarterContentStateIfUnset(
- ctx context.Context,
- q *db.Queries,
- userID pgtype.UUID,
- current pgtype.Text,
-) error {
- if current.Valid {
- return nil
- }
- _, err := q.SetStarterContentState(ctx, db.SetStarterContentStateParams{
- ID: userID,
- StarterContentState: pgtype.Text{String: "imported", Valid: true},
- })
- return err
-}
diff --git a/server/internal/handler/onboarding_test.go b/server/internal/handler/onboarding_test.go
index 8434d38855..3123a54b62 100644
--- a/server/internal/handler/onboarding_test.go
+++ b/server/internal/handler/onboarding_test.go
@@ -194,479 +194,6 @@ func TestJoinCloudWaitlistSecondCallOverwrites(t *testing.T) {
}
}
-// ---------------------------------------------------------------------------
-// Shim endpoint tests — guard the BootstrapOnboarding* handlers that were
-// restored for desktop < v3 compatibility. Once telemetry confirms no
-// pre-v3 desktops remain, delete both these tests AND the handlers in
-// onboarding_shim.go in the same commit.
-// ---------------------------------------------------------------------------
-
-func TestBootstrapOnboardingRuntimeCreatesSingleGuideIssue(t *testing.T) {
- if testHandler == nil {
- t.Skip("database not available")
- }
-
- ctx := context.Background()
- t.Cleanup(func() {
- testPool.Exec(ctx, `
- DELETE FROM agent_task_queue
- WHERE agent_id IN (
- SELECT id FROM agent
- WHERE workspace_id = $1 AND name = $2
- )
- `, testWorkspaceID, onboardingAssistantName)
- testPool.Exec(ctx,
- `DELETE FROM issue WHERE workspace_id = $1 AND title = $2`,
- testWorkspaceID, onboardingIssueTitle,
- )
- testPool.Exec(ctx,
- `DELETE FROM agent WHERE workspace_id = $1 AND name = $2`,
- testWorkspaceID, onboardingAssistantName,
- )
- testPool.Exec(ctx,
- `UPDATE "user" SET onboarded_at = NULL, starter_content_state = NULL WHERE id = $1`,
- testUserID,
- )
- })
- testPool.Exec(ctx,
- `DELETE FROM issue WHERE workspace_id = $1 AND title = $2`,
- testWorkspaceID, onboardingIssueTitle,
- )
- testPool.Exec(ctx,
- `DELETE FROM agent WHERE workspace_id = $1 AND name = $2`,
- testWorkspaceID, onboardingAssistantName,
- )
- testPool.Exec(ctx,
- `UPDATE "user" SET onboarded_at = NULL, starter_content_state = NULL WHERE id = $1`,
- testUserID,
- )
-
- body := map[string]string{
- "workspace_id": testWorkspaceID,
- "runtime_id": testRuntimeID,
- }
- w := httptest.NewRecorder()
- testHandler.BootstrapOnboardingRuntime(w, newRequest(http.MethodPost, "/api/me/onboarding/runtime-bootstrap", body))
- if w.Code != http.StatusOK {
- t.Fatalf("BootstrapOnboardingRuntime: expected 200, got %d: %s", w.Code, w.Body.String())
- }
-
- var resp bootstrapOnboardingRuntimeResponse
- if err := json.NewDecoder(w.Body).Decode(&resp); err != nil {
- t.Fatalf("decode response: %v", err)
- }
- if resp.WorkspaceID != testWorkspaceID || resp.AgentID == "" || resp.IssueID == "" {
- t.Fatalf("unexpected response: %+v", resp)
- }
-
- var (
- agentName string
- agentRuntime string
- instructions string
- avatarURL *string
- )
- if err := testPool.QueryRow(ctx, `
- SELECT name, runtime_id, instructions, avatar_url
- FROM agent
- WHERE id = $1
- `, resp.AgentID).Scan(&agentName, &agentRuntime, &instructions, &avatarURL); err != nil {
- t.Fatalf("lookup assistant: %v", err)
- }
- if agentName != onboardingAssistantName {
- t.Fatalf("agent name = %q, want %q", agentName, onboardingAssistantName)
- }
- if agentRuntime != testRuntimeID {
- t.Fatalf("agent runtime = %q, want %q", agentRuntime, testRuntimeID)
- }
- if !strings.Contains(instructions, "built-in AI assistant") {
- t.Fatalf("assistant instructions were not seeded with the new identity: %q", instructions)
- }
- if avatarURL == nil || *avatarURL != onboardingAssistantAvatarURL {
- t.Fatalf("agent avatar_url = %v, want seeded Multica Helper avatar", avatarURL)
- }
-
- var (
- issueTitle string
- assigneeType string
- assigneeID string
- issueStatus string
- issuePriority string
- )
- if err := testPool.QueryRow(ctx, `
- SELECT title, assignee_type, assignee_id, status, priority
- FROM issue
- WHERE id = $1
- `, resp.IssueID).Scan(&issueTitle, &assigneeType, &assigneeID, &issueStatus, &issuePriority); err != nil {
- t.Fatalf("lookup onboarding issue: %v", err)
- }
- if issueTitle != onboardingIssueTitle {
- t.Fatalf("issue title = %q, want %q", issueTitle, onboardingIssueTitle)
- }
- if assigneeType != "agent" || assigneeID != resp.AgentID {
- t.Fatalf("issue assignee = %s/%s, want agent/%s", assigneeType, assigneeID, resp.AgentID)
- }
- if issueStatus != "todo" || issuePriority != "high" {
- t.Fatalf("issue status/priority = %s/%s, want todo/high", issueStatus, issuePriority)
- }
-
- var (
- onboardedAt *time.Time
- starterContentState *string
- )
- if err := testPool.QueryRow(ctx, `
- SELECT onboarded_at, starter_content_state
- FROM "user"
- WHERE id = $1
- `, testUserID).Scan(&onboardedAt, &starterContentState); err != nil {
- t.Fatalf("lookup user onboarding state: %v", err)
- }
- if onboardedAt == nil {
- t.Fatal("expected onboarded_at to be set")
- }
- if starterContentState == nil || *starterContentState != "imported" {
- t.Fatalf("starter_content_state = %v, want imported", starterContentState)
- }
-
- var taskCount int
- if err := testPool.QueryRow(ctx, `
- SELECT count(*)
- FROM agent_task_queue
- WHERE issue_id = $1 AND agent_id = $2
- `, resp.IssueID, resp.AgentID).Scan(&taskCount); err != nil {
- t.Fatalf("count queued tasks: %v", err)
- }
- if taskCount == 0 {
- t.Fatal("expected onboarding issue to enqueue an agent task")
- }
-
- w2 := httptest.NewRecorder()
- testHandler.BootstrapOnboardingRuntime(w2, newRequest(http.MethodPost, "/api/me/onboarding/runtime-bootstrap", body))
- if w2.Code != http.StatusOK {
- t.Fatalf("second BootstrapOnboardingRuntime: expected 200, got %d: %s", w2.Code, w2.Body.String())
- }
- var resp2 bootstrapOnboardingRuntimeResponse
- if err := json.NewDecoder(w2.Body).Decode(&resp2); err != nil {
- t.Fatalf("decode second response: %v", err)
- }
- if resp2.AgentID != resp.AgentID || resp2.IssueID != resp.IssueID {
- t.Fatalf("bootstrap should be idempotent: first=%+v second=%+v", resp, resp2)
- }
-}
-
-func TestBootstrapOnboardingRuntime_WithStarterPrompt(t *testing.T) {
- if testHandler == nil {
- t.Skip("database not available")
- }
-
- ctx := context.Background()
- t.Cleanup(func() {
- testPool.Exec(ctx, `
- DELETE FROM agent_task_queue
- WHERE agent_id IN (
- SELECT id FROM agent
- WHERE workspace_id = $1 AND name = $2
- )
- `, testWorkspaceID, onboardingAssistantName)
- testPool.Exec(ctx,
- `DELETE FROM issue WHERE workspace_id = $1 AND title = $2`,
- testWorkspaceID, onboardingIssueTitle,
- )
- testPool.Exec(ctx,
- `DELETE FROM agent WHERE workspace_id = $1 AND name = $2`,
- testWorkspaceID, onboardingAssistantName,
- )
- testPool.Exec(ctx,
- `UPDATE "user" SET onboarded_at = NULL, starter_content_state = NULL WHERE id = $1`,
- testUserID,
- )
- })
- testPool.Exec(ctx,
- `DELETE FROM issue WHERE workspace_id = $1 AND title = $2`,
- testWorkspaceID, onboardingIssueTitle,
- )
- testPool.Exec(ctx,
- `DELETE FROM agent WHERE workspace_id = $1 AND name = $2`,
- testWorkspaceID, onboardingAssistantName,
- )
- testPool.Exec(ctx,
- `UPDATE "user" SET onboarded_at = NULL, starter_content_state = NULL WHERE id = $1`,
- testUserID,
- )
-
- const wantPrompt = "Introduce Multica to me, please."
- body := map[string]string{
- "workspace_id": testWorkspaceID,
- "runtime_id": testRuntimeID,
- "starter_prompt": wantPrompt,
- }
- w := httptest.NewRecorder()
- testHandler.BootstrapOnboardingRuntime(w, newRequest(http.MethodPost, "/api/me/onboarding/runtime-bootstrap", body))
- if w.Code != http.StatusOK {
- t.Fatalf("BootstrapOnboardingRuntime: expected 200, got %d: %s", w.Code, w.Body.String())
- }
- var resp bootstrapOnboardingRuntimeResponse
- if err := json.NewDecoder(w.Body).Decode(&resp); err != nil {
- t.Fatalf("decode response: %v", err)
- }
-
- var description *string
- if err := testPool.QueryRow(ctx, `
- SELECT description FROM issue WHERE id = $1
- `, resp.IssueID).Scan(&description); err != nil {
- t.Fatalf("lookup issue description: %v", err)
- }
- if description == nil || *description != wantPrompt {
- t.Fatalf("issue description = %v, want %q", description, wantPrompt)
- }
-}
-
-func TestBootstrapOnboardingRuntime_NoStarterPrompt(t *testing.T) {
- if testHandler == nil {
- t.Skip("database not available")
- }
-
- ctx := context.Background()
- t.Cleanup(func() {
- testPool.Exec(ctx, `
- DELETE FROM agent_task_queue
- WHERE agent_id IN (
- SELECT id FROM agent
- WHERE workspace_id = $1 AND name = $2
- )
- `, testWorkspaceID, onboardingAssistantName)
- testPool.Exec(ctx,
- `DELETE FROM issue WHERE workspace_id = $1 AND title = $2`,
- testWorkspaceID, onboardingIssueTitle,
- )
- testPool.Exec(ctx,
- `DELETE FROM agent WHERE workspace_id = $1 AND name = $2`,
- testWorkspaceID, onboardingAssistantName,
- )
- testPool.Exec(ctx,
- `UPDATE "user" SET onboarded_at = NULL, starter_content_state = NULL WHERE id = $1`,
- testUserID,
- )
- })
- testPool.Exec(ctx,
- `DELETE FROM issue WHERE workspace_id = $1 AND title = $2`,
- testWorkspaceID, onboardingIssueTitle,
- )
- testPool.Exec(ctx,
- `DELETE FROM agent WHERE workspace_id = $1 AND name = $2`,
- testWorkspaceID, onboardingAssistantName,
- )
- testPool.Exec(ctx,
- `UPDATE "user" SET onboarded_at = NULL, starter_content_state = NULL WHERE id = $1`,
- testUserID,
- )
-
- body := map[string]string{
- "workspace_id": testWorkspaceID,
- "runtime_id": testRuntimeID,
- }
- w := httptest.NewRecorder()
- testHandler.BootstrapOnboardingRuntime(w, newRequest(http.MethodPost, "/api/me/onboarding/runtime-bootstrap", body))
- if w.Code != http.StatusOK {
- t.Fatalf("BootstrapOnboardingRuntime: expected 200, got %d: %s", w.Code, w.Body.String())
- }
- var resp bootstrapOnboardingRuntimeResponse
- if err := json.NewDecoder(w.Body).Decode(&resp); err != nil {
- t.Fatalf("decode response: %v", err)
- }
-
- var description *string
- if err := testPool.QueryRow(ctx, `
- SELECT description FROM issue WHERE id = $1
- `, resp.IssueID).Scan(&description); err != nil {
- t.Fatalf("lookup issue description: %v", err)
- }
- if description == nil || *description != onboardingIssueDescription {
- t.Fatalf("issue description = %v, want fallback onboardingIssueDescription", description)
- }
-}
-
-func TestBootstrapOnboardingNoRuntimeCreatesSingleGuideIssue(t *testing.T) {
- if testHandler == nil {
- t.Skip("database not available")
- }
-
- ctx := context.Background()
- t.Cleanup(func() {
- testPool.Exec(ctx,
- `DELETE FROM issue WHERE workspace_id = $1 AND title = $2`,
- testWorkspaceID, noRuntimeIssueTitle,
- )
- testPool.Exec(ctx,
- `UPDATE "user" SET onboarded_at = NULL, starter_content_state = NULL, language = NULL WHERE id = $1`,
- testUserID,
- )
- })
- testPool.Exec(ctx,
- `DELETE FROM issue WHERE workspace_id = $1 AND title = $2`,
- testWorkspaceID, noRuntimeIssueTitle,
- )
- testPool.Exec(ctx,
- `UPDATE "user" SET onboarded_at = NULL, starter_content_state = NULL, language = 'en' WHERE id = $1`,
- testUserID,
- )
-
- body := map[string]string{
- "workspace_id": testWorkspaceID,
- }
- w := httptest.NewRecorder()
- testHandler.BootstrapOnboardingNoRuntime(w, newRequest(http.MethodPost, "/api/me/onboarding/no-runtime-bootstrap", body))
- if w.Code != http.StatusOK {
- t.Fatalf("BootstrapOnboardingNoRuntime: expected 200, got %d: %s", w.Code, w.Body.String())
- }
-
- var resp bootstrapOnboardingNoRuntimeResponse
- if err := json.NewDecoder(w.Body).Decode(&resp); err != nil {
- t.Fatalf("decode response: %v", err)
- }
- if resp.WorkspaceID != testWorkspaceID || resp.IssueID == "" {
- t.Fatalf("unexpected response: %+v", resp)
- }
-
- var (
- issueTitle string
- assigneeType string
- assigneeID string
- issueStatus string
- issuePriority string
- description string
- )
- if err := testPool.QueryRow(ctx, `
- SELECT title, assignee_type, assignee_id, status, priority, description
- FROM issue
- WHERE id = $1
- `, resp.IssueID).Scan(&issueTitle, &assigneeType, &assigneeID, &issueStatus, &issuePriority, &description); err != nil {
- t.Fatalf("lookup no-runtime onboarding issue: %v", err)
- }
- if issueTitle != noRuntimeIssueTitle {
- t.Fatalf("issue title = %q, want %q", issueTitle, noRuntimeIssueTitle)
- }
- if assigneeType != "member" || assigneeID != testUserID {
- t.Fatalf("issue assignee = %s/%s, want member/%s", assigneeType, assigneeID, testUserID)
- }
- if issueStatus != "todo" || issuePriority != "high" {
- t.Fatalf("issue status/priority = %s/%s, want todo/high", issueStatus, issuePriority)
- }
- for _, want := range []string{
- "Try Multica first",
- "https://multica.ai/docs/install-agent-runtime",
- "npm i -g @openai/codex",
- } {
- if !strings.Contains(description, want) {
- t.Fatalf("issue description missing %q: %q", want, description)
- }
- }
- if !strings.Contains(description, "Agents need a runtime before they can execute work") {
- t.Fatalf("issue description was not seeded: %q", description)
- }
-
- var (
- onboardedAt *time.Time
- starterContentState *string
- )
- if err := testPool.QueryRow(ctx, `
- SELECT onboarded_at, starter_content_state
- FROM "user"
- WHERE id = $1
- `, testUserID).Scan(&onboardedAt, &starterContentState); err != nil {
- t.Fatalf("lookup user onboarding state: %v", err)
- }
- if onboardedAt == nil {
- t.Fatal("expected onboarded_at to be set")
- }
- if starterContentState == nil || *starterContentState != "imported" {
- t.Fatalf("starter_content_state = %v, want imported", starterContentState)
- }
-
- var taskCount int
- if err := testPool.QueryRow(ctx, `
- SELECT count(*)
- FROM agent_task_queue
- WHERE issue_id = $1
- `, resp.IssueID).Scan(&taskCount); err != nil {
- t.Fatalf("count queued tasks: %v", err)
- }
- if taskCount != 0 {
- t.Fatalf("expected no agent tasks for no-runtime issue, got %d", taskCount)
- }
-
- w2 := httptest.NewRecorder()
- testHandler.BootstrapOnboardingNoRuntime(w2, newRequest(http.MethodPost, "/api/me/onboarding/no-runtime-bootstrap", body))
- if w2.Code != http.StatusOK {
- t.Fatalf("second BootstrapOnboardingNoRuntime: expected 200, got %d: %s", w2.Code, w2.Body.String())
- }
- var resp2 bootstrapOnboardingNoRuntimeResponse
- if err := json.NewDecoder(w2.Body).Decode(&resp2); err != nil {
- t.Fatalf("decode second response: %v", err)
- }
- if resp2.IssueID != resp.IssueID {
- t.Fatalf("bootstrap should be idempotent: first=%+v second=%+v", resp, resp2)
- }
-}
-
-func TestBootstrapOnboardingNoRuntimeUsesChineseGuideForChineseUsers(t *testing.T) {
- if testHandler == nil {
- t.Skip("database not available")
- }
-
- ctx := context.Background()
- t.Cleanup(func() {
- testPool.Exec(ctx,
- `DELETE FROM issue WHERE workspace_id = $1 AND title = $2`,
- testWorkspaceID, noRuntimeIssueTitle,
- )
- testPool.Exec(ctx,
- `UPDATE "user" SET onboarded_at = NULL, starter_content_state = NULL, language = NULL WHERE id = $1`,
- testUserID,
- )
- })
- testPool.Exec(ctx,
- `DELETE FROM issue WHERE workspace_id = $1 AND title = $2`,
- testWorkspaceID, noRuntimeIssueTitle,
- )
- testPool.Exec(ctx,
- `UPDATE "user" SET onboarded_at = NULL, starter_content_state = NULL, language = 'zh-Hans' WHERE id = $1`,
- testUserID,
- )
-
- body := map[string]string{
- "workspace_id": testWorkspaceID,
- }
- w := httptest.NewRecorder()
- testHandler.BootstrapOnboardingNoRuntime(w, newRequest(http.MethodPost, "/api/me/onboarding/no-runtime-bootstrap", body))
- if w.Code != http.StatusOK {
- t.Fatalf("BootstrapOnboardingNoRuntime: expected 200, got %d: %s", w.Code, w.Body.String())
- }
-
- var resp bootstrapOnboardingNoRuntimeResponse
- if err := json.NewDecoder(w.Body).Decode(&resp); err != nil {
- t.Fatalf("decode response: %v", err)
- }
-
- var description string
- if err := testPool.QueryRow(ctx, `
- SELECT description
- FROM issue
- WHERE id = $1
- `, resp.IssueID).Scan(&description); err != nil {
- t.Fatalf("lookup no-runtime onboarding issue: %v", err)
- }
- for _, want := range []string{
- "先体验项目管理功能",
- "https://multica.ai/docs/install-agent-runtime",
- "中文用户建议先装 Kimi CLI",
- "kimi --version",
- } {
- if !strings.Contains(description, want) {
- t.Fatalf("Chinese issue description missing %q: %q", want, description)
- }
- }
-}
-
// counterValue sums a named Prometheus counter across all label
// combinations on the given BusinessMetrics. Events are metrics-only
// since MUL-4127, so PatchOnboarding's emissions are observable ONLY
diff --git a/server/pkg/db/generated/user.sql.go b/server/pkg/db/generated/user.sql.go
index 1f9a35a26b..da341bd844 100644
--- a/server/pkg/db/generated/user.sql.go
+++ b/server/pkg/db/generated/user.sql.go
@@ -248,46 +248,6 @@ func (q *Queries) PatchUserOnboarding(ctx context.Context, arg PatchUserOnboardi
return i, err
}
-const setStarterContentState = `-- name: SetStarterContentState :one
-UPDATE "user" SET
- starter_content_state = $2,
- updated_at = now()
-WHERE id = $1
-RETURNING id, name, email, avatar_url, created_at, updated_at, onboarded_at, onboarding_questionnaire, cloud_waitlist_email, cloud_waitlist_reason, starter_content_state, language, profile_description, timezone
-`
-
-type SetStarterContentStateParams struct {
- ID pgtype.UUID `json:"id"`
- StarterContentState pgtype.Text `json:"starter_content_state"`
-}
-
-// Atomically transition starter_content_state. The handler is
-// responsible for checking the current value first (to decide between
-// "transition NULL -> imported and run the seeding" vs "already
-// decided, short-circuit"). Using COALESCE here would swallow the
-// transition, so this is a straight assignment.
-func (q *Queries) SetStarterContentState(ctx context.Context, arg SetStarterContentStateParams) (User, error) {
- row := q.db.QueryRow(ctx, setStarterContentState, arg.ID, arg.StarterContentState)
- var i User
- err := row.Scan(
- &i.ID,
- &i.Name,
- &i.Email,
- &i.AvatarUrl,
- &i.CreatedAt,
- &i.UpdatedAt,
- &i.OnboardedAt,
- &i.OnboardingQuestionnaire,
- &i.CloudWaitlistEmail,
- &i.CloudWaitlistReason,
- &i.StarterContentState,
- &i.Language,
- &i.ProfileDescription,
- &i.Timezone,
- )
- return i, err
-}
-
const updateUser = `-- name: UpdateUser :one
UPDATE "user" SET
name = COALESCE($2, name),
diff --git a/server/pkg/db/queries/user.sql b/server/pkg/db/queries/user.sql
index eef17ad013..14fd23a54b 100644
--- a/server/pkg/db/queries/user.sql
+++ b/server/pkg/db/queries/user.sql
@@ -73,15 +73,3 @@ UPDATE "user" SET
updated_at = now()
WHERE id = $1
RETURNING *;
-
--- name: SetStarterContentState :one
--- Atomically transition starter_content_state. The handler is
--- responsible for checking the current value first (to decide between
--- "transition NULL -> imported and run the seeding" vs "already
--- decided, short-circuit"). Using COALESCE here would swallow the
--- transition, so this is a straight assignment.
-UPDATE "user" SET
- starter_content_state = $2,
- updated_at = now()
-WHERE id = $1
-RETURNING *;