导出面板:去掉「已让陶泥儿…」这类复述,状态行只说事实
- 一键适配、帮我填不再铺一句「已让陶泥儿帮你调通导出 / 来填这三项」:这两个动作就是用户刚点的那颗按钮,右侧会话就摆在旁边,复述只是噪音; - 打包现算发现没有脚本时,只把适配弹窗重新武装起来,状态行不再重复「项目还没配置好导出…」; - 失败修复的回执只留出错原因,去掉「已让陶泥儿来修。」这句叙述(失败卡片收掉后,原因仍是唯一说明「刚才为什么开这一轮」的地方); - `notice` 的语义写进注释:读不到内容、打包结果、指令没发出去、失败修复的原因;用户刚点的动作不回执; - 用例跟着改:没脚本时 `notice` 为空。
This commit is contained in:
+12
-23
@@ -89,6 +89,8 @@ export function useXhsMinitoolExport({
|
||||
const [fieldError, setFieldError] = useState<FormInvalid | null>(null);
|
||||
const [conflict, setConflict] = useState<SaveConflict | null>(null);
|
||||
const [failure, setFailure] = useState<XhsMinitoolCardFailure | null>(null);
|
||||
// 界面上「有事要说」的那一句:读不到内容、打包结果、指令没发出去、失败修复的原因。
|
||||
// 用户刚点的动作本身不回执——「已交给陶泥儿」这类复述是噪音。
|
||||
const [notice, setNotice] = useState('');
|
||||
const [loading, setLoading] = useState(false);
|
||||
/**
|
||||
@@ -199,8 +201,8 @@ export function useXhsMinitoolExport({
|
||||
setFieldError(null);
|
||||
setConflict(null);
|
||||
setFailure(null);
|
||||
// 只撤掉「读不到」那一句:适配 / 打包的回执也是 `notice`,读到内容不等于用户读过了它,
|
||||
// 每 2 秒重读一次就把回执擦掉会让回执根本来不及被看见。
|
||||
// 只撤掉「读不到」那一句:打包结果、失败修复的原因也是 `notice`,读到内容不等于用户读过了它,
|
||||
// 每 2 秒重读一次就把它们擦掉会让这些话根本来不及被看见。
|
||||
setNotice((previous) =>
|
||||
previous === CONTENT_UNAVAILABLE_NOTICE ? '' : previous,
|
||||
);
|
||||
@@ -392,12 +394,8 @@ export function useXhsMinitoolExport({
|
||||
try {
|
||||
const hasScriptNow = await refresh();
|
||||
if (hasScriptNow !== true) {
|
||||
// 弹窗重新武装起来就是给用户的交代,状态行不再复述一遍。
|
||||
setAdaptPromptDismissed(false);
|
||||
if (hasScriptNow === false) {
|
||||
setNotice(
|
||||
'项目还没配置好导出,先让陶泥儿帮你调通,之后就能直接打包了',
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
// 先 flush 自动保存:用户刚敲完就点打包时,注册表里可能还是上一份。
|
||||
@@ -425,12 +423,12 @@ export function useXhsMinitoolExport({
|
||||
/**
|
||||
* 把一条指令当用户消息发给项目会话。
|
||||
*
|
||||
* `sentNotice` 由调用方按「首次适配 / 失败修复」分别给:两条路径给 agent 的指令不同,给用户的
|
||||
* 回执也不该长一个样——失败修复那条必须把这次的失败原因复述出来,否则失败卡片收掉之后用户只剩
|
||||
* 一句「已交给 agent」。
|
||||
* 成功不回执:这几个动作都是用户刚点的那颗按钮,面板再复述一句「已交给陶泥儿」只是噪音。
|
||||
* 留在界面上的只有两种话——发不出去时的实话,和失败修复必须留下的出错原因(失败卡片收掉之后,
|
||||
* 那是唯一还写着「刚才为什么开这一轮」的地方)。
|
||||
*/
|
||||
const sendToAgent = useCallback(
|
||||
async (instruction: string, sentNotice: string): Promise<void> => {
|
||||
async (instruction: string, sentNotice = ''): Promise<void> => {
|
||||
const handedOver = await submitTurn([
|
||||
{ type: 'input_text', text: instruction },
|
||||
]);
|
||||
@@ -460,20 +458,14 @@ export function useXhsMinitoolExport({
|
||||
if (dirty && !conflict && !fieldError) {
|
||||
await persist(form, baselineRef.current);
|
||||
}
|
||||
await sendToAgent(
|
||||
buildXhsMinitoolFormFillInstruction(),
|
||||
'已让陶泥儿来填这三项,它改完会自动出现在上面',
|
||||
);
|
||||
await sendToAgent(buildXhsMinitoolFormFillInstruction());
|
||||
}, [projectPath, form, dirty, conflict, fieldError, persist, sendToAgent]);
|
||||
|
||||
/** 一键适配(bootstrap):把首次适配指令发给同一个项目会话。发出即收起阻断提示,别让弹窗再拦住用户。 */
|
||||
const adapt = useCallback((): void => {
|
||||
if (!projectPath) return;
|
||||
setAdaptPromptDismissed(true);
|
||||
void sendToAgent(
|
||||
buildXhsMinitoolAdaptationInstruction(),
|
||||
'已让陶泥儿帮你调通导出,右侧会话里能看到它的进展',
|
||||
);
|
||||
void sendToAgent(buildXhsMinitoolAdaptationInstruction());
|
||||
}, [projectPath, sendToAgent]);
|
||||
|
||||
/**
|
||||
@@ -496,10 +488,7 @@ export function useXhsMinitoolExport({
|
||||
// 回执复述用户侧的说法;给 agent 的指令直接带原始错误,两者互不派生。
|
||||
const reason = describeXhsMinitoolFailure(failure);
|
||||
setFailure(null);
|
||||
void sendToAgent(
|
||||
buildXhsMinitoolErrorFixInstruction(failure),
|
||||
`已让陶泥儿来修。\n出错原因:${reason}`,
|
||||
);
|
||||
void sendToAgent(buildXhsMinitoolErrorFixInstruction(failure), reason);
|
||||
}, [projectPath, failure, sendToAgent]);
|
||||
|
||||
/**
|
||||
|
||||
@@ -885,10 +885,9 @@ describe('状态 hook', () => {
|
||||
expect(calls).toContain('read_xhs_minitool_export');
|
||||
expect(calls).not.toContain('run_xhs_minitool_export_build');
|
||||
// 还没有脚本就把「让陶泥儿帮你调通」重新递出来,而不是报个错把人晾在原地。
|
||||
// 这一路只重新武装弹窗,状态行不再复述一遍。
|
||||
expect(result.current.adaptPromptDismissed).toBe(false);
|
||||
expect(result.current.notice).toBe(
|
||||
'项目还没配置好导出,先让陶泥儿帮你调通,之后就能直接打包了',
|
||||
);
|
||||
expect(result.current.notice).toBe('');
|
||||
expect(result.current.running).toBe(false);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user