Repository navigation
fix(slack): keep a picture sent in a linked thread for the dashboard turn - #38076
Conversation
UX Review (Opus 5.5, fork) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS The fix copies each picture into the session's existing attachments store, which the recorded 2026-11-06 picture decision requires. The only surplus is a one-caller Notes
What this change shipsInventory (6 items) — 5 justifiedIntent: a picture sent in a Slack thread linked to a dashboard chat should reach that chat's agent. FIX.
[FIRST-PRINCIPLES-REVIEWED] f8ad20c Description read[DESCRIPTION-READ] 7e7d415fa5e15ab41cfb5fea0fc1a9eef26a36ce8d0b9c68cb00f8e7eb0fa0f8 That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS No design-level concerns. Storing the picture in the session before the hand-off fixes the root cause: the turn and the dashboard row both outlived the temp file. It also follows the recorded picture-kept-with-session decision and removes nothing. Notes
[DESIGN-REVIEWED] f8ad20c Description read[DESCRIPTION-READ] 6b162a7aa1dc7df4e9aabbdc44b73fcbb1c4b18c61276cd32ad010249f5156db 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 (fork) — ✅ no blocking findingsReviewed |
bolichen97
left a comment
There was a problem hiding this comment.
Welcome to Kiro Crew, @atkinh-amzn, and thanks for a clear first PR. The description explains the bug and the fix well.
Verdict: approve.
What I checked on f62272710c:
- Root cause. The linked-thread turn runs after the Slack handler task has unlinked its temp files (
slack/events.pycleanup). Storing the pictures inroute_linked_threadbefore the hand-off fixes that cause, not the symptom. - Order in the router.
store_linked_thread_images(slack/handler_runtime/inbound.py:908) runs after thechannel_agent_mismatchrefusal and after the pinned re-entry. So a refused reply stores nothing, and a re-routed reply cannot store twice. - Queued entries. The enqueue path hands cleanup of
image_temp_pathsto_dispatch_queued, which unlinks only after the dispatch. So the drain'sset_linked_thread_files(kwargs["image_temp_paths"])still sees live files, and each entry routes with its own files. - The context variable. It is set once per message in
_route_message(events.py:1518) and taken once instore_for_slot. A child task gets a copy, so a value cannot leak back into the parent or into another Slack event's task. - Storage.
store_ingested_imagesreuses_store_ingested_imagesunder_locked(key), the same lockdelete_sessiontakes. So the per-messageImageBudget, the session cap and deletion with the transcript all apply, as the 2026-11-06 decision says. Non-picture files and refused pictures keep their lines. - Failure path.
store_for_slotlogs and returns the text unchanged. That is the same outcome as before the fix, never a lost message. - Docs.
history.mdandslack-gateway.mdmatch the code.
Local run on the PR head: test/test_slack_linked_thread_images.py, test/test_history_bindings.py, test/test_handler_link_intercept.py and test/test_slack_handler_composition_contract.py gave 355 passed. flake8 is clean on the 7 changed source files. mypy is clean on the 3 core ones.
Not blocking: the **Goal:** line says "you can't end an image". It probably means "send". The goal is frozen, so leave it unless you want to fix the typo yourself.
I'm turning on auto merge, so it lands once the required checks are green.
AI-assisted, sent by Bolin Review bot
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
Head branch was pushed to by a user without write access
f622727 to
f6db648
Compare
bolichen97
left a comment
There was a problem hiding this comment.
Re-approving f6db648. The new part closes the race in the copy step well: the copy runs off the loop, so route_linked_thread now passes a still_current check that is read back on the loop. If the slot was closed, deleted or relinked meanwhile, store_for_slot removes the copies it just made, records the files again and returns None; a pinned route then reads as unrouted, and an unpinned one is resolved once more and pinned, which bounds it to one extra pass. ConversationLog.store_ingested_images keeps the copy under the session lock without an append, matching the spec note.
Locally on the head: the changed test files, 235 passed, including the new TestSlotChangedDuringCopy cases. Auto merge is on.
AI-assisted, sent by Bolin Review bot
Head branch was pushed to by a user without write access
d1e9db2 to
c76fcc6
Compare
bolichen97
left a comment
There was a problem hiding this comment.
Re-approving c76fcc6. The range-diff against the head I approved (f6db648) only drops the cleanup of copies after a relink, and adds a test for it. That is right: stored names come from the file content, so the old session's copy can be the same file a committed row already names, and deleting it would break that row. The session's own deletion reclaims it. The docstrings match. test/test_slack_linked_thread_images.py and test/test_history_bindings.py pass locally on this head (236 passed).
AI-assisted, sent by Bolin Review bot
|
@atkinh-amzn a correction to what I said in Slack: GPT 6.1's new finding on Dropping the rollback fixed the earlier problem (deleting a file another row names), but it opens this one: if the session is permanently deleted while Fix: decide under the session lock, before the copy. In Two other reds are not from this PR, and I re-ran both:
AI-assisted, sent by Bolin Review bot |
…turn A reply in a Slack thread linked to a dashboard chat runs as that chat's turn, after the Slack handler task has deleted the message's downloaded files, so the agent and the dashboard row got a dead temp path. route_linked_thread now stores each picture in the linked session's attachments (ConversationLog.store_ingested_images) before the hand-off, and the turn and the row name the stored copy. The event path records the files after the code-channel dispatch; the queue drain records each entry's own files. Part of kirodotdev#10871
Head branch was pushed to by a user without write access
c76fcc6 to
f8ad20c
Compare
bolichen97
left a comment
There was a problem hiding this comment.
Re-approving f8ad20c59b. GPT's deleted-session finding is fixed the way I suggested: store_ingested_images now decides under the session lock, the same lock delete_session reclaims attachments under. It stores nothing when a delete is in flight or when refuse (the slot's own session_was_deleted witness) says the session is gone. test_a_session_deleted_before_the_copy_gets_no_attachments_back and test_a_delete_in_flight_stores_nothing pin both paths, and the fingerprint row is updated. The range-diff against c76fcc6eb6 shows nothing else changed. The linked-thread and history tests pass locally on this head (238 passed). I approved the held CI runs on this head.
AI-assisted, sent by Bolin Review bot
|
Closing and reopening to refresh CI: PR Hygiene counted 7 commits against the stale base in the old push event (the PR has 1 commit), and Fast Gate was cancelled. AI-assisted, sent by Bolin Review bot |
Pull request was closed
…turn (#38076) A reply in a Slack thread linked to a dashboard chat runs as that chat's turn, after the Slack handler task has deleted the message's downloaded files, so the agent and the dashboard row got a dead temp path. route_linked_thread now stores each picture in the linked session's attachments (ConversationLog.store_ingested_images) before the hand-off, and the turn and the row name the stored copy. The event path records the files after the code-channel dispatch; the queue drain records each entry's own files. Part of #10871 Co-authored-by: atkinh-amzn <356308962+atkinh-amzn@users.noreply.github.com> (cherry picked from commit 9945f61)
…turn (#38076) A reply in a Slack thread linked to a dashboard chat runs as that chat's turn, after the Slack handler task has deleted the message's downloaded files, so the agent and the dashboard row got a dead temp path. route_linked_thread now stores each picture in the linked session's attachments (ConversationLog.store_ingested_images) before the hand-off, and the turn and the row name the stored copy. The event path records the files after the code-channel dispatch; the queue drain records each entry's own files. Part of #10871 Co-authored-by: atkinh-amzn <356308962+atkinh-amzn@users.noreply.github.com> (cherry picked from commit 9945f61)
…turn (#38076) A reply in a Slack thread linked to a dashboard chat runs as that chat's turn, after the Slack handler task has deleted the message's downloaded files, so the agent and the dashboard row got a dead temp path. route_linked_thread now stores each picture in the linked session's attachments (ConversationLog.store_ingested_images) before the hand-off, and the turn and the row name the stored copy. The event path records the files after the code-channel dispatch; the queue drain records each entry's own files. Part of #10871 Co-authored-by: atkinh-amzn <356308962+atkinh-amzn@users.noreply.github.com> (cherry picked from commit 9945f61)
…turn (#38076) A reply in a Slack thread linked to a dashboard chat runs as that chat's turn, after the Slack handler task has deleted the message's downloaded files, so the agent and the dashboard row got a dead temp path. route_linked_thread now stores each picture in the linked session's attachments (ConversationLog.store_ingested_images) before the hand-off, and the turn and the row name the stored copy. The event path records the files after the code-channel dispatch; the queue drain records each entry's own files. Part of #10871 Co-authored-by: atkinh-amzn <356308962+atkinh-amzn@users.noreply.github.com> (cherry picked from commit 9945f61)
… main (#39387) Backports to release/0.13.0 the fixes from #39342, squashed into one commit and brought up to date with release/0.13.0 after the Kiro Memory preview backport (#39360). Picks, in order; each [pick sha] is the commit on the #39342 branch, whose body has main's cherry-picked-from line: - fix(monitor): wake the session once when its watched PR merges or closes (#37776) [pick 84da419] - fix(security): match deny rules against Windows program suffixes and cmd/PowerShell in-word escapes (#33569) [pick e4941b7] - fix(mimocode): refuse a chat that would answer from Xiaomi's hosted model unsigned (#37629) [pick 1bfdce3] - fix(acp): end a quiet agent-started cycle on the shared runtime's stale gate (#37932) [pick fa870a2] - fix(conductor): re-read goal-conductor after a compaction (#37917) [pick ccdd67c] - fix(security): refuse a command nested past 32 substitutions before the floors walk it (#37875) [pick 2f9bd67] - fix(mates): carry a moved Bot's shell toolsSettings entry as execute_bash instead of holding it (#37973) [pick 16022f4] - fix: hold an app to its own sessions, jobs and runs (#37804) [pick 3dff0c0] - fix(acp): keep a KAS chat's stored record when its resume fails after the load (#37955) [pick 6ceb7b5] - fix(gateway): ignore a repeat SIGTERM during graceful shutdown (#38031) [pick b48287d] - fix(security): keep a quote in a $( ) from hiding a later ssh (#37558) [pick b9fed61] - fix(agent): rebuild takes a server's disabledTools from the kiro global (#38147) [pick c50bbcc] - fix(mcp_gateway): keep the backend when a stub leaves an open listen (#38121) [pick 3e9c7f9] - fix: refresh plan and model list after a kiro-cli sign-in to another account (#38053) [pick 5ad3d36] - fix(slack): keep a picture sent in a linked thread for the dashboard turn (#38076) [pick 7f8903e] - fix: keep a resolved tool policy when the gateway is too slow to answer (#36669) [pick 9be5691] - fix: open owner-only files and prune overlay folders without following links (#36994) [pick 6a1acc9] - fix: refuse the local token mint to app backends (#38113) [pick d166dab] - fix(subagent): hold a spawn's first prompt for its MCP servers (#38127) [pick e3e0298] - fix(security): refuse a headless git --output write with no approver (#36326) [pick 1abee40] - fix(restore): require an explicit mode, never default to replace (#38094) [pick ca86c06] - fix: make the deny gate's shell walk linear in command length (#36437) [pick 22c100b] - fix(chat): let a cancelled background start finish its session teardown (#36664) [pick b1dd34f] - fix(acp): refuse a start when two differing specs declare the agent's name (#38411) [pick 80ccfff] - fix: probe a silent turn while its co-tenant keeps the process busy (#38662) [pick 6354490] - fix(kas): let a reopened chat switch to models its load select omits (#38376) [pick 1640822] - fix(cloud): install a patched node 22 on run on aws instances (#38732) [pick 059cb90] - fix: write member record files without following links (#37303) [pick aac9642] - fix: fail a kas start fast once the host has turned its mcp off (#38677) [pick e147238] - fix(decisions): fall back to HTTP/1.1 when h2 is missing (#38759) [pick fc16482] - fix(mcp_gateway): free a spawn permit when its backend exits before initialize (#38793) [pick a084ba2] - fix(kas): start an app chat whose tool policy hides every kirocrew-cron tool (#38761) [pick ccea5a9] - fix(acp): give the tool-stall watchdog a margin over native waits (#34117) [pick b5d9e89] - fix(mcp): bind the working-folder answer to its launch; observe launch changes behind name grants (#38983) [pick a1069be] - fix(mcp): hide the gateway secret files from the npm install and third-party probe spawns (#39000) [pick 14d8571] - fix(sandbox): fold env name case on Windows in the agent env scrub (#33997) [pick 9bdce76] - fix(apps): let app turns follow the Auto approval mode (#38830) [pick e8336df] - fix: end a dashboard turn stopped while it is still being prepared (#36478) [pick 37fff93] - fix(acp): cleanup_session deletes the record on the session's own host (#39046) [pick 31b5ec4] - fix(acp): scan only the new part of a streamed tool result (#38852) [pick e2870db] - fix(sandbox): make an unscoped session host the OOM victim, not the gateway (#39189) [pick 2be6dde] - fix(security): read aws s3 downloads piped into tail, with 2>&1, or with an AWS_PROFILE prefix (#38271) [pick bf65d97] - fix: redact four display and log paths and use a fixed 502 message for session switch refusals (#38982) [pick 55d9ec7] - fix(sandbox): pin a credential-masking app's folder after the masks on the namespace backend (#34339) [pick afd2b14] - fix(acp): wait for systemd scope admission as its own startup stage (#37008) [pick 3e29c86] - fix(acp): wait for systemd scope admission on the AcpClient spawn path (#38303) [pick 85f0a25] - fix(acp): stamp the spawn instance on the AcpClient child (#38810) [pick f36eb5a] - fix: end the turn when the agent never confirms a stop (#38512) [pick 2665c9d] - fix(kas): renew a refused crew sign-in instead of failing every start (#38978) [pick 2f48cac] - fix(security): keep self-host detection when the ssh verb is a glob (#34056) [pick ab53f10] - fix(security): judge each substitution body for ssh-to-self (#37616) [pick d5b7ac3] - test: check the ssh floor's nesting bound below the gate's depth cap (#37964) [pick 6c9ae1d] - fix(mate): apply held Bot limits on shared claude sessions and refuse unnarrowed KAS children (#39212) [pick 721bbbe] - test(integration): wait out and reset the hidden-chat refresh between boots (#37933) [pick e77586d] - fix(browser): fall back to Kiro's Chromium under Automatic when Chrome's remote debugging is off (#39265) [pick 31912eb] Left out of #39342's set (not needed for 0.13.0): the provider_labels refactor, #34045, #36668, #39120 and #37627. Merge with release/0.13.0: kept both imports in runtime_session_load, runtime_spawn_launch and session_provider; session_allocation lists the memory_policy owner; the keep-record resume path passes kas_memory_mode as main does; dropped the ACP_BACKENDS_SESSION_EVICTION import that moved to session_provider_new_conversation.
Problem / Motivation
Goal: Bug Fix: Currently you can't end an image through Slack, when you try it fails to reach the backend and you have to switch over to the dashboard and upload there; this is annoying and breaks what should be a a reasonable and common workflow.
A Slack picture is downloaded to a temp file, and the Slack handler deletes it when its task ends. A reply in a thread linked to a dashboard chat is handed to that chat's turn, which starts in the background (or waits in the slot's queue) after the handler task has already ended. So the turn found no file: the agent got a dead
/tmp/tmpXXXX.pngpath instead of the picture, and the dashboard row showed the same dead path.Why it matters
Anyone who links a Slack thread to a dashboard chat and sends a picture there gets an answer about a file the agent never saw. Linking a thread is the way to keep talking to a dashboard chat from a phone, so a photo taken on the phone is exactly the case that breaks.
Not a goal
uploads/folder, a per-channel flag, 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.What changed (motivation → approach → change)
The turn read a file its own handler task had deleted. The per-session attachments store already keeps a channel's downloaded pictures for an appended row (#31807), but a linked-thread message is not appended by the Slack path: the dashboard slot saves its own window. So the router now stores the pictures itself, before it hands the message over, and the turn and the row both name the stored copy.
slack/linked_thread_images.py(new)store_for_slotcopies each picture into the linked session's attachments and rewrites its line to. The files are taken once per message.slack/handler_runtime/inbound.pyroute_linked_threadcalls it before redaction and the hand-off.slack/events.py,slack/events_queue.pyConversationLog.store_ingested_images(history_append.py,history.py)slack/handler.pyhistory.mdandslack-gateway.mddescribe the linked-thread store.Files that are not pictures, and a picture the store refuses (too large, or the session cap reached), keep their lines exactly as today. This follows the maintainer decision
docs/decisions/2026-11-06-a-channel-picture-is-kept-with-its-session.md: the copy lives and is deleted with the session's transcript, Incognito and Temporary included.The files travel in a context variable, not a parameter. The router is reached from the native handler, the transport dispatcher and the queue drain, and none of them carries the download list; each turn task inherits the value from the task that created it.
Backwards compatibility
Compatible:
store_ingested_imagesis a new member;route_linked_threadchanges the text only when the message carried downloaded pictures, and changes it tomarkup the dashboard already renders.Removes nothing: no key, function or record is removed; a picture's line changes from a deleted temp path to its stored copy.
Tests
test/test_slack_linked_thread_images.pydriveshandle_messageinto a realConversationLog, deletes the temp file the way the handler's cleanup does, then checks what the turn reads:test_the_turn_reads_a_stored_copy_after_the_cleanup: one stored copy, the turn's text names it, the prompt carries one image block, and the dashboard row names the same copy.test_without_the_store_the_picture_is_lost: the defect, the turn gets no image block.test_a_queued_message_names_the_stored_copy: a busy slot queues text that names the copy.test_a_file_that_is_not_a_picture_keeps_its_line,test_the_recorded_files_are_taken_once,test_no_conversation_log_leaves_the_text.test_a_queued_entry_routes_with_its_own_files: the queue drain routes with the entry's own files, never the files of the message that queued it.test_the_event_path_records_the_message_files:_route_messagedownloads one picture and its turn task sees that path.test/test_history_bindings.pyaddsstore_ingested_imagesto the frozen member inventory.Proof: not provable -- other: prove.py reverts the new module with the rest, so the test file fails at collection; reverting one line at a time by hand instead, removing the router's
store_linked_thread_imagescall failstest_the_turn_reads_a_stored_copy_after_the_cleanupandtest_a_queued_message_names_the_stored_copy, removing the queue drain'sset_linked_thread_filesfailstest_a_queued_entry_routes_with_its_own_files, and removing the event path'sset_linked_thread_filesfailstest_the_event_path_records_the_message_filesDeterminism: 20 of 20 runs at
-n0; 10 of 10 at-n 4 --dist loadgroup --max-worker-restart=2besidetest/test_handler_link_intercept.pyandtest/test_slack_handler_composition_contract.py; 5 of 5 seeded shuffled orders of the new file's 8 tests.Manual verification
Ran this build locally and confirmed that images successfully sent both as part of the initial message and as a reply in the thread (both one image and multiple in a post).
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 -nE "route_linked_thread(|maybe_route_linked_thread(" -- src/kiro_crew
Sibling: src/kiro_crew/slack/handler_runtime/inbound.py -- changed here
Sibling: src/kiro_crew/slack/handler_runtime/dispatch.py -- not affected -- routes through inbound.py, which now stores the pictures
Sibling: src/kiro_crew/slack/transport_dispatch.py -- not affected -- routes through inbound.py, which now stores the pictures
Sibling: src/kiro_crew/slack/code_channels/routing.py -- not affected -- code channels hand their own files to the bound session
Pattern harvest
Not generalizable: the defect is one hand-off that outlives the task owning its temp files; each channel cleans up in its own order, so no scanner can tell a safe hand-off from this one.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.