diff --git a/.project-docs/30-worklog/tasks/20260930-preview-toolbar-tabs-56e98b2d.md b/.project-docs/30-worklog/tasks/20260930-preview-toolbar-tabs-56e98b2d.md new file mode 100644 index 00000000..7b240d43 --- /dev/null +++ b/.project-docs/30-worklog/tasks/20260930-preview-toolbar-tabs-56e98b2d.md @@ -0,0 +1,54 @@ +# Task: Move work preview address toolbar beside workspace tabs + +## Identity + +- Task ID: 20260930-preview-toolbar-tabs-56e98b2d +- Mode: Feature +- Branch: codex/20260930-preview-toolbar-tabs-56e98b2d-preview-toolbar-tabs +- Worktree: /Users/chillishark/Makelore 麦洛/.codex-worktrees/makelore/20260930-preview-toolbar-tabs-56e98b2d +- Base commit: c55e9c718201eb8986a83e545e9b3ad7b110dd7e +- Owner: codex +- Status: Ready for Integration + +## Scope + +- Move the entire embedded work-preview address toolbar (back, forward, reload and editable URL) beside the Operation Chat / Work tabs, as explicitly confirmed by the user. + +## Intent And Constraints + +- Keep the current navigation, browser/view lifecycle, URL editing, empty-work behavior, native viewport bounds, teacher clearance and student drafts. Show the toolbar only in the Work tab; retain standalone developer-browser layout. Use existing visual styles, fitting one row when space permits and wrapping cleanly on narrow panes. No live-app update, main merge or push is requested in this turn. + +## Outcome + +- Embedded work previews render their existing navigation form through a portal into a stable slot beside the two workspace tabs. The form remains outside the tablist, retains existing handlers and address focus protection, and disappears when the Work tab is hidden. The old internal toolbar row is removed only when the external slot is available; standalone/fallback browsers remain unchanged. Responsive layout keeps all controls usable and wraps the address toolbar only when the pane is too narrow. README documents the new position. + +## Verification + +- Standard typecheck, production build and scoped ESLint passed. All 59 relevant unit tests passed: 42 coding-chat-panel/use-work-preview tests and 17 agent-browser-panel tests, including external-toolbar navigation, inline fallback and hide/reopen behavior. +- All 17 browser layout scenarios were verified (14 passed in the full run; the final 3 passed after replacing obsolete internal-toolbar spacing assumptions with native viewport clearance assertions). Screenshots verified 375px wrapping, 768/1180px alignment and the expanded teacher pane. The fixture now includes a standards-mode doctype and production tab icons. Native pixels keep 8–10px below overlapping teacher speech, reclaim space for shorter messages, and restore the original 20px content padding when speech is dismissed or no longer overlaps. +- The updated isolated Electron work-tab scenario passed: the complete toolbar shares the tab row, address arrow keys stay in the input, refresh reaches the existing navigation endpoint, keyboard tab switches preserve the draft, and the toolbar returns without duplicate controls. Test-only changes to generated Main were restored byte-for-byte; no running user app or data was changed. +- Independent static review found no blocking lifecycle, focus, native bounds, tab semantics or teacher-clearance issues. Root reviewed the product/test diff and browser/Electron screenshots. Logs: `/tmp/preview-toolbar-tabs-final-typecheck.log`, `/tmp/preview-toolbar-tabs-final-lint.log`, `/tmp/preview-toolbar-tabs-build.log`, `/tmp/preview-toolbar-tabs-regression.log`, `/tmp/preview-toolbar-tabs-browser-full-56e98b2d.log`, `/tmp/preview-toolbar-tabs-clearance-56e98b2d.log`, `/tmp/preview-toolbar-tabs-electron-56e98b2d.log`. + +## Follow-ups + +- None recorded. + +## Promotion Candidates + +- None recorded. + +## Project Context Loaded + +- Task: 20260930-preview-toolbar-tabs-56e98b2d; feature mode; branch/worktree/base as Identity. Official start/status confirms ownership/reservation. App create_worktree is unavailable at this parent-directory chat root (Not a git repository); official skill isolation succeeded from primary main `c55e9c7`. +- Read AGENTS, entry/memory index, task record and planning gate. Positioning, current-state, decision index, architecture and teacher ADR remain byte-identical to the previously loaded `7bce156` snapshot; domain, success criteria and evidence/reflection/commitment context remains applicable. README and actual source govern current presentation. +- Project supports student creation through Main-owned project conversations and a shared Agent/browser work preview. This is a Renderer layout change, without API/model/data changes. +- Read all 26 peer task Scope/Intent/Promotion sections. New teacher-reference-isolation peer protects selected source text/teacher handoff; leave those handlers intact. Empty-work peer requires local empty detection before conversation/model launch. No semantic conflict. Old unspecified child-language task is unrelated. +- Browser ownership remains Main/project/generation-scoped. Tabs hide the existing view without destroying or navigating it; native viewport bounds and teacher-overlay clearance must remain correct. Standalone browser and diagnostics retain current behavior. +- Files: AgentBrowserPanel, CodingChatPanel, classroom-workspace.css, focused browser/navigation tests and README. React portal can reuse the existing toolbar state/handlers in an external sibling slot outside the semantic tablist, avoiding duplicate controls or a second browser owner. +- Gate: Passed. + +## Plan + +1. Add an optional embedded-toolbar target and a sibling slot on the tabs row; keep the existing form/navigation handlers and standalone fallback. +2. Scope styles to the workspace row, keep tab/button semantics separate, and prevent overflow in narrow panes. +3. Verify navigation/disabled states/tab lifecycle, real layout/native viewport behavior, relevant regressions, typecheck/lint/build; record and commit the isolated result. diff --git a/README.md b/README.md index 1ca2f79d..b6acd5d6 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Code 会话保存的模型被下架后,会提示重新选择可用模型;用 Makelore 是一个面向软件、视觉创作、智能机器人与个人云智能体的 AI 桌面工作台。当前版本为 `2.0.0`,源码提供四个模块入口;云智能体需配套配置 WS/Yuxi 服务。模块入口页按 Agents、Code、Canvas、Robot 排列,统一采用横向插画卡片;Agents 标语为“打造你想象中的AI助手”。工作区左上角入口点击后返回模块入口页: - `Makelore Code|AI 编程`:管理本地项目、项目智能体、对话、文件上下文、代码变更和运行时。 - 会话工作台采用浅蓝项目栏、彩色通用手柄图标与卡片选中态;中间对话/作品使用圆角标签,右侧智能体咨询使用奶油色标题区。沿用真实项目和会话入口、侧栏伸缩与账户菜单,样式只作用于 Code 会话工作台。可编辑的空对话在输入区上方的可用区域中央显示童趣欢迎语;「去作品广场逛逛」入口紧贴输入框上方,两者一起位于底部。老师介绍以固定宽度浮在右上角,不占用中间布局;欢迎语和底部输入区始终相对项目栏右侧的整个内容区域居中;小窗口的欢迎内容独立滚动;发送首条消息后收起欢迎区。侧栏保留「作品广场」入口,只有点击后才在系统浏览器打开公共广场,不请求、摘取或内嵌展示广场作品。打开广场保留当前项目、对话、草稿和附件,不自动发送消息;老师求助按钮保留临时应用的最新文案「帮我整体看🧠」。 + 会话工作台采用浅蓝项目栏、彩色通用手柄图标与卡片选中态;中间对话/作品使用圆角标签,作品预览的后退、前进、刷新与网址输入统一放在标签右侧;只在作品页显示,窄窗口自动换行。右侧智能体咨询使用奶油色标题区。沿用真实项目和会话入口、侧栏伸缩与账户菜单,样式只作用于 Code 会话工作台。可编辑的空对话在输入区上方的可用区域中央显示童趣欢迎语;「去作品广场逛逛」入口紧贴输入框上方,两者一起位于底部。老师介绍以固定宽度浮在右上角,不占用中间布局;欢迎语和底部输入区始终相对项目栏右侧的整个内容区域居中;小窗口的欢迎内容独立滚动;发送首条消息后收起欢迎区。侧栏保留「作品广场」入口,只有点击后才在系统浏览器打开公共广场,不请求、摘取或内嵌展示广场作品。打开广场保留当前项目、对话、草稿和附件,不自动发送消息;老师求助按钮保留临时应用的最新文案「帮我整体看🧠」。 - `Makelore Agents|AI 智能体`:配置个人云智能体并试聊,发布后正式对话、接入个人微信或创建应用 API Key。支持流式回复、审批、排队请求、附件与产物、自动任务和活动历史;重新进入时恢复最近智能体与对话,未确认操作可按原输入重试。聊天可提出日程建议,由创建者核对能力、时间和费用后启用。知识库上传、替换及导入本人会话附件后自动解析并建立索引;文档卡片区分排队、解析、索引、可用和失败,持续刷新已加载文档,失败可原地重试;零文本内容不会显示为可用,新文档可用后才移除被替换的旧文档。支持删除知识内容;个人 MCP 凭据、Skills、子智能体可自助管理。支持智能体和会话归档、发布版本比较及恢复为草稿。除知识库 embedding 向量化外,模型调用(包括知识处理触发的对话模型调用)仍按原规则由创建者个人词元点数支付,可按智能体设置每次任务和每日上限,费用按时间、来源、应用分页统计;embedding 向量化由平台承担,不计入用户用量、词元点数或智能体费用上限;应用调用者保有自己的内容空间。Main 管理云会话和本机文件,Renderer 通过 Host API 操作。配套服务接入见 [Yuxi MakeLore 说明](https://xerrors.github.io/Yuxi/advanced/makelore-agents.html)。 编辑采用全高桌面分栏,支持拖动调整与展开、独立滚动、小窗口配置/试用切换。首次创建按选用途、说要求、试一试引导,提供科学问答、故事、英语和笔记整理起点;回答方式可多选,特别要求直接编辑,仍以草稿的 system_prompt 保存。新助手预选云端目录的第一个可用模型并明确显示,可自行更换;已有助手不自动换模型。编辑区以“我的要求”和“高级设置”两个 Tab 切换,默认显示基础要求;高级设置包含能力、知识与限制,返回时保留上次分类,切换保留未保存的输入及当前试用。已开始使用的助手在顶部显示“修改已保存,尚未应用”或“已应用最新修改”,并提供显眼的“应用最新修改”按钮;保存只更新草稿,应用沿用同一发布操作,失败重试保留原操作身份。草稿明确保存(Ctrl/⌘+S),保存与切换页面保留当前试用及未发送文字;“保存并重新试用”使用最新保存的要求,保留上次试用供对比,并可复用上次问题,不自动发送。示例问题仅填入输入框;有运行、排队、审批或未确认操作时先处理当前试用。工具确认先展示实际操作说明与参数,完整技术详情可展开。确认“开始使用”会创建仅自己可用的发布版本并进入独立对话,微信渠道与应用接入仍单独配置。费用上限在限制中独立保存。Enter 发送、Shift+Enter 换行,F6 切换面板焦点、Esc 恢复分栏。 云知识库的 embedding 模型只由平台管理员在 Yuxi 后台维护:在「智能体管理 → 模型供应商」启用供应商,按供应商要求填写有效的服务地址和 API Key,添加并启用 embedding 模型并填写实际向量维度;embedding 向量化费用由平台承担,不计入用户用量、词元点数或智能体费用上限;one-api 不参与 embedding 配置,Works Square 只负责其他应计费模型调用的创建者词元点数账本。客户端区分目录加载中、加载失败与无可用模型,空状态提供管理员配置说明;「刷新知识库与模型」保留未提交名称,未确认的创建请求沿用原操作身份。 diff --git a/src/pages/Chat/AgentBrowserPanel.tsx b/src/pages/Chat/AgentBrowserPanel.tsx index 86fcd0c3..f2384c77 100644 --- a/src/pages/Chat/AgentBrowserPanel.tsx +++ b/src/pages/Chat/AgentBrowserPanel.tsx @@ -6,6 +6,7 @@ import { useState, type FormEvent, } from 'react'; +import { createPortal } from 'react-dom'; import { ArrowLeft, ArrowRight, @@ -46,6 +47,7 @@ export interface AgentBrowserPanelProps { open: boolean; onOpenChange(open: boolean): void; embedded?: boolean; + toolbarContainer?: HTMLElement | null; teacherBubble?: HTMLElement | null; teacherIntroduction?: HTMLElement | null; conversationId?: string | null; @@ -133,6 +135,7 @@ export function AgentBrowserPanel({ open, onOpenChange, embedded = false, + toolbarContainer, teacherBubble, teacherIntroduction, conversationId, @@ -482,6 +485,37 @@ export function AgentBrowserPanel({ if (!open) return null; + const toolbar = ( +
+ + + + setAddress(event.target.value)} + aria-label="网页地址" + className="h-7 min-w-0 flex-1 rounded-lg border border-border/90 bg-surface-input px-2.5 text-[11px] font-medium outline-none focus:border-brand/40 focus:ring-2 focus:ring-brand/15" + placeholder={embedded ? '作品打开后会显示地址' : '输入 URL'} + spellCheck={false} + /> +
+ ); + return (