fix(desktop): preserve pasted paths in logs - #3856
Conversation
|
| Filename | Overview |
|---|---|
| apps/desktop/src/renderer/components/new-chat/pastePipeline.ts | 收窄路径识别范围符合修复目标,但新增空白判定错误拒绝带尾分隔符的独立目录路径。 |
| apps/desktop/src/renderer/components/new-chat/ChatInput.tsx | 仅更新粘贴管线说明,与新的混合文本处理语义一致。 |
| apps/desktop/src/renderer/tests/pastePipeline.test.ts | 覆盖了主要日志和混排回归场景,但遗漏单独粘贴带尾分隔符目录的既有支持形态。 |
Prompt To Fix All With AI
### Issue 1
apps/desktop/src/renderer/components/new-chat/pastePipeline.ts:186-189
**尾分隔符破坏目录路径识别**
当用户单独粘贴以 `/` 或 `\` 结尾的工作区目录路径时,`trimPathCandidate` 会剥离尾分隔符并将其留在非空白文本段中,导致 `hasOnlySurroundingWhitespace` 判定失败,最终按普通文本粘贴而无法生成目录引用 chip。
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (1): Last reviewed commit: "fix(desktop): preserve pasted paths in l..." | Re-trigger Greptile
| const hasOnlySurroundingWhitespace = pathSegments.every( | ||
| (seg) => seg.kind === 'path' || (seg.kind === 'text' && seg.text.trim().length === 0), | ||
| ); | ||
| return paths.length === 1 && hasOnlySurroundingWhitespace ? pathSegments : null; |
There was a problem hiding this comment.
当用户单独粘贴以 / 或 \ 结尾的工作区目录路径时,trimPathCandidate 会剥离尾分隔符并将其留在非空白文本段中,导致 hasOnlySurroundingWhitespace 判定失败,最终按普通文本粘贴而无法生成目录引用 chip。
Context Used: 使用和PR描述相同的语言进行评论 (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/desktop/src/renderer/components/new-chat/pastePipeline.ts
Line: 186-189
Comment:
**尾分隔符破坏目录路径识别**
当用户单独粘贴以 `/` 或 `\` 结尾的工作区目录路径时,`trimPathCandidate` 会剥离尾分隔符并将其留在非空白文本段中,导致 `hasOnlySurroundingWhitespace` 判定失败,最终按普通文本粘贴而无法生成目录引用 chip。
**Context Used:** 使用和PR描述相同的语言进行评论 ([source](https://app.greptile.com/review/custom-context?memory=instruction-0))
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.|
这条会改变输入框粘贴路径时要不要自动变成文件引用,属于用户看得见的交互变化。维护者确认门先拦住,等维护者在 PR 上 Approve。需要修改就 Request Changes。讨论 issue:#3860 |
|
@Stella-xixi 👋 这个 PR 还有 1 条 review conversation 没 resolve(apps/desktop/src/renderer/components/new-chat/pastePipeline.ts),auto-review 因此暂时跳过、没法继续审查 / 合并。 如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。 |
|
命中 UI 路径(apps/desktop/src/renderer/components/new-chat/ChatInput.tsx / apps/desktop/src/renderer/components/new-chat/pastePipeline.ts)但 description 未附界面效果证据——建议补充改动后效果:截图/录屏,或改动后界面的 HTML 页面(```html 代码块、.html 附件或在线预览链接),便于确认界面符合 DESIGN.md 设计规范 |
MagicLizi
left a comment
There was a problem hiding this comment.
独立审查未通过(0 P0 / 1 P1)。请按下列路径修改后再推。
P1 apps/desktop/src/renderer/components/new-chat/pastePipeline.ts:186 — 单独粘贴带尾分隔符的工作区目录时,路径识别被「整段仅空白包围」判定误杀。segmentPathCandidates 用 trimPathCandidate 剥掉尾 / 或 \ 后,把剥离物留成非空白 text 段,hasOnlySurroundingWhitespace 失败,整段返回 null,不会进 path chip。Finder / 资源管理器 / shell 补全常见的 dir/、dir\ 会回归成普通粘贴。请把剥掉的尾分隔符当作路径本体,而不是额外正文;cd ${dir}/ 这类混合文本继续 null。补测:POSIX dir/、Windows dir\、首尾空白 + 尾分隔符。
这些问题已在当前 head 的后续 commit 中修复(格式门/安全门已通过),自动 dismiss 旧的 CHANGES_REQUESTED 以解除合并阻塞。
|
@Stella-xixi 👋 这个 PR 现在在等维护者确认,确认之前流程不会合并它 —— 不是卡住了,也不是在等你再改一版(你推的改动流程都读到了,判的就是最新一版代码)。
这条是流程自动发的状态提醒(同一版代码只发一次),不用回复。 |
MagicLizi
left a comment
There was a problem hiding this comment.
独立审查(standard)未通过,P1×1。当前 head 4ce29df 不能合。维护者确认门仍在拦(product),本轮不合并。
- [P1] apps/desktop/src/renderer/components/new-chat/pastePipeline.ts:276 —
segmentPathCandidates用trimPathCandidate剥掉尾分隔符后,按 trimmed 长度推进 cursor,剩下的/或\变成 text 段。新的整段粘贴门要求非 path 段必须是空白,于是单独粘贴工作区内目录路径(.../apps/desktop/)无法升级为引用 chip。请把 trim 掉的尾分隔符算进同一条 path,不要当成散文。验证:整段粘贴workdir/subdir/与C:\Code\app\仍产出 path chip;混有日志/叙述的路径保持原文。
这些问题已在当前 head 的后续 commit 中修复(格式门/安全门已通过),自动 dismiss 旧的 CHANGES_REQUESTED 以解除合并阻塞。
MagicLizi
left a comment
There was a problem hiding this comment.
审查结论:需要修改(P1 × 1)
单独粘贴带尾分隔符的工作区目录时,新的「整段仅空白包围」门会把剥下来的 / 或 \ 当成非空白文本,整段返回 null,目录无法升级成 path chip。这和 PR「单独路径仍引用」的承诺冲突;现有 greptile thread 指向同一处。
P1
apps/desktop/src/renderer/components/new-chat/pastePipeline.ts:276—segmentPathCandidates用trimPathCandidate剥掉尾/或\\后按 trimmed 长度推进 cursor,剥离物变成非空白 text 段;hasOnlySurroundingWhitespace(186–189)失败。复现:…/apps/desktop/→[path, text:'/']→ 门失败;无尾斜杠的同一目录仍成功。请把剥掉的尾分隔符算进同一条 path,不要当散文;cd ${dir}/继续null。补测:POSIXdir/、Windowsdir\\、首尾空白 + 尾分隔符。
这些问题已在当前 head 的后续 commit 中修复(格式门/安全门已通过),自动 dismiss 旧的 CHANGES_REQUESTED 以解除合并阻塞。
MagicLizi
left a comment
There was a problem hiding this comment.
独立审查未通过(P1×1)。greptile 未 resolve 的尾分隔符意见仍成立,未代 resolve。
- apps/desktop/src/renderer/components/new-chat/pastePipeline.ts:186 —
trimPathCandidate会剥掉尾分隔符,但segmentPathCandidates用cursor = m.index + trimmed.length把剥下来的/或\留成非空白 text 段;新闸门hasOnlySurroundingWhitespace因此失败,整段粘贴退回null。契约是「除首尾空白外仅一个工作区绝对路径」仍应升级为引用。现行为:…/apps/desktop→ path 段;…/apps/desktop/、…/apps/desktop//、Windows 尾\→null。单 path 判定应对整段 trim 后再 trimPathCandidate 与唯一 path 段比较,或把仅含[\\/]的残留与空白同等放行,并补 POSIX/Windows 尾分隔符用例。
这些问题已在当前 head 的后续 commit 中修复(格式门/安全门已通过),自动 dismiss 旧的 CHANGES_REQUESTED 以解除合并阻塞。
MagicLizi
left a comment
There was a problem hiding this comment.
独立审查未通过(P1×1)。当前 head 4ce29df4e1d8fa907ff9a2cedfe606c53edcf874 不能合。维护者确认门仍在拦(product),本轮不合并。未代 resolve greptile thread。
- [P1] apps/desktop/src/renderer/components/new-chat/pastePipeline.ts:186 — 单独粘贴带尾分隔符的工作区目录时,路径识别被「整段仅空白包围」判定误杀。
trimPathCandidate剥掉尾/或\后,segmentPathCandidates把剥离物留成非空白 text 段,hasOnlySurroundingWhitespace失败,整段返回null,不会生成目录 chip。这和 PR「单独路径仍引用」的承诺冲突。请忽略只含被剥离尾分隔符的 leftover text,并补 POSIX/与 Windows\的回归测试。
这些问题已在当前 head 的后续 commit 中修复(格式门/安全门已通过),自动 dismiss 旧的 CHANGES_REQUESTED 以解除合并阻塞。
|
@Stella-xixi 👋 这个 PR 已经有 3 天没有 rebase 了。 为了避免合入后出现 CI 未曾验证过的新问题,请在本地 rebase 最新的 |
|
@Stella-xixi 👋 这个 PR 已经有 4 天没有 rebase 了。 为了避免合入后出现 CI 未曾验证过的新问题,请在本地 rebase 最新的 |
Signed-off-by: Stella-xixi <2559689615@qq.com>
Signed-off-by: Stella-xixi <2559689615@qq.com>
375575b to
596fb6f
Compare
|
@Stella-xixi 👋 这个 PR 已经有 4 天没有 rebase 了。 为了避免合入后出现 CI 未曾验证过的新问题,请在本地 rebase 最新的 |
这次改了什么
摘要
收窄输入框的粘贴路径自动引用行为:只有整段粘贴除首尾空白外仅包含一个工作区内绝对路径时,才继续确认文件并升级为引用。终端日志、错误信息和普通叙述中混入的绝对路径保持字面原文,避免发送给模型时静默变成
@相对路径。变更类型
fix缺陷修复范围
stat、序列化和显式@/拖拽入口改动UI 变化
怎么验证的
自动验证
验证说明:修复提交接到 PR 来源基线后,已确认完整代码树与通过上述测试的版本一致;DCO 在最终提交上重新检查通过。
手工验证
不涉及:本次用纯函数回归测试覆盖 Issue 中的 Windows 终端输出输入形态。
未执行的验证
未启动 Desktop 做 GUI 手工验证;改动位于纯粘贴分段函数,已由定向与 related 单测覆盖。
风险
风险分类
影响与回滚
提交前检查