You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maka.apache.org by "Astro-Han (via GitHub)" <gi...@apache.org> on 2026/09/11 06:55:18 UTC

Re: [PR] fix(desktop,cli): stop rejecting legal edit-and-resend / rewind on structured history [maka]

Astro-Han commented on code in PR #5118:
URL: https://github.com/apache/maka/pull/5118#discussion_r3986644511


##########
apps/desktop/src/renderer/app-shell-revision-actions.ts:
##########
@@ -153,27 +155,10 @@ export function createAppShellRevisionActions(deps: {
       return;
     }
 
-    const turnOrder: string[] = [];
-    const seenTurns = new Set<string>();
-    const turnHasAttachments = new Set<string>();
-    for (const message of messages) {
-      const messageTurnId = (message as { turnId?: string }).turnId;
-      if (messageTurnId && !seenTurns.has(messageTurnId)) {
-        seenTurns.add(messageTurnId);
-        turnOrder.push(messageTurnId);
-      }
-      if (message.type === 'user' && message.attachments && message.attachments.length > 0) {
-        turnHasAttachments.add(message.turnId);
-      }
-    }
-    const sourceIndex = turnOrder.indexOf(turnId);
-    const retainedAttachmentTurn = turnOrder
-      .slice(0, Math.max(0, sourceIndex))
-      .find((candidate) => turnHasAttachments.has(candidate));
-    if (
-      (userMessage.attachments && userMessage.attachments.length > 0) ||
-      retainedAttachmentTurn
-    ) {
+    if (userMessage.attachments && userMessage.attachments.length > 0) {
+      // Self-contained quotes ride back into the draft as staged content;

Review Comment:
   **P2** "Self-contained quotes ride back into the draft as staged content" — they don't, on two counts. `TurnRevisionDraft` (same file, 55-66) holds only `originalText` / `previousComposerText`, and `beginEditUserMessage` does nothing but `composerRef.current?.setText(prompt)`; the staging prototype was `b075bc0c0` and `9836e4abd` reverted it whole. And a message carrying quotes can't reach this function anyway — `chat-turn.tsx:590` counts quotes into `editDisabled`, `:212` returns early on it.
   
   The cost isn't the inaccuracy. It's that the next person takes this as the current contract and removes the quote gate in `chat-turn.tsx` to match, which silently drops quotes — the exact bug #5109 was filed for. Drop this line; 160-161 are true and should stay.
   
   <details><summary>中文</summary>
   
   "Self-contained quotes ride back into the draft as staged content" 两个层面都不成立:`TurnRevisionDraft`(同文件 55-66)只有 `originalText` / `previousComposerText`,`beginEditUserMessage` 只做 `composerRef.current?.setText(prompt)`——staging 原型是 `b075bc0c0`,已被 `9836e4abd` 整个 revert;而且带 quotes 的消息根本到不了这个函数,`chat-turn.tsx:590` 把 quotes 计入 `editDisabled`,`:212` 早返回。
   
   代价不是注释不准,而是下一个人会把它当成当前契约,去掉 `chat-turn.tsx` 的 quote 门来对齐——于是静默丢 quote,正是 #5109 被提出的那个 bug。删掉这一行;160-161 是真的,保留。
   
   </details>



##########
apps/desktop/src/renderer/app-shell-revision-actions.ts:
##########
@@ -153,27 +155,10 @@ export function createAppShellRevisionActions(deps: {
       return;
     }
 
-    const turnOrder: string[] = [];
-    const seenTurns = new Set<string>();
-    const turnHasAttachments = new Set<string>();
-    for (const message of messages) {
-      const messageTurnId = (message as { turnId?: string }).turnId;
-      if (messageTurnId && !seenTurns.has(messageTurnId)) {
-        seenTurns.add(messageTurnId);
-        turnOrder.push(messageTurnId);
-      }
-      if (message.type === 'user' && message.attachments && message.attachments.length > 0) {
-        turnHasAttachments.add(message.turnId);
-      }
-    }
-    const sourceIndex = turnOrder.indexOf(turnId);
-    const retainedAttachmentTurn = turnOrder
-      .slice(0, Math.max(0, sourceIndex))
-      .find((candidate) => turnHasAttachments.has(candidate));
-    if (
-      (userMessage.attachments && userMessage.attachments.length > 0) ||
-      retainedAttachmentTurn
-    ) {
+    if (userMessage.attachments && userMessage.attachments.length > 0) {
+      // Self-contained quotes ride back into the draft as staged content;
+      // attachment references are session-owned and their rewritten targets
+      // are not exposed to clients yet, so those stay explicitly rejected.
       toastApi.info(copy.revisionUnavailableTitle, copy.revisionAttachmentsUnsupported);

Review Comment:
   **P3** This still sends `revisionAttachmentsUnsupported`, whose copy reads "Edit & resend does not yet support **historical** attachments" (`conversation-copy.ts:917` en, `:448` zh-CN, `:687` zh-TW). That is the wording of the rule this PR deletes; the guard that survives is about the source message's *own* attachments. Retarget the copy.
   
   Two notes that don't change the fix. This toast is unreachable in the real UI — `chat-turn.tsx:212` returns early on `editDisabled`, which already covers attachments — so the guard above it and the second new test case are defence in depth rather than a user-visible refusal; worth knowing if you were treating it as the rejection point. And the PR body says folder references "stay explicitly rejected": this file only checks `attachments`, so that rejection's authority is `chat-turn.tsx:588`. Worth saying so in the body.
   
   <details><summary>中文</summary>
   
   这里仍然发 `revisionAttachmentsUnsupported`,而那条文案写的是"Edit & resend 暂不支持**历史**附件"(`conversation-copy.ts:917` en、`:448` zh-CN、`:687` zh-TW)——那正是本 PR 删掉的那条规则的措辞;留下来的 guard 管的是源消息**自身**的附件。改掉文案指向。
   
   两点不影响这个修法的说明:这个 toast 在真实 UI 里不可达——`chat-turn.tsx:212` 对 `editDisabled` 早返回,而它已经覆盖了附件——所以它上面那个 guard 和新测试的第二个用例是纵深防御,不是用户可见的拒绝点;如果你把它当成拒绝点,理解有偏差。另外 PR 正文说文件夹引用"仍被显式拒绝":本文件只查 `attachments`,这条的权威在 `chat-turn.tsx:588`,正文该说清楚。
   
   </details>



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org