From 288d3aca07a3f5284dfa5b500226ee6f7c07dd48 Mon Sep 17 00:00:00 2001 From: weichen Date: Thu, 1 Oct 2026 04:47:02 +0000 Subject: [PATCH] Create a default project when the first task has none MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Why: On an empty workspace the primary button and the empty state both say to start by creating a task, but the action only toasted that a project was required. Evidence: A fresh embedded instance returns an empty project list, so the first click never opened a conversation. Impact: The first task now creates 「默认项目」 and opens it. Existing projects are unchanged. Refs: walkthrough of the empty workspace on main Co-authored-by: Cursor --- src/store.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/store.ts b/src/store.ts index ecb04a5..f56e2f8 100644 --- a/src/store.ts +++ b/src/store.ts @@ -186,10 +186,16 @@ export const store = { await store.refreshArtifacts(projectId) }, - /** 新建任务(=会话):默认当前项目上下文;显式 projectId 用于"新建于指定项目"。 */ + /** 新建任务(=会话):默认当前项目上下文;显式 projectId 用于"新建于指定项目"。 + * 空库时主按钮与空状态都写着「点击新建任务开始」,这里先落一个默认项目再开会话。 */ async createTask(projectId?: string) { - const pid = projectId ?? state.currentProjectId - if (!pid) { store.toast('请先创建项目'); return } + let pid = projectId ?? state.currentProjectId + if (!pid && state.projects.length > 0) pid = state.projects[0].id + if (!pid) { + const p = await store.createProject('默认项目') + pid = p.id + } + if (pid !== state.currentProjectId) await store.openProject(pid) const c = await api.createConversation(pid) await store.refreshTasks() await store.openTask(c.id)