Improve onboarding defaults and issue goal fallback

This commit is contained in:
Dotta
2026-03-12 08:50:31 -05:00
parent 5f3f354b3a
commit 448e9c192b
9 changed files with 378 additions and 77 deletions

View File

@@ -0,0 +1,22 @@
import { describe, expect, it } from "vitest";
import { parseOnboardingGoalInput } from "./onboarding-goal";
describe("parseOnboardingGoalInput", () => {
it("uses a single-line goal as the title only", () => {
expect(parseOnboardingGoalInput("Ship the MVP")).toEqual({
title: "Ship the MVP",
description: null,
});
});
it("splits a multiline goal into title and description", () => {
expect(
parseOnboardingGoalInput(
"Ship the MVP\nLaunch to 10 design partners\nMeasure retention",
),
).toEqual({
title: "Ship the MVP",
description: "Launch to 10 design partners\nMeasure retention",
});
});
});

View File

@@ -0,0 +1,18 @@
export function parseOnboardingGoalInput(raw: string): {
title: string;
description: string | null;
} {
const trimmed = raw.trim();
if (!trimmed) {
return { title: "", description: null };
}
const [firstLine, ...restLines] = trimmed.split(/\r?\n/);
const title = firstLine.trim();
const description = restLines.join("\n").trim();
return {
title,
description: description.length > 0 ? description : null,
};
}