Repository navigation
feat(slack): one renderer for both ingress kinds, images flow both ways - #10369
NicholasRBowers wants to merge 1 commit into
Conversation
|
Intent: A session with a Slack attachment is served by ONE Slack renderer whichever surface a turn arrived from (RFC session-address-model §5.3/§5.4), and pictures flow both ways between the dashboard transcript and the linked thread: outbound through the renderer with the uploads directory as an approved root, inbound by promoting a Slack picture into that directory so the dashboard renders it after the turn. |
Design Review (Opus 5.5) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS Slack pictures now persist in one flat Watch
Suggestions
[DESIGN-REVIEWED] 77e3529 Description read[DESCRIPTION-READ] 25f843a6ee080e50b6ed83930ef1cf8da6a4a035d01ae16fe5e98dc29c1effd3 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 |
First Principles Review (Opus 5.5) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS Pictures in unlinked Slack threads now stay forever; the description says "the directory's own retention applies", but Not justified as shipped
What this change shipsInventory (10 items) — 7 justifiedIntent: one Slack output path per linked session, so pictures travel between the dashboard and Slack in both directions. ADDITION, plus a removed duplicate.
[FIRST-PRINCIPLES-REVIEWED] 77e3529 Description read[DESCRIPTION-READ] 4b0660fc60d4f004a65f5faf12cac4d8a4877b0734329a620942ed3bbaedf396 That sha256 names the PR description this verdict read. Recompute it with |
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: |
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: |
e1f2dc2 to
1421de3
Compare
1421de3 to
9b72459
Compare
|
self-added: yes
|
|
self-added: yes
|
|
self-added: no
Maintainer: if this ruling should stand, the one-line exit the lane accepts is |
|
self-added: no
|
|
self-added: yes
|
|
self-added: no
|
|
self-added: yes
|
|
self-added: yes
|
|
self-added: no
|
|
self-added: yes
|
|
self-added: no
|
|
self-added: no
|
|
self-added: no
|
|
Drive status (edited in place; head
|
|
self-added: no
|
|
self-added: yes
|
|
self-added: yes
|
|
self-added: yes
|
|
self-added: yes
|
|
self-added: no
|
|
self-added: no
|
|
self-added: no
|
|
self-added: no
|
|
self-added: yes
|
|
self-added: no
|
|
self-added: no
|
|
self-added: no
|
|
self-added: no
|
|
self-added: no
|
|
self-added: no
|
|
self-added: yes
|
|
self-added: no
|
|
self-added: no
|
|
self-added: yes
|
|
self-added: yes
|
|
PR triage: rebase needed, and merge order needs agreeing with #15273 and #16851 I checked head
Coordinate with open PR #15273 ("build image blocks only from a channel's attachment list"). The two PRs overlap in code and conflict in behavior:
Also overlapping: #16851 (cron replies upload embedded images to Slack). It moves the renderer's extract/upload into Still open from earlier review comments: Design Review flagged that Recommendation: rebase onto current main, then agree a merge order with #15273, and port the inbound image to its structured-attachment path if #15273 lands first. |
|
Nick's agent: Nick is no longer actively driving this PR, so it's open for anyone who wants to pick it up. Auto-merge is disarmed. Current state: head |
Problem / Motivation
Goal: A session linked to Slack is served by one Slack renderer from both ingress kinds, so a picture pasted in the dashboard reaches the thread and a picture posted in the thread renders in the dashboard.
A session linked to Slack has more than one Slack output path, and the dashboard-side one cannot carry a picture. A Slack-born turn is served by
SlackRenderer(streaming, task cards, OPTIONS control, image uploads). A dashboard-born turn on the same linked session is served by a hand-rolled text-only subset inside the dashboard turn loop: it posts a💬echo, opens a stream for tool cards, and posts the reply text at the end. A picture pasted into the dashboard therefore reaches the thread as a filesystem path. An agent-drawn chart does the same. The link-time history backfill is a third text-only writer with the same gap.Inbound has the mirror image of the problem. A picture posted in the Slack thread is downloaded to a temp file, the bare temp path is appended to the prompt, and the file is deleted when the turn ends. The dashboard transcript then shows a dead path where the picture was.
Why it matters
The session address model (
docs/request-for-change/rfc-session-address-model.md, §5.3 and §5.4) says the dashboard is the permanent host, a channel is an attachment, and ingress selects the delivery surface while the delivery surface selects the capability set. The conclusion this change draws from that is one output path per surface: whichever side a turn arrived from, a reply bound for the Slack thread is shaped by the one Slack renderer. The duplicate Slack path is exactly where a "Slack-born" and a "dashboard-born" session are still two different kinds of session on the output side. Pictures are how people report UI bugs. Today a picture renders only on the surface it was sent from, in both directions.Not a goal
slack/handler.pyhandle_messagepath and theslack.messaging.use_transportflag: a separate migration, untouched._deliver_cross_surface_reply, the Discord/Telegram/Teams legs stay text-only; the inbound promotion's rollout to the seven sibling channels is Persist inbound images for the non-Slack channels; namespace the uploads directory per session #10871 item 1).Rendereror a fan-out renderer: the RFC's Phase 3 surface model.uploads/: this adds no policy; the directory's own retention applies, tracked in Persist inbound images for the non-Slack channels; namespace the uploads directory per session #10871 items 2 and 3.Backwards compatibility
Reader:
slack/transport_dispatch.py:dispatch-- chat -- a Slack-born turn still drives the sameSlackRendererand callsauthorize_upload_root(cwd),release_held_word()andclose()unchanged; the cwd root keeps its rule and only gains an identity fixed at approval (test_slack_renderer.py,test_turn_ceiling.py,test_close_guard_parity.py).Reader:
dashboard/chat_slack.py:drain_slack_backfill-- chat -- link-time history rows go throughSlackRenderer.post_history_rowinstead of hand-formatted posts, same icons and limit (test_slack_one_renderer.py::TestPostHistoryRow).Reader:
slack/events.py:_route_message-- chat --process_slack_filesnow returnsIngestResult; temp paths are still unlinked on every discard path and promoted paths are excluded from them (test_slack_events_coverage.py,test_slack_files.py).Reader:
messaging/outbound_files.py:extract_local_refs-- chat -- the sibling renderers (discord, telegram, teams, webex, whatsapp) still pass a barestrroot; it is approved on the spot, so their behaviour is unchanged (test_discord_outbound_files.py,test_teams_files.py,test_telegram_parity.py,test_webex_renderer.py,test_whatsapp_files.py).Reader:
dashboard/chat_runner.py:_run_chat-- chat -- gains the keyword-only_ingress(default dashboard); every existing caller is valid, and the hand-rolled Slack mirror it replaces had no reader outside the runner (test_chat_runner_composition_contract.py).Breaking:
slack/events.py:_route_message-- chat -- a picture posted in a Slack-native thread that is nottemporary/incognito(durable flag or same-message!token) now persists in<data_home>/uploads/instead of being a temp file deleted at turn end -- a retention change, accepted: the dashboard already persists pasted pictures this way, and cleanup/retention for both is tracked in #10871.Breaking:
dashboard/chat_runner.py:_run_chat-- chat -- a dashboard-born turn on a linked session now reaches the thread in the Slack-born shape -- streamed text segments, the OPTIONS control on the timing footer, the thread status plus a lazily opened stream instead of aThinking…placeholder -- a visible change, intended (see Three visible differences below).What changed (motivation → approach → change)
One
SlackRendererserves a linked session from both ingress kinds, and pictures travel both ways between the dashboard transcript and the Slack thread.dashboard/slack_mirror.open_slack_mirror,chat_runner._run_chatSlackRendererand callson_turn_start/on_text_chunk/on_thinking/on_tool_call/on_doneat the event sites; the hand-rolled Slack calls are goneStreamRedactor(redact_via_context)(_mirred, and_mirthinkredfor the reasoning feed)render_for_slack's default), so a companion's extra credential patterns still apply on a composed host; the withheld tails flush before each tool card, before the seal, before the first answer text (the renderer posts the reasoning then), and at teardown. The renderer adds a DISPLAY-form holdback on every throttled flush (_split_trailing_display_run): a key the model splits with markup --[AKIA](url)ending one chunk, the rest opening the next -- renders whole on Slack while the raw scan sees)end the run, so the raw tail whose rendering is a credential-class run is held with the trailing word until the join is scanned as Slack shows it; image references are left to the ref holdSlackRenderer.on_tool_callviaredact_for_target, thenTOOL_CARD_LIMITAKIA**IOSF**ODNN7EXAMPLEis caught before the emphasis is stripped, and only the redacted text is cut to 75 characters, so a cut can never expose a secret's prefix; one method covers the dashboard mirror and the nativedispatchpath, and the mirror hands the fields over untoucheddecider=None,reactions_enabled=False,user_id=state.owner_id,uploads_allowed=not slot.is_restrictedpost_linked_approval); achat.startStreamwith no recipient would demote tochat.updateSlackRenderer.close()_Thinking…_placeholder, clears the thread status, on every exit path;close(publish=False)does the closing without the publishing, for a turn the audience fence withholds_mirror_publishes()inchat_runner,cross_surface_withheldmessaging/outbound_files.extract_local_refs(roots),outbound_files.ApprovedRoot/approve_root,SlackRenderer.authorize_upload_root(cwd)and its awaited twinauthorize_upload_root_off_loop(the two production callers approve in a worker thread, since the approval resolves the cwd and pinsuploads/)within_root_is_canonical, never re-resolved at read time, souploads/swapped for a link after approval cannot move the boundary); the uploads root's refusal of a link at its name and its identity come from ONE pinned open (platform_compat.pin_directory+pinned_fs.fd_real_path), so there is no screen-then-resolve window, and anuploads/that does not exist yet authorizes nothing until it does; denylist, symlink refusal, raster sniff, budgets and the restricted ceiling are unchangedecho_user_message,post_history_row,messaging/display_safety.mirror_echo_text,chat_slack.drain_slack_backfill💬echo and the🧑/🤖rows go throughrender_for_slack, extraction first, redaction before the length cutmessaging/attachments.ingest_attachments(persist_images=True),kiro_crew/uploads.create_upload_file,pinned_fs.create_and_open_dir_pinneduploads/with the dashboard's naming (<uuid hex>_<name>, sniffed extension,O_EXCL,0o600), all-or-nothing, created relative to a pinned directory descriptor withO_NOFOLLOWwhere the platform can (POSIX), and on Windows written under aplatform_compat.pin_directoryhandle held from before the open until after the last byte, so the directory cannot be swapped mid-write and a junction atuploads/is refused at the pinuploads.markdown_image_dest↔outbound_files._finish_destination,test/fixtures/markdown_image_dest.jsonmdImageDest/mdImageDestToPath(website/src/utils/fileTokens.ts): forward slashes for a Windows path, a<…>wrap with%as%25for a space or%; only the wrapped form is decoded, a barephoto%20copy.pngkeeps its name. Both producers and both inverses are pinned to ONE shared table, walked by the backend test and bywebsite/src/test/fileTokens.test.ts, so an escaping change on either side fails that side's suite; the wrap now closes at the last>on the Python side too, so a<or>in a file name round-trips like it does in the composerslack/files.process_slack_files(persist_images=)(required, no default),slack/events._inbound_images_persist,_strip_leading_mentiontemporary/incognitoor the message carries!incognito/!temporary-- read under the key the turn runs under, so a single-session DM (slack.dm_single_session, flat keyslack:<channel>) honours an!incognitotyped in an earlier message; the gate reads mention-stripped text so<@bot> !yolois the bang command it is_run_chat(_ingress=),slack/handler.maybe_route_linked_thread,chat_utils._dequeue_next_message,slot_queue_repository.queue_edit_by_idslackand never echoed back with its files; a queue merge stops at an ingress change so a batch is one kind; an edit of a queued entry drops the tag with the other provenance flags, since the replacement words were typed in the dashboard and the thread has not seen themkiro_crew/uploads.py, used bydashboard/handlers/files.py,messaging/attachments.py,slack/renderer.py_UPLOAD_DIRtest override still wins firstsecurity_posture.pySlackRenderer.post_history_rowas the render pathflowchart LR subgraph Before D1[dashboard turn]:::ctx --> H1[hand-rolled Slack calls in chat_runner]:::removed --> T1[Slack thread]:::ctx S1[Slack turn]:::ctx --> R1[SlackRenderer]:::ctx --> T1 end subgraph After D2[dashboard turn]:::ctx --> R2[SlackRenderer]:::changed --> T2[Slack thread]:::ctx S2[Slack turn]:::ctx --> R2 U2[uploads/ dir]:::added --> R2 end classDef added fill:#DCFCE7,stroke:#16A34A,color:#14532D,stroke-width:2px classDef changed fill:#FEF3C7,stroke:#D97706,color:#78350F,stroke-width:2px classDef removed fill:#FEE2E2,stroke:#DC2626,color:#7F1D1D,stroke-dasharray:4 3 classDef ctx fill:#E0F2FE,stroke:#0284C7,color:#0C4A6E linkStyle 0,1 stroke:#DC2626,stroke-dasharray:4 3 linkStyle 4,5,7 stroke:#16A34A,stroke-width:2px🟩 added · 🟨 changed · 🟥 removed · 🟦 unchanged
Both ingress kinds now reach the thread through the one renderer, and the dashboard's uploads directory is a root it may read pictures from.
A linked session had two Slack output paths. A Slack-born turn went through
SlackRenderer. A dashboard-born turn went through hand-rolled calls inchat_runnerthat could not carry a picture and posted only the text after the last tool. A picture pasted in the dashboard never reached the thread. A picture sent from Slack landed in a temp file the turn's cleanup deleted, so the transcript showed a dead path where the picture was.The session address model (§5.3/§5.4) says the attachment decides where a reply is reachable and the ingress decides how it is shaped. So there is one renderer per surface, driven from both ingress kinds, and the dashboard's uploads directory is admitted as a second approved root: the file the transcript row names is the file Slack uploads.
The dashboard turn loop builds the renderer and drives it from the event sites the hand-rolled calls occupied. Text and tool-card fields are redacted for the form Slack will display before they leave. Outbound, a picture in the reply or the echo is extracted under one of the two roots and read through a descriptor pinned to that root, so a link planted in one tree that resolves into the other is refused. Inbound, a Slack picture bound for a linked slot is promoted into
uploads/through a pinned, no-follow, all-or-nothing write, and its transcript row is spelled the way the composer spells one, with the outbound extractor as the exact inverse, so the picture renders in the dashboard and travels back to Slack even from a data home whose path holds a space or a%. A message that arrived from Slack carries an ingress tag, so it is never echoed back into the thread it came from.Three visible differences for a dashboard-born turn, all of them the Slack-born shape: every text segment streams into the thread, the OPTIONS control rides the turn's timing footer with its
tsrecorded for expiry, and the in-flight indicator is the thread status plus a lazily opened stream rather than aThinking…placeholder message.Scope, stated plainly. The legacy
slack/handler.pyhandle_messagepath and theslack.messaging.use_transportflag are a separate migration and are not touched. Non-Slack channels (_deliver_cross_surface_reply, the Discord/Telegram/Teams legs) stay text-only. The dashboard is not itself aRendererand there is no fan-out renderer; that is the RFC's Phase 3 surface model. Retention of a promoted image follows whatever the uploads directory already does; this adds no policy.Tests
test/test_slack_one_renderer.py(new, 100 tests):approve_rootrefuses what is not a tree and can refuse a link at the name._approved_rootsin a worker thread with the same result, and both production callers (slack_mirror,slack/transport_dispatch) await it (source-pinned)._approved_roots: the uploads dir rides beside a valid cwd with both identities fixed at approval; an invalid cwd authorizes nothing; a link atuploads/, or anuploads/that does not exist yet, authorizes only the cwd.create_upload_fileis all-or-nothing: a short write is completed, a failed write leaves no partial file, a zero-progress write fails closed.close(publish=False)stops an open stream without completing the card or flushing held text, and leaves a fallback placeholder exactly as shown.on_tool_callthe raw fields (no slice, no scrub of its own).create_upload_fileon the Windows branch pins the directory across the write: the pin is taken before the by-name open and released after the last byte, a pin refusal (junction atuploads/) creates no file, and a failed write still releases the pin.create_upload_filenever follows a planted link: a symlinkeduploads/is refused with nothing written where it points, a missing directory is created and written through its pinned parent, a failed write unlinks through the descriptor, and without descriptor support a reparse point atuploads/is still refused while a real directory works.markdown_image_destand the outbound scanner walktest/fixtures/markdown_image_dest.json(11 path ↔ destination ↔ decoded rows plus the legacy bare case): the producer spells each path as the table says and the scanner reads each destination back,//host/sharestaying a remote reference; the same table is walked bywebsite/src/test/fileTokens.test.tsformdImageDest/mdImageDestToPath, so the two grammars cannot drift silently. The inbound row uses the rule, and the ACP encoder's Windows grammar still finds the path inside the wrap.test_outbound_files.py): the producer's wrapped%25form resolves to the real file in akc%homedata home, a barephoto%20copy.pngstays verbatim, and a malformed%zzsequence inside the wrap is taken as written.echo_user_message: shape, full-text redaction before the 500-char cut, a pasted picture is uploaded after the echo, extraction precedes the length cut, no roots means no bytes ship, a Slack refusal never raises.post_history_row: role icons, a row's picture uploads after the text, credentials redacted, a failed post reportsFalse.close()appends the throttle buffer -- with the word a throttled flush held back in front of it, as a final flush -- and the withheld reference tail before stopping the stream, still closes the surface when that append fails, seals a no-stream placeholder with the text shown so far and deletes one that showed nothing, finishes an unfinished turn's surface, and touches nothing afteron_done; no decider means no approval card._run_chat: echo, thread status,start_streamwith the owner as recipient, task cards opened and completed, every text segment streamed, OPTIONS control recorded with ats, status cleared; a credential split across two chunks never reaches the stream, a key split by link markup across two throttled flushes never renders whole (mirror leg and renderer-level, plus the boundary helper's own cases: emphasis, Slack link grammar, bounds, an image reference left whole), and a companion-only credential (known only to the context redactor) split across chunks is masked on the reply stream and in the posted reasoning; a synthetic turn is not echoed but still answered; a slash turn reaches Slack not at all; a Slack-born message is not echoed back and its picture is not re-uploaded; a dashboard-pasted picture travels with the echo; an agent-drawn chart travels with the reply; thinking followsslack.show_thinking; a paused mirror silences everything; a crash mid-tool still completes the card and stops the stream; the approval prompt is posted once throughpost_linked_approvaland the renderer posts no card of its own; a markdown-split key in a tool title or purpose never reaches the card from the dashboard mirror or from the nativedispatchpath, and safe titles keep their 75-character bound.requires_symlinks); the linked-ancestor, swapped-root and linked-uploads/tests build their links withmake_dir_link(a junction on Windows) and never skip.chat_runner; the backfill no longer formats rows by hand.0o600, the suffix follows the sniffed type, the row carries the markdown form, the prompt encoder finds the path inside the markdown, an opaque file keeps the temp behaviour, images stay temp without the flag,process_slack_filesopts in.Updated:
test_queue_edit.py(an edited Slack-ingress entry loses the tag; an untagged one is unaffected),test_source_corpus.py(the blocking-on-loop corpus ceiling moves 907→909 for the two newasync-bearing modules,uploads.pyanddashboard/slack_mirror.py, the same way #16224 moved it forchat_turn/),test_chat_runner_composition_contract.py(the runner no longer bindsPostedOptions;_run_chatgains_ingress),website/src/test/fileTokens.test.ts(walks the shared destination table),test_slack_events_coverage.py(a promoted image is a markdown row that survives the turn while an opaque temp file is still cleaned; a message bound for a linked slot always promotes, restricted or not, while a Slack-native thread with the durable flag or the same-message token keeps its images temporary, a single-session DM reads its flag under the flatslack:<channel>key the turn runs under (and the per-thread key alone would miss it), a bang command on a linked thread takes the native rule, a mentioned bang command is classified on the mention-stripped text the router reads, and the predicate fails closed; patchedprocess_slack_filesstubs returnIngestResult),test_slack_files.py(flattened-view shim overIngestResult),test_dashboard_chat.py(the recovery-reply test reads every reply sink the renderer may use),test_slack_options_lifecycle.py(owner-resolution pin re-anchored onon_done),test_handler_link_intercept.py,test_slack_handler_coverage.py,test_slack_handler_more_coverage.py,test_conn_recovery.py(theingress/_ingresskeyword).Gates run locally on this head (rebased onto
mainatf16fa23ec): the changed and adjacent backend test files by path with-n0(test_slack_one_renderer.py,test_outbound_files.py,test_dashboard_chat.py,test_chat_runner_composition_contract.py,test_chat_runner_coverage.py,test_cross_surface_mirror.py,test_slack_events_coverage.py,test_slack_files.py,test_slack_handler*.py,test_slack_renderer.py,test_slack_options_lifecycle.py,test_session_control.py,test_messaging_attachments.py,test_markdown_link_parentheses.py, the sibling transports' outbound-file tests: 30 files, 5,176 passed, 0 failed on the tree rebased ontoecb30c2ad; after the final rebase ontof16fa23ec, whose seven new commits touchchat_runner.pyandstate.pyamong this PR's files, the nine files covering the renderer, the extractor and the dashboard turn loop were re-run, 1,940 passed); CI'sisort --check-only,flake8andmypy src/kiro_crew/(2,081 files, clean); the baselined black gate; the comment-history, changelog, feature-map, brand, harness-parity, focus-cue, memory-store-seam, sync-io, agent-sdk-boundary, subprocess-encoding, loop-bound-locks, builtin-skill-scope, testpaths-coverage, cwd-relative-reads, decisions-history and docs-lint guards; websiteeslinton the changed test,typecheck, andvitest run src/test/fileTokens.test.ts(122 passed). Mutation checks: re-resolving the root at read time reddens the swapped-root test, and dropping the denylist consult reddens the denylist test.Manual verification
The screenshot below was produced end to end from the inbound path:
ingest_attachments(persist_images=True)was run against an isolated gateway home (its ownKIROCREW_HOME) with a fake downloader supplying a real PNG, which landed at<home>/uploads/<uuid>_Screenshot_2026-09-12_at_09.38.44.pngwith0o600;append_attachment_contextproduced the row…\n; the row was imported into that gateway throughPOST /api/chat/slots/import. The dashboard frame renders that exact row with that file's real bytes. Slack itself cannot be screenshotted from this environment; the renderer tests above are the evidence for the Slack side, and I can attach a live Slack capture on review if asked.Screenshots / video
Dashboard transcript rendering the Slack-origin image (dark):
Light theme
The frame was captured with the repo's transcript capture shell (
website/capture/chatpage-scroll-shell.html, the realChatPageover a mocked API, the same harness the repo's other transcript screenshots use), with/api/file-rawserving the promoted file's bytes; the capture asserts the<img>decoded and that no raw, so the render goes through the capture shell rather than that gateway's own port. There is no Slack screenshot: see Manual verification.Related Issues
no linked issue: requested directly as a one-PR change against the merged session-address-model RFC (#4294).
Checklist
feat|fix|docs|refactor|perf|test|chore|ci|build|revert: ...)docs/system-specs/modules/slack-gateway.md: image flow, temp lifecycle, linked-thread sync,SlackRendererroots)