Repository navigation
Mirror only the user's own turns to IM - #28
Conversation
A turn started by another Bot or a scheduled task put that Bot's text on the user's phone, trimmed by size only, so a one-paragraph Bot-to-Bot answer went out whole. Steve's rule (2026-11-17): IM mirrors only turns he started. Each Session now records who its running turn is for, from the turn's own messages: the user's (app, IM or card answer) or a peer's (a Bot relay or a scheduled task). Text of a peer turn is neither mirrored to `all` connections nor held for `bookends`. The record is cleared at both turn edges, so it cannot outlive its turn in either direction, and the user's message joining a peer turn makes the rest of it his. A part switch that goes on with a stopped turn carries the Bot relay that started it; a bare handoff or failed-switch resume note means no Bot did, so it decides nothing and the user's resumed turn still mirrors. A restart's resume note cannot say who asked and stays silent. Cards are unchanged: questions, views and approvals still go out.
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: be8c52612f
ℹ️ 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 continues = source => (source.role === 'handoff' && source.resume === true) | ||
| || (source.role === 'resume' && source.resumed !== true) | ||
| const fromPeer = source => source?.kind === 'schedule' | ||
| || (source?.kind === SOURCE_KIND && !continues(source)) |
There was a problem hiding this comment.
Preserve turn ownership across part-switch continuations
When a user-started turn switches parts, parts.js's handoffSource emits a bare handoff resume because turns.js does not store user messages in entry.info. Ignoring that source leaves the resumed turn unclassified, so a Bot relay arriving later sets it to peer and suppresses subsequent text even though the user started the work. Scheduled turns also have no entry.info, so they receive the same bare handoff and incorrectly resume mirroring text. Carry the actual user/peer classification through successful and failed part switches rather than treating these continuation sources as undecided.
Useful? React with 👍 / 👎.
Job tg-only-steve-turns-20261117 (Igor). Local stack PR, not for upstream.
Rule (Steve, 2026-11-17): Telegram mirrors only turns he started. Text from a turn started by another Bot or a scheduled task never reaches his phone, whatever its length. His own turns keep sending their first and last block on
bookends.Change:
ds-bot/src/host/im/index.jsrecords per Session who the running turn is for (turnFor), from the turn's ownuser/messagesources. It is cleared atturn/startandturn/end. Peer-turn text is neither mirrored toallconnections nor held forbookends. If the user's own message joins a peer turn, the rest of that turn is his. Part-switch continuations (a barehandoffresume, a failed-switchresumenote) decide nothing. A restartresumenote (resumed) counts as a peer's. Cards are unchanged.Tests: 11 new tests in
ds-bot/test/im.test.js.index.js(blob 397d56e9): 9 of the 11 fail. The other 2 are guards against silencing the user, so they pass on both.npm test: 3028 tests, 2989 pass, 7 fail, 32 skipped. The same 7 fail on the unchanged base, and none are in IM.build-client --check: exit 0.Scope:
ds-bot/src/host/im/index.js,ds-bot/test/im.test.js.