Repository navigation
fix: keep a telegram picture visible in the dashboard after the turn - #36520
Conversation
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
UX Review (Opus 5.5) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS The fix reuses the existing Notes
What this change shipsInventory (4 items) — 4 justifiedIntent: a picture someone sends the bot on Telegram stays visible in that dashboard conversation after the turn ends and after a reload. FIX.
[FIRST-PRINCIPLES-REVIEWED] 4005c3a Description read[DESCRIPTION-READ] dcf5fed404d77ee1c3509d3ec6fbda7b1e982788c5f9fc29194b1633ca3d887f That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: it reuses the existing [DESIGN-REVIEWED] 4005c3a Description read[DESCRIPTION-READ] 6a94f859c3f70a578a660acb8eb5517638e3e7fb95eeb2f5c963160a2c828644 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
|
Review passed on this head. Please rebase onto the latest main so CI can run fresh; the current CI run predates fixes on main and cannot go green as is. The approval will follow once the rebased head is green. |
A photo sent on Telegram was downloaded to a temp file that the turn deletes, and the user row kept that bare path plus a note that the file lasts until the turn ends. A dashboard tab on the conversation then showed a dead path where the picture had been. The Telegram turn now copies the photos it downloaded into the session's attachments store right before it writes the row, through ConversationLog.store_ingested_images (the copy step of append(ingested_images=...) on its own), and hands the stored text to both the live dashboard window and the transcript append. The live window rewrites its rows on every save, so it has to hold the same text the transcript does. A store that fails leaves both writers the text as it came in, so the turn is still recorded. Part of #10871
|
Rebased: main moved in src/kiro_crew/history.py, src/kiro_crew/history_append.py, src/kiro_crew/telegram/dispatch/turn_engine.py, test/test_history_bindings.py, docs/system-specs/modules/history.md and docs/system-specs/modules/messaging.md since this head went green (2f7e9f2 -> 2d7d2df); CI re-running. Why this rebase: GitHub reported the pull request as conflicting, and a fresh run on today's main was asked for above. Two changes on main meet this one:
What was checked, on a clean Ubuntu 24.04 (Linux x86_64) host, on this exact commit on 5c747a0: every gate of the repository's gate list and the related tests on both surfaces, semgrep and the flake ratchet green; [operator: bolichen97] |
cc9f424 to
4005c3a
Compare
|
[operator: bolichen97] One correction to the note above: the host checks ran on the same patch at a095f53d, on 5c747a0. main moved once more before the push, in none of this pull request's files, so the pushed head 4005c3a is that same patch on 2d7d2df, and this head's CI run is the test run on today's main. |
|
[operator: bolichen97] The one red check on this head, Nothing is pushed for it. The job gets its one re-run once CodeQL on |
Code change approver recommendation: A person should decideWhy: the decider estimates a 10% chance that this change introduces a defect, within the 12% limit for approving on its own, but it is held at tier 2: design-doc-gate: A. Telegram now calls ConversationLog.store_ingested_images on its downloaded photos before redaction and before both the live dashboard window and the transcript append, so both writers name the stored copy. The order (store, then redact) matches the existing append path. The step only runs when _session_restricted allows a write, and that check covers channel-native incognito/temporary sessions through the privacy_mode fallback. Under the session lock it does nothing if a delete is in flight. A failed store is caught and the row is written as before. Telegram has a single ingest point, so no other path is left out. Two new tests cover the success and failure paths, and CI is green. Tier: 2, held for a person: design-doc-gate: A. An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
I reviewed head 4005c3a. Telegram now stores the photos it downloaded in the session's attachments store before the redaction step, and the live dashboard window and the transcript append both get that stored text, so neither one can write the deleted temp path back. If the store fails, the turn falls back to the original text, so the row is still recorded. The new test fails when the turn engine is reverted to main and passes on this head. The full Telegram test set passes locally. I found no correctness, security or data-loss problem that blocks merging.
Problem / Motivation
Goal: A picture someone sends the bot on Telegram still shows in the dashboard after the turn ends and after a reload.
A Telegram photo is downloaded to a temp file, and that file is deleted when the turn ends. The transcript's user row kept the bare temp path plus the model-facing note
[Image <name> is saved in the folder /tmp/ until this turn ends; ...]. So a dashboard tab on that conversation showed a dead path and a stale note where the picture had been. Feishu had the same defect and was fixed in #31807; Telegram is the next channel #10871 wires.Why it matters
Anyone who sends the bot a picture on Telegram and then opens that conversation in the dashboard sees text instead of the picture, and the note points at a file that no longer exists. The picture is gone from the history for good.
Not a goal
uploads/folder, or a new privacy gate. The maintainer decision on Persist inbound images for the non-Slack channels; namespace the uploads directory per session #10871 rules these out.role != "user"rule for typed paths stays.What changed (motivation → approach → change)
The user row named a temp file the turn deletes.
ConversationLog.store_ingested_imagesalready copies a channel's own downloads into the session's attachments store and rewrites the row to name the copy (the #31807 step, which #38076 made callable on its own). Telegram needs that step a moment earlier than Feishu: when a dashboard tab is open on the conversation, Telegram shows the row there live before it appends it, and that window rewrites its rows on disk on every save. A window still holding the temp path would undo the copy.telegram/dispatch/turn_engine.py)IngestResult.image_paths), stores them throughConversationLog.store_ingested_imagesright before the row is scrubbed and written, and hands the stored text to both the live dashboard window and the transcript append. Each picture becomes a copy insessions/<stem>.attachments/, its path line becomes, and its turn-only note is dropped. A store that fails leaves both the text as it came in, so the turn is still recorded. Nothing changes when the session is restricted, since that turn writes nothing.history.mdandmessaging.mdsay Telegram stores its pictures before both writers.A picture that cannot be kept (too large, the session cap reached, or the session being deleted) leaves the row exactly as it is today. The model's prompt for the turn is unchanged, and the temp files are still deleted when the turn ends.
Backwards compatibility
Compatible: no function, signature or key changes; only a Telegram user row carrying a downloaded photo changes, to
markup the dashboard already renders.Removes nothing: no key, function or record is removed; the stored row loses only a note that stopped being true when the turn deleted the file.
Tests
test/test_telegram_attachments.py::TestAPictureOutlivesTheTurn::test_the_row_and_the_live_window_name_a_copy_kept_with_the_sessiondrives a Telegram photo turn into a realConversationLog. The user row names the one stored copy in the session's attachments directory with no note left, the live dashboard window is handed that same text, and the downloaded temp file is gone after the turn.test/test_telegram_attachments.py::TestAPictureOutlivesTheTurn::test_a_store_that_fails_still_writes_the_rowmakes the store raise a lock timeout: the live window and the transcript still get the user row, as it came in.Proof: PROVEN test/test_telegram_attachments.py::TestAPictureOutlivesTheTurn::test_the_row_and_the_live_window_name_a_copy_kept_with_the_session (head a095f53d257a)
Determinism: both
TestAPictureOutlivesTheTurntests 20 of 20 runs at-n0, the two in reversed order, and all oftest/test_telegram_attachments.pywith the new tests run after the rest.Manual verification
Reproduced and smoke-tested on Ubuntu 24.04 (Linux x86_64) on a clean checkout of this PR's base. No live Telegram bot can be reached there, so the run drives the real Telegram dispatcher (
handle_message) with a fake client whose download writes a PNG, a realConversationLogin an isolated data home, and a spy on the real live-window projection. An isolated gateway on that same home then serves the dashboard's view-time file endpoint,/api/file-raw.Before (base):
After (this PR):
A photo whose caption carries a valid GitHub token is kept the same way, and its row and live window both read
look [REDACTED: credential]above the stored picture. A Telegram text-only turn writes"hello there"as its row and creates no attachments store.Screenshots / video
N/A — the diff touches no frontend file; the dashboard already draws a user row's
markup.Related Issues
Part of #10871
Sibling sweep
Swept: git grep -n "append_attachment_context(" -- src/kiro_crew
Sibling: src/kiro_crew/telegram/dispatch/turn_engine.py -- changed here
Sibling: src/kiro_crew/feishu/transport_dispatch.py -- not affected -- fixed by #31807
Sibling: src/kiro_crew/discord/transport_dispatch.py -- tracked in #10871
Sibling: src/kiro_crew/teams/transport_dispatch.py -- tracked in #10871
Sibling: src/kiro_crew/webex/transport_dispatch.py -- tracked in #10871
Sibling: src/kiro_crew/wecom/transport_dispatch.py -- tracked in #10871
Sibling: src/kiro_crew/weixin/transport_dispatch.py -- tracked in #10871
Sibling: src/kiro_crew/whatsapp/transport.py -- tracked in #10871
Pattern harvest
Not generalizable: each channel has its own ingest, write and cleanup order, so the fix is wiring that channel's downloaded paths into the store before its writers, not a rule a scanner could hold.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Submitted under the project's Apache-2.0 license (see CONTRIBUTING.md).