fix(home): send starter cards instead of filling the composer
Independent Staging Quality Gate / validate (push) Successful in 11m21s
Independent Staging Quality Gate / publish (push) Successful in 17m56s

Clicking today's reading or a topic card should open a consultation and wait for the model, not leave the question in the input box.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Jesse_Chen
2026-08-21 22:02:40 +08:00
parent cf168a54c0
commit 649ba32034
7 changed files with 70 additions and 18 deletions
+38 -7
View File
@@ -2067,8 +2067,8 @@ export default function Home() {
}
}
async function startNewChat() {
if (!account || !modelCatalog || creatingSession) return;
async function startNewChat(): Promise<ChatSession | null> {
if (!account || !modelCatalog || creatingSession) return null;
const nextSession = createSession(modelCatalog.defaultModelId);
const previousSessionId = activeSession?.id ?? "";
setCreatingSession(true);
@@ -2081,6 +2081,7 @@ export default function Home() {
setRequestError(null);
try {
await persistSession(nextSession, "create");
return nextSession;
} catch (caught) {
setSessions((current) => current.filter((session) => session.id !== nextSession.id));
setActiveSessionId(previousSessionId);
@@ -2088,6 +2089,7 @@ export default function Home() {
sessionId: previousSessionId,
message: caught instanceof Error ? caught.message : "新对话未能保存到云端。",
});
return null;
} finally {
setCreatingSession(false);
}
@@ -2498,8 +2500,37 @@ export default function Home() {
window.requestAnimationFrame(() => composerInput.current?.focus());
}
function draftDailyStarlanguageQuestion() {
chooseSuggestedQuestion(
async function startSuggestedConsultation(
question: string,
theme?: Theme,
entrypoint: ConsultationEntrypoint | null = null,
) {
if (
pendingSessionId
|| cancellationInFlight.current
|| pendingConsultation.current
|| creatingSession
) return;
const trimmed = question.trim();
if (!trimmed || !account || !modelCatalog) return;
let targetSession = activeSession
&& activeSession.sessionType === "consultation"
&& activeSession.messages.length === 0
? activeSession
: null;
if (!targetSession) {
targetSession = await startNewChat();
if (!targetSession) return;
}
await send(trimmed, theme, entrypoint, null, targetSession.id, {
sessionOverride: targetSession,
});
}
function startDailyStarlanguageConsultation() {
void startSuggestedConsultation(
dailyStarlanguageQuestion,
"timing",
"daily_starlanguage",
@@ -3749,7 +3780,7 @@ export default function Home() {
type="button"
aria-label={natalMinuteAvailable ? dailyStarlanguageQuestion : "查看今日运势"}
disabled={productEntrypointsDisabled}
onClick={draftDailyStarlanguageQuestion}
onClick={startDailyStarlanguageConsultation}
/>
<div className="product-entrypoint-copy">
<h2 id="daily-starlanguage-title">{natalMinuteAvailable ? "今日星语" : "每日运势"}</h2>
@@ -3806,8 +3837,8 @@ export default function Home() {
key={`${item.theme}-${item.text}`}
type="button"
aria-label={`${theme?.label || "开始"}${item.text}`}
disabled={!hydrated || Boolean(pendingSessionId) || cancellationPending || !account || !modelCatalog}
onClick={() => chooseSuggestedQuestion(item.text, item.theme)}
disabled={productEntrypointsDisabled}
onClick={() => void startSuggestedConsultation(item.text, item.theme)}
>
<span className="starter-content">
<b>{theme?.label || "开始"}</b>