修复从首页打开已有项目时丢掉首页输入:initialPrompt 不再写死空串,首页草稿文案随打开动作进入首轮与对话历史
This commit is contained in:
@@ -36,6 +36,7 @@ import type {
|
||||
HomeCreationType,
|
||||
HomeDraft,
|
||||
} from '../../view/home';
|
||||
import { richTextToPrompt } from '../../view/home/components/RichInputArea/richTextToPrompt';
|
||||
import { useLauncherHomeDraftStore } from '../../view/home/useHomeDraftStore';
|
||||
import type { LauncherView } from '../../view/layout';
|
||||
import type {
|
||||
@@ -49,6 +50,15 @@ import {
|
||||
} from '../project-summary/projectSummary';
|
||||
import { resolveSessionPreviewOnProjectOpen } from './sessionPreview';
|
||||
|
||||
/** 首页输入框当前的纯文本(Lexical 编辑器状态 -> 文本);没有输入就返回空串。 */
|
||||
function homeDraftPromptText() {
|
||||
try {
|
||||
return richTextToPrompt(useLauncherHomeDraftStore.getState().draft).trim();
|
||||
} catch {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
type UseHomeProjectCreationOptions = {
|
||||
setStatus: Dispatch<SetStateAction<string>>;
|
||||
setLauncherView: Dispatch<SetStateAction<LauncherView>>;
|
||||
@@ -471,6 +481,9 @@ export function useHomeProjectCreation({
|
||||
async function createProjectFromProjectPage(
|
||||
nextProjectPath: string,
|
||||
skipNonEmptyCheck = false,
|
||||
// 首页输入框里已经写好的要求:打开已有项目时不能再丢掉(此前写死空串,
|
||||
// 用户写的内容既不发首轮也不进对话历史)。
|
||||
initialPrompt = '',
|
||||
) {
|
||||
if (projectActionRef.current) {
|
||||
return;
|
||||
@@ -523,7 +536,7 @@ export function useHomeProjectCreation({
|
||||
),
|
||||
creationType: null,
|
||||
startMode: null,
|
||||
initialPrompt: '',
|
||||
initialPrompt,
|
||||
attachments: [],
|
||||
recentRunStatus: null,
|
||||
recentRunStopReason: null,
|
||||
@@ -629,7 +642,7 @@ export function useHomeProjectCreation({
|
||||
),
|
||||
creationType: null,
|
||||
startMode: runtimeMode?.activeRuntime === 'design' ? 'planning' : null,
|
||||
initialPrompt: '',
|
||||
initialPrompt: homeDraftPromptText(),
|
||||
attachments: [],
|
||||
recentRunStatus: directoryStatus.recentRunStatus,
|
||||
recentRunStopReason: directoryStatus.recentRunStopReason,
|
||||
@@ -922,7 +935,11 @@ export function useHomeProjectCreation({
|
||||
setProjectPath(selectedPath);
|
||||
projectActionRef.current = null;
|
||||
setProjectAction(null);
|
||||
await createProjectFromProjectPage(selectedPath);
|
||||
await createProjectFromProjectPage(
|
||||
selectedPath,
|
||||
false,
|
||||
homeDraftPromptText(),
|
||||
);
|
||||
} catch (error) {
|
||||
setStatus(error instanceof Error ? error.message : String(error));
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user