Skip to content

Mirror only the user's own turns to IM - #28

Merged
neotechnet merged 1 commit into
stack/installed-0.3.8from
fix/telegram-only-steve-turns
Nov 18, 2026
Merged

neotechnet merged 1 commit into
stack/installed-0.3.8from
fix/telegram-only-steve-turns

Conversation

@neotechnet

Copy link
Copy Markdown
Owner

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.js records per Session who the running turn is for (turnFor), from the turn's own user/message sources. It is cleared at turn/start and turn/end. Peer-turn text is neither mirrored to all connections nor held for bookends. If the user's own message joins a peer turn, the rest of that turn is his. Part-switch continuations (a bare handoff resume, a failed-switch resume note) decide nothing. A restart resume note (resumed) counts as a peer's. Cards are unchanged.

Tests: 11 new tests in ds-bot/test/im.test.js.

  • Negative control on unchanged 0.3.8 index.js (blob 397d56e9): 9 of the 11 fail. The other 2 are guards against silencing the user, so they pass on both.
  • With the fix: im tests 89 pass, 0 fail, 6 skipped.
  • Full 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.
  • Lint: 0 errors, 83 warnings.

Scope: ds-bot/src/host/im/index.js, ds-bot/test/im.test.js.

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.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T16:56:49.343805Z be8c526 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +1606 to +1609
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))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@neotechnet
neotechnet merged commit ffe017d into stack/installed-0.3.8 Nov 18, 2026
28 of 30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant