You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maka.apache.org by "somewan820 (via GitHub)" <gi...@apache.org> on 2026/09/03 07:18:51 UTC
[PR] fix(desktop): 既有会话发送不再报告已解析会话 (onSessionResolved 契约) [maka]
somewan820 opened a new pull request, #4630:
URL: https://github.com/apache/maka/pull/4630
## 问题
`createAppShellChatActions.send()` 的既有会话分支**无条件**调用 `options.onSessionResolved?.(sessionId)`:
- 新会话分支(`initialSessionId` 为空时)仅在 `submitted.kind === 'projected'` 时触发——这是回调的**契约**:它只应报告"本次发送**新建**、且首条消息成功投射的会话"。
- 既有会话分支(`initialSessionId` 非空)无条件触发,语义错误。
当前 `main` 上该回调尚无任何调用方(死代码),所以无行为影响。但 #4598 一旦接入 start-task(把 `onSessionResolved` 注入为 `workBoard.linkSession` 的触发点),无条件调用会把 Work Board 条目误链接到**无关的既有会话**。
## 修复
移除既有会话分支对 `onSessionResolved` 的无条件调用,并用注释明确该回调的契约。新会话分支行为不变。
## 测试
新增回归测试:既有会话(`activeIdRef.current` 已设置)projected 发送**不**触发 `onSessionResolved`。
## 验证
- desktop main 全量 1984/1984 通过
- `tsc -p tsconfig.main.json` 0 error · biome lint clean · `git diff --check` clean
## 说明
这是 C1(跨会话误消费)的**根本修复**,独立于 #4598 提交,可直接合入 `main`。它把 `onSessionResolved` 的语义钉死在"新建会话首条消息投射"上,使 #4598 或任何后续消费方不会被错误绑定。剩余依赖 feature 的清理(start-task claim 的取消路径与编排测试)在 #4598 上另行处理。
--
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
Re: [PR] fix(desktop): 既有会话发送不再报告已解析会话 (onSessionResolved 契约) [maka]
Posted by "M4n5ter (via GitHub)" <gi...@apache.org>.
M4n5ter merged PR #4630:
URL: https://github.com/apache/maka/pull/4630
--
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
Re: [PR] fix(desktop): 既有会话发送不再报告已解析会话 (onSessionResolved 契约) [maka]
Posted by "somewan820 (via GitHub)" <gi...@apache.org>.
somewan820 commented on PR #4630:
URL: https://github.com/apache/maka/pull/4630#issuecomment-5523001586
已按 review 5099565705 的建议修改并推送(c7f8fae78):
- **新会话分支**:`onSessionResolved` 回调现在只在 `submitted.kind === 'projected'` 时触发。此前 `outcome_unknown`(映射为 `unreconciled`)虽会跳过 `refused` 提前返回,但仍会调用回调——与"首条消息确认投射才上报"的契约冲突;且 `send()` 对 `unreconciled` 有意返回 `true`,调用方事后无法补救。
- **回归测试**:新增 `new Session + outcome_unknown` 用例,断言 `send()` 返回 `true`、会话保留(不调用 remove)、`onSessionResolved` 不触发。
验证:desktop main 全量 2005/2005 通过 · tsc 0 error · biome lint clean · `git diff --check` clean。
---
_本评论与代码修改由 AI(pi · deepseek-v4-flash)辅助生成,已按 CONTRIBUTING 在受影响 commit 附加 `Generated-by: pi` trailer。_
--
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
Re: [PR] fix(desktop): 既有会话发送不再报告已解析会话 (onSessionResolved 契约) [maka]
Posted by "M4n5ter (via GitHub)" <gi...@apache.org>.
M4n5ter commented on code in PR #4630:
URL: https://github.com/apache/maka/pull/4630#discussion_r3922572405
##########
apps/desktop/src/renderer/app-shell-chat-actions.ts:
##########
@@ -612,7 +612,11 @@ export function createAppShellChatActions(deps: {
});
if (submitted.kind === 'refused') return false;
if (submitted.kind === 'unreconciled') return true;
- options.onSessionResolved?.(sessionId);
+ // `onSessionResolved` is the contract for a Session this send CREATED
+ // and whose first message projected (the new-Session branch above). An
+ // existing-Session send must never report it, or a consumer that binds
+ // follow-up state to a newly resolved Session would bind it to an
+ // unrelated pre-existing conversation.
Review Comment:
<details open>
<summary>English</summary>
Could we also gate this callback in the new-session branch on `submitted.kind === 'projected'`?
`outcome_unknown` is mapped to `unreconciled`, but this branch only returns early for `refused`, so it still calls `onSessionResolved`. That contradicts the contract documented here and could link a Work Board item to a Session whose first message was never confirmed as projected. Since `send()` intentionally returns `true` for `unreconciled`, the caller cannot correct this afterward.
```ts
unsentSessionId = undefined;
if (submitted.kind === 'projected') {
options.onSessionResolved?.(session.id);
}
```
Please also cover `new Session + outcome_unknown` with a regression test asserting that `send()` returns `true` while the callback is not invoked.
</details>
<details>
<summary>中文</summary>
这里是否也应该把新会话分支的回调限制为仅在 `submitted.kind === 'projected'` 时触发?
`outcome_unknown` 会被映射为 `unreconciled`,但当前分支只对 `refused` 提前返回,因此仍会调用 `onSessionResolved`。这与此处声明的契约不一致,并可能把 Work Board 条目链接到首条消息尚未确认成功投射的 Session。由于 `send()` 对 `unreconciled` 会有意返回 `true`,调用方之后也无法补救。
```ts
unsentSessionId = undefined;
if (submitted.kind === 'projected') {
options.onSessionResolved?.(session.id);
}
```
建议同时补充 `新 Session + outcome_unknown` 的回归测试,断言 `send()` 返回 `true`,但回调不触发。
</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
Re: [PR] fix(desktop): 既有会话发送不再报告已解析会话 (onSessionResolved 契约) [maka]
Posted by "somewan820 (via GitHub)" <gi...@apache.org>.
somewan820 commented on code in PR #4630:
URL: https://github.com/apache/maka/pull/4630#discussion_r3923581195
##########
apps/desktop/src/renderer/app-shell-chat-actions.ts:
##########
@@ -612,7 +612,11 @@ export function createAppShellChatActions(deps: {
});
if (submitted.kind === 'refused') return false;
if (submitted.kind === 'unreconciled') return true;
- options.onSessionResolved?.(sessionId);
+ // `onSessionResolved` is the contract for a Session this send CREATED
+ // and whose first message projected (the new-Session branch above). An
+ // existing-Session send must never report it, or a consumer that binds
+ // follow-up state to a newly resolved Session would bind it to an
+ // unrelated pre-existing conversation.
Review Comment:
<details open>
<summary>English</summary>
Good catch — done. `onSessionResolved` in the new-session branch now fires only when `submitted.kind === 'projected'` (head `d1cfe8349`).
Follow-ups since the first fix (`c7f8fae78`):
- The gate was re-expressed as a single-line `if` so the file stays at or below the base token count (the renderer architecture debt ratchet only allows legacy AppShell files to shrink); the contract comments were re-added once the follow-up refactor freed budget.
- A follow-up refactor extracted the duplicated ~30-line `sendCommand`/`submitAndProject` block shared by the new-session and existing-session branches into a `submitIntoSession` helper, and removed the now-dead `if (submitted.kind === 'unreconciled') return true;` branch in the existing-session path (it existed to skip the deleted callback call). `nonTriviaTokens` went 4278 → 4089.
Verification: renderer architecture check passes against the CI base `726fb809` · desktop main 2005/2005 · CI `test` green.
---
_This comment and the code changes were AI-assisted (pi); per CONTRIBUTING the affected commits carry a `Generated-by: pi` trailer._
</details>
<details>
<summary>中文</summary>
好建议,已完成。新会话分支的 `onSessionResolved` 现在只在 `submitted.kind === 'projected'` 时触发(head `d1cfe8349`)。
初版修复(`c7f8fae78`)之后的后续调整:
- 门控改写为单行 `if`,使文件 token 保持不高于 base(renderer architecture 单调 debt ratchet 只允许 legacy AppShell 文件缩减);后续重构释放预算后,契约注释已补回。
- 一次重构把新会话/既有会话两分支重复的 ~30 行 `sendCommand`/`submitAndProject` 块提取为 `submitIntoSession` helper,并删除了既有会话路径中已失效的 `if (submitted.kind === 'unreconciled') return true;` 死分支(该行原本用于跳过已删除的回调调用)。`nonTriviaTokens` 从 4278 降至 4089。
验证:renderer architecture 检查以 CI 同款 base `726fb809` 通过 · desktop main 全量 2005/2005 · CI `test` 绿。
---
_本评论与代码修改由 AI(pi)辅助生成,已按 CONTRIBUTING 在受影响 commit 附加 `Generated-by: pi` trailer。_
</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