Create a default project when the first task has none
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 <cursoragent@cursor.com>
This commit is contained in:
+9
-3
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user