Repository navigation
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 492daff040
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const editorRetained = useSurfaceRetention( | ||
| 'editor', | ||
| () => `${props.params.api.id}:${renderUrl.value}`, | ||
| visible, | ||
| ) |
There was a problem hiding this comment.
Initialize renderUrl before registering surface retention
Opening an attachment tab now calls useSurfaceRetention() before renderUrl is initialized. That composable immediately registers a key watcher, which evaluates this getter even without immediate, so setup throws ReferenceError: Cannot access 'renderUrl' before initialization. This prevents both text and image attachment previews, including their Download UI, from mounting. Move the renderUrl computed declaration above this registration.
Useful? React with 👍 / 👎.
| const latestKnownRevision = inCompare | ||
| ? ((compareStale.value ? observedDiskRevision : compareDiskRevision.value) || baseRevision.value) | ||
| : (observedDiskRevision || baseRevision.value) | ||
| const omitContent = isDirty.value || (inCompare && Boolean(compareDiskRevision.value)) |
There was a problem hiding this comment.
Keep metadata-only poll results out of the content-apply path
If a dirty editor starts a poll and the user undoes their edits before a changed-disk response arrives, omitContent remains true but resolvePolledTextChange() reevaluates isDirty as false and returns apply. The response intentionally contains empty content, so applyPolledTextContent() replaces both buffers with an empty string and advances baseRevision; subsequent polls report unchanged and leave the editor falsely clean and blank. Preserve the omission information through completion and fetch the actual content before taking the apply branch.
Useful? React with 👍 / 👎.
| promise: Promise<{ data: HandlersFsReadResponse }> | ||
| } | ||
|
|
||
| const inFlightReads = new Map<string, InFlightReadEntry>() |
There was a problem hiding this comment.
Use Pinia Colada for the new filesystem request coordinator
The new module-global map and subscriber/abort bookkeeping introduce an independent request lifecycle for a normal REST read. This violates root AGENTS.md's “state uses Pinia + Pinia Colada” requirement and frontend M3, required by apps/web/AGENTS.md, which assigns server-data caching, loading, retries and invalidation to Colada. The generated getBotsByBotIdContainerFsReadQuery and key factory already exist in packages/sdk/src/@pinia/colada.gen.ts; implement conditional-read coordination through a shared Colada query/composable instead of adding another coordinator outside the existing query reset and invalidation mechanisms.
AGENTS.md reference: AGENTS.md:L192-L193
Useful? React with 👍 / 👎.
| const sig = `${name}|${surfaceHex}` | ||
| if (definedMonacoThemeSignatures.has(sig)) return false | ||
| definedMonacoThemeSignatures.add(sig) |
There was a problem hiding this comment.
Track the currently registered surface per Monaco theme name
When appearance changes produce surfaces A → B → A while retaining the same Shiki theme name, defineTheme(name, ...) overwrites the same Monaco registration first with A and then B. This set remembers both historical signatures, so returning to A makes this function return false and syncEditorTheme() skips restoring A's definition. The minimap therefore retains B's background rather than matching the current editor surface. Track the last registered surface per theme name, or register each signature under a distinct Monaco theme name.
Useful? React with 👍 / 👎.
1ba7550 to
9e9b2d7
Compare
9e9b2d7 to
9a6e492
Compare
- 文件查看器不再自行读取正文,加载、轮询、保存后同步与 Compare 都走共享查询, 磁盘状态由一处对账函数决定 - 文档预览的下载与渲染改由面板可见性驱动,不再依赖 KeepAlive 钩子 - Bot 详情页的两个编辑器对话框与附件面板按需加载 Monaco - 懒加载占位不再嵌套面板框;只有未保存修改会让隐藏的编辑器常驻 - 合并重复的文件指纹与 404 判断,修正过期注释
读取完成后先清 loading、隔一个微任务才写入内容,中间的一次渲染会用空缓冲 创建编辑器;编辑器异步创建期间到达的内容又被 model-value 监听跳过。 现在读取结果在同一同步步骤内应用,编辑器创建完成后也会补上期间变化的内容。
没有量出收益,而它在文件查看器里多出一组挂载条件与视图状态的保存恢复。 已打开过的文件编辑器在面板隐藏时保持挂载,与 main 上 KeepAlive 的行为一致。
9a6e492 to
73331e2
Compare
- 读取完成后清除此前失败的元数据检查状态,「重试」可立即恢复; 重新载入的意图保留到读取被应用或读取本身失败 - 同步后的首次元数据检查发现文件大小不同即读取,不再等下一轮 - 外部改动被还原到编辑器基线后收起冲突提示并放行保存 - Bot 设置页弹窗内的编辑器补上加载与失败占位
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 88b6aec14e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (recovered || revertedToBase) { | ||
| diskState.value = 'available' | ||
| observedExternalRevision.value = '' | ||
| if (revertedToBase) lastLoadedAt.value = Date.now() |
There was a problem hiding this comment.
Advance the save watermark after successful unchanged reads
When a same-bot exec emits a wildcard filesystem beacon while this file is visible and clean, but its contents are unchanged, loadTextContent() successfully refetches the same revision and reaches this branch without advancing lastLoadedAt. After the user edits the file, handleSave() still sees fsChangedAt > lastLoadedAt and refuses to POST, reporting a conflict that the successful read already ruled out. The previous explicit-load path updated this timestamp even for unchanged content. Refresh the verification watermark after a successful same-revision read without replacing the user's buffer.
Useful? React with 👍 / 👎.
| if (modTimeMs < lastSync.wallAt - FINGERPRINT_SETTLE_MS - CLOCK_SKEW_TOLERANCE_MS) { | ||
| lockedFingerprint = fingerprint | ||
| contentFresh = false | ||
| return 'skip' |
There was a problem hiding this comment.
Read changed fingerprints before applying the clock shortcut
If the workspace clock is two minutes behind the browser, a same-size external write can produce a different fingerprint whose modTime still satisfies this condition. The tracker then locks that new fingerprint without reading its content; subsequent observations return through the earlier locked-fingerprint check, so neither the editor nor preview receives the change, even after the settling period. Replacing a file with a preserved older modification time has the same problem. A changed fingerprint must not be considered synchronized solely because its size matches and its timestamp looks old relative to the browser clock.
Useful? React with 👍 / 👎.
| } | ||
|
|
||
| watch( | ||
| [() => textQuery.data.value, () => textQuery.error.value, textQuery.pollError, () => props.botId, filePath] as const, |
There was a problem hiding this comment.
Reconcile the disk snapshot when the draft becomes clean
If an external revision arrives while the editor is dirty, let its fingerprint settle and then undo the local edits back to originalContent. The editor becomes clean, but this watcher does not observe that transition and the separate isDirty watcher only emits the dirty flag. Subsequent polls skip the unchanged fingerprint, so nothing reapplies the already-fetched newer disk snapshot: the tab remains marked clean while displaying old content and a conflict chip until another disk change or manual reload. Trigger reconciliation on the dirty-to-clean transition, retaining the existing load/save guards.
Useful? React with 👍 / 👎.
Author
Type
Summary
右侧工作区(文件编辑器、预览、终端)原先有三处固定开销:打开的文本文件每 2 秒完整读取一次正文,编辑器与预览并排时各读一次;进入聊天页即加载 Monaco 与 xterm,即使没有打开任何文件;编辑器每次同步主题都重跑一遍自写的 Shiki → Monaco 主题转换。本 PR 只改前端,不改后端接口、OpenAPI 规范和
@memohai/sdk。改动后的行为:
useContainerTextFileQuery:按 bot + 路径共享一份查询和一个轮询,每 2 秒只调用轻量的GET /bots/{bot_id}/container/fs,文件大小或修改时间变化后才读取正文。编辑器(FileViewer)与预览(PanelPreview)订阅同一份数据,编辑器加载或保存后的内容直接同步给预览。modTime只有秒级精度,因此指纹需保持 1.5 秒不变才视为稳定:一次外部改动会先读一次正文让变化尽快显示,稳定后再读一次确认。该查询键已加入持久化排除名单,不写入localStorage。defineAsyncComponent之后,面板首次可见时才加载;未打开文件时不再下载 Monaco 与 xterm。shiki/themes的引用,新增minimap-theme.ts,在主题注册时并入--surface-editor,语言增量加载重新注册主题后底色不再丢失。文件树节点与面包屑从设置 store 读取明暗状态,不再各自监听 DOM。未改变的行为:未保存修改、冲突提示、对比、重新加载、仍要保存的语义与入口不变;后台标签里的编辑器仍全部保持挂载(曾尝试的后台编辑器回收已在本 PR 内撤掉,收益无法测量,且会清空干净文件的撤销历史)。
已知限制:变更检测依赖
modTime,同一秒内且大小不变的外部写入会晚一个稳定期(约 1.5 秒)才被发现。保存冲突保护使用内容 revision,不受影响。文件树的目录轮询次数没有减少,仍为每分钟约 60 次。实测对比
基线为
main的ff8e7bca4,两边均为vite build+vite preview,同一个 bot、同一批文件。内存与脚本体积在撤掉后台编辑器回收之前测得,之后未重测。代码量
相对
main共 35 个文件,+1656 / −731。无生成物与机械性变更。净增主要来自三个新文件:共享文本文件查询(319 行,其中约三分之一是说明并发与时钟前提的注释)、Minimap 底色同步(98 行)、面板加载占位(73 行,由原
panel-loading.vue拆出)。需要重点 review 的行为:
use-container-text-file.ts中的稳定期判定与syncEpoch:决定何时读正文,以及在途读取不得覆盖刚保存的内容。file-viewer.vue的加载与轮询流程改为订阅共享查询,冲突状态机的入口随之调整;其中reconcileText/applyDiskSnapshot决定共享状态对编辑器意味着什么,两轮修复都落在这里。monaco-editor/index.vue创建完成后的内容核对。Related Issues
Validation
以下均为 Agent 执行的自动检查与浏览器自测,未经过人工 QA。
自动检查(head
88b6aec14):pnpm typecheck(apps/web)通过。eslint对改动文件 0 error;2 个 warning 位于panel-preview.test.ts,属既有的单文件多组件规则。node scripts/check-ui-contract.mjs通过。vitest相关 39 个测试文件、343 个用例中 341 个通过;失败的 2 个在未改动的use-session-follow-up-queue.test.ts,属本机环境问题,以 CI 结果为准。首次打开的回归用例,以及审查修正对应的 4 个用例(3 个新增、1 个既有断言随行为更新),均已确认在修复前的代码上失败。vitest:在本机更大范围运行时有 6 个文件 14 个用例失败(缺少document/sessionStorage、i18n 未加载),均不在改动范围内,未在基线上逐一对照,以 CI 结果为准。浏览器自测(宿主机 Vite
http://127.0.0.1:8083,指向本地 OSS 后端,用测试 bot 的工作区文件):88b6aec14上重测)。第 1–13 项在
73331e216上执行;88b6aec14的四处修正由单元测试覆盖,未在浏览器中逐一重放。未覆盖:弹窗内编辑器的加载与失败占位(本机加载过快未出现)、Bot 设置页「网络」里的编辑器对话框、多个文件标签并存、DOCX 预览、Agent 在对话中写文件触发的刷新、Electron 桌面端、浏览器控制台报错检查。
Screenshots / Recordings
Human QA