Skip to content
This repository was archived by the owner on Feb 18, 2025. It is now read-only.

Commit a651674

Browse files
committed
WIP: add handler for command
1 parent 85f6a74 commit a651674

3 files changed

Lines changed: 35 additions & 9 deletions

File tree

crates/cursor-core/src/project/mod.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ enum Task {
2424
Append(String),
2525
}
2626

27+
impl Task {
28+
fn title(&self) -> &str {
29+
match self {
30+
Task::Step(title) => title,
31+
Task::Create(title) => title,
32+
Task::Append(title) => title,
33+
}
34+
}
35+
}
36+
2737
#[wasm_bindgen(js_name = generateProject)]
2838
pub async fn generate_project(prompt: &str) -> Result<JsValue, JsValue> {
2939
let prompt = prompt.to_owned();
@@ -67,9 +77,16 @@ pub async fn generate_project(prompt: &str) -> Result<JsValue, JsValue> {
6777

6878
// The message sent by the report will automatically disappear after a short period of time.
6979
// In order to keep the text displayed on the dialog box, report the title every time data is returned.
80+
if current_task.is_some() {
81+
progress.report(current_task.as_ref().unwrap().title());
82+
continue;
83+
}
7084
match &current_task {
71-
Some(Task::Step(title) | Task::Create(title) | Task::Append(title)) => {
72-
progress.report(&title);
85+
Some(Task::Create(_)) => {
86+
todo!()
87+
}
88+
Some(Task::Append(_)) => {
89+
todo!()
7390
}
7491
_ => {}
7592
}

src/extension/index.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,9 @@ import { GenerateSession, getScratchpadManager } from "./generate";
55
import { getGlobalState } from "./globalState";
66
import { ChatPanelProvider } from "./chat/chatPanelProvider";
77
import { sharedChatServiceImpl } from "./chat/chatServiceImpl";
8-
import {
9-
generateProject,
10-
setExtensionContext,
11-
signIn,
12-
signOut,
13-
} from "@crates/cursor-core";
8+
import { setExtensionContext, signIn, signOut } from "@crates/cursor-core";
149
import { ExtensionContext } from "./context";
10+
import { handleGenerateProjectCommand } from "./project";
1511

1612
function setHasActiveGenerateSessionContext(value: boolean) {
1713
vscode.commands.executeCommand(
@@ -95,7 +91,7 @@ export function activate(context: vscode.ExtensionContext) {
9591
);
9692
}),
9793
vscode.commands.registerCommand("aicursor.generateProject", () => {
98-
generateProject("a new Unity project");
94+
handleGenerateProjectCommand();
9995
}),
10096
getScratchpadManager().registerTextDocumentContentProvider(),
10197
vscode.window.registerWebviewViewProvider(

src/extension/project.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import * as vscode from "vscode";
2+
import { generateProject } from "@crates/cursor-core";
3+
4+
export async function handleGenerateProjectCommand() {
5+
const input = await vscode.window.showInputBox({
6+
title: "Generate A New Project",
7+
placeHolder: "Instructions for project to generate...",
8+
});
9+
if (!input) {
10+
return;
11+
}
12+
await generateProject(input);
13+
}

0 commit comments

Comments
 (0)