顶部帮助菜单里的“问题上报”当前只打开通用“提交反馈”弹窗,不会自动带上用户当时看到的任务现场。任务右键反馈、Header 更多菜单里的任务反馈、远程连接失败反馈已经通过 IPlatformService.captureWindowScreenshot() 截取当前 Electron 窗口,并把结果作为 FeedbackSubmitDraft.screenshots 传给反馈表单。
本需求要求用户点击帮助菜单里的“问题上报”后,自动把当前窗口任务截图放入“提交反馈”弹窗的截图区域。
FeedbackScreenshotPicker。packages/shared/src/platform.ts 已定义 captureWindowScreenshot?(): Promise<WindowScreenshotResult | null>,注释明确 Web fallback 可返回 null。packages/desktop/src/main/desktopMainIpcPlatform.ts 已通过 BrowserWindow.fromWebContents(event.sender).webContents.capturePage() 截取当前窗口。packages/desktop/src/preload/index.ts 和 packages/desktop/src/renderer/src/main.tsx 已把 captureWindowScreenshot 暴露给 UI 平台服务。packages/ui/src/WorkspaceHelpMenuButton.tsx 是截图中帮助菜单入口所在组件,当前 handleOpenIssueReport 只调用 openFeedbackSubmit(...)。packages/ui/src/feedback/FeedbackSubmitForm.tsx 已支持从 initialDraft.screenshots 初始化截图区域。WorkspaceHelpMenuButton 的“问题上报”菜单项改为异步处理:
platform.captureWindowScreenshot?.()。FeedbackAttachmentDraft[];无能力、返回 null 或抛错时返回空数组。openFeedbackSubmit({ type: "bug", module: "其它", severity: "P2-中", includeLogs: true, screenshots })。截图调用发生在 openFeedbackSubmit 之前,因此 Electron 截到的是当前任务窗口,不包含反馈弹窗自身。
新增一个小型 UI helper,例如 packages/ui/src/feedback/feedbackScreenshotDraft.ts:
import type { IPlatformService } from "@zcode/shared";
import type { FeedbackAttachmentDraft } from "@/feedback/feedbackStore.js";
export async function captureFeedbackScreenshotDraft(
platform: Pick<IPlatformService, "captureWindowScreenshot">,
): Promise<FeedbackAttachmentDraft[]> {
const screenshot = await platform.captureWindowScreenshot?.().catch(() => null);
return screenshot ? [screenshot] : [];
}
这个 helper 只处理 UI draft 组装,不做日志、不弹 toast、不重试。截图失败通常不是用户提交反馈的主流程错误,静默降级可以保证反馈弹窗仍然打开。
captureWindowScreenshot 可不存在或返回 null,反馈弹窗仍打开。captureFeedbackScreenshotDraft 添加单元测试:
FeedbackAttachmentDraft 的数组。captureWindowScreenshot 返回 null 时返回空数组。captureWindowScreenshot 抛错时返回空数组。WorkspaceHelpMenuButton 添加或更新组件测试:
openSubmit,draft 中包含截图。openSubmit,draft 中 screenshots 为空数组。pnpm typecheckpnpm lint