Repository navigation
Conversation
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks: Reconnect is added beside restart, and no default changes. The 300 s held-work give-up and its notices go further than the Goal, which is only to apply saved credentials. Notes
What this change shipsInventory (10 items) — 9 justifiedIntent: let an owner apply newly saved Slack credentials with one click instead of restarting the gateway. This is an ADDITION.
[FIRST-PRINCIPLES-REVIEWED] dc9ded5 Description read[DESCRIPTION-READ] 9162f90bafc2d02e7e4506fed06884b491e5cf10fe699b03bd39573403686651 That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS No design-level blocker. The route fixes the stated cause in place: credentials are read once at boot and a flag stays false after a failed connect. It stays out of Notes
[DESIGN-REVIEWED] dc9ded5 Description read[DESCRIPTION-READ] b9733635fabd014e456576e8394b6cb6ffa1ef09514983dcf10b564ab227a621 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 |
UX Review (Opus 5.5) — ✅ PASS (a BLOCK with no Trigger and no Outcome does not block)UX-level review of UX-Verdict: PASS cannot evaluate: missing the "Slack: message not delivered" dashboard notification and the "slash command applies after a gateway restart" save-row line. No supplied screenshot shows either one. Evidence gaps
Notes
[UX-REVIEWED] dc9ded5 Description read[DESCRIPTION-READ] 90748dcc276afb163cd26aba68030c865e3b234146ffd46ac8183d17c6c1bf46 That sha256 names everything this verdict read: the PR description, plus the 11 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 Review detailsNo findings. Notes:
[OPUS-REVIEWED] dc9ded5 Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — 🔴 changes requested (blocking)GPT 6.1 found at least one blocking issue that must be resolved before merging This comment is updated in place on each push. BLOCKING -- src/kiro_crew/slack/reconnect.py:428 -- An unconfirmed workspace pin permits switching with queued work
BLOCKING -- website/src/pages/settings/SlackPanel.tsx:349 -- A refused workspace switch is displayed as successful
[BLOCK-MERGE] dc9ded5 Adjudication (Opus 5.5) — is blocking on each finding proportionate?F1 (
Only then does F2 ( 🏷️ Fenced finding(s) machine-flagged as likely edge caseThe security fence keeps these findings blocking regardless of adjudication; the only clearance path is a human override. The annotate-only pass judged the condition combination each one requires extreme, and pre-drafted the override rationale below. A repository writer must independently verify a rationale before posting it — it is machine-authored, and a wrong override on a security-class finding ships exactly the class the fence exists to stop.
Replace False positive or not applicable? A repository writer can comment: |
c78441a to
e6a6dda
Compare
|
Review round on
Gates: the comment-history markers are reworded, the Semgrep logger message no longer says "token", and the two fixed sleeps in the tests are now |
e6a6dda to
1b41bae
Compare
|
GPT 6.1 Review on
|
1b41bae to
987e540
Compare
|
GPT 6.1 Review on
|
3224902 to
4926e11
Compare
4926e11 to
bdccd57
Compare
bdccd57 to
c9ac806
Compare
…t a restart POST /api/slack/reconnect re-reads the saved Slack credentials and re-runs the Socket Mode handshake on the gateway loop, recomputing _slack_enabled first. Settings > Slack gets a Reconnect button, and a credential save points at it instead of a gateway restart. A reconnect never switches workspaces in place.
|
Head ad82bf2: (1) GPT 6.1 F1 (failed reconnect drops attachments): when a reconnect fails and no client can fetch the files, the router no longer delivers the caption alone or returns silently; the owner gets the same 'message not delivered' notice the held-work give-up sends (events_queue.notify_slack_undelivered). Test: test_attachments_a_failed_reconnect_cannot_fetch_are_noticed (caption and file-only). (2) Bundle Size Gate: the Reconnect UI took SettingsPage from ~498.8 KB on main to 501.0 KB (500 KB default); added a measured SettingsPage entry in CHUNK_BUDGETS, 527 KB (~5% headroom), with attribution in the comment. |
|
Head 855366f: GPT 6.1 F1 (heartbeat result dropped during a reconnect) is the same class as the attachment finding, so it is fixed the same way: _deliver_result waits for a running reconnect before Slack-bound delivery and reads the published client once; if the attempt fails, a Slack-only result becomes a dashboard notification instead of vanishing (the slack: and default arms already notify). Test: test_slack_only_arm_waits_out_a_reconnect (connected and failed). Also adds notify_slack_undelivered to the slack.events facade manifest (the facade tests that went red on ad82bf2). |
|
Holding this head (855366f): two fix rounds are spent, and the two new blocks are new findings, not regressions of the earlier fixes. Both look valid and both sit in this PR's own Reconnect path: (1) GPT 6.1: the replacement RealSlackClient never gets agent_sessions.status.configure(orch), so native session status and Stop buttons go quiet after a reconnect until restart. (2) Opus 5.5: a boot pin left unconfirmed by a transient probe failure (_slack_team_id empty) makes every same-token reconnect fail as workspace_switch_needs_restart, after _close_socket has already torn the socket down. Next round should take both together. |
…the boot pin Boot pins its workspace only when it published a Web API client, either as orch.slack or as the dashboard's copy (init_socket_mode can clear orch.slack alone). A leftover bot token without its app token pins nothing, so a reconnect can adopt the workspace the user saves. The boot workspace probe releases the pin only for a token that never authenticated (invalid_auth, not_authed) with no Slack work admitted; a revoked or expired token keeps it. While a reconnect runs with no client published, the Slack queue drains and the inbound route keep their entries queued instead of dispatching them, and a connected reconnect starts them again. A reconnect that retires a published client and fails keeps that hold for the next reconnect (the retry) for HELD_WORK_GIVE_UP_SECS; when the window ends with no client, each held message leaves its queue and the owner gets one dashboard notification naming its channel and timestamp, and the hold is released. A gateway no reconnect took a client from handles a missing client as on main. A drain that does dispatch hands _dispatch_queued the client it read in the same step as the dequeue. An inbound message with attachments waits for a reconnect in progress and ingests with one client read before ingestion (process_slack_files and _transcribe_files take slack=).
|
Handing this to a maintainer at head dc9ded5. That was our last fix round: it attaches the agent-session driver on reconnect and moves the workspace check ahead of the socket teardown, and Opus 5.5 now passes. CI is green. GPT 6.1 still blocks, and both findings are open:
|
|
[operator: bolichen97] Continuing this in #32304; thanks for the start. |
Problem / Motivation
Goal: Slack credentials saved from Settings take effect with one click, without restarting the gateway.
Slack's tokens and owner ID are read once, when the gateway orchestrator is built. Saving new ones from Settings → Slack (
PUT /api/slack/config) writes them to the credential store, but the running Socket Mode client keeps the old ones, and the panel's only advice is "restart the gateway".POST /api/restartexecvs the whole process, so every in-flight agent run, task-runner step and cron is torn down to redo one websocket handshake.Why it matters
First-run Slack setup is where a token typo or a missing owner ID happens. The issue's reporter ran for hours with no Socket Mode client because the owner ID was missing at boot; re-entering it in Settings reported success and changed nothing. With Reconnect, the fix is one click and the outcome shows on the same screen.
Not a goal
POST /api/restart, or the slash command's restart requirement (it is registered in the Slack app manifest).restart_channel.Intended? / Repro
Intended? No. Nothing documents a restart as the required way to apply a Slack credential. Every registry channel already restarts in place on a config change (
src/kiro_crew/slack/gateway_runtime/channel_lifecycle.pyrestart_channel); Slack is the one channel left out. The_connect_slackdocstring (channel_lifecycle.py:251) records "no background retry of the initial connect" as a known gap, not a design decision.Repro (read on current main,
a29bae7df7):src/kiro_crew/slack/gateway_runtime/orchestrator_init.py:86and:103assign_owner_idand_slack_enabledonce, in the constructor. Nothing reassigns them later.src/kiro_crew/slack/events.py:183returns early when_slack_enabledis false, and:188/:217set it false on a missing owner or a refused workspace. So once boot failed, no in-process retry could ever connect.src/kiro_crew/dashboard/routes/messaging.py:23-25registers onlyGET/PUT /api/slack/configandGET /api/slack/manifest. There is no reconnect route.src/kiro_crew/dashboard/messaging_api/slack_settings.py:350returnsrestart_requiredfor every credential write (channel_folders.py:98), andwebsite/src/pages/settings/SlackPanel.tsx:83tells the user to restart the gateway.KIROCREW_OWNER_IDunset logsKIROCREW_OWNER_ID is not set — Slack disabled for security. Saving the owner ID in Settings answers "Saved. Restart the gateway to apply.", and Slack stays down until a restart (before frames below).What changed (motivation → approach → change)
Symptom: a saved Slack credential needs a full gateway restart. Cause: the credentials are hoisted once, and the socket init returns early on a sticky flag. Change: one route that redoes the Slack part of a restart, in place.
Backend
src/kiro_crew/slack/reconnect.py(new),reconnect_slack(orch):.envwrite. A store that cannot be read raisesCredentialStoreUnreadable, and the running connection is left alone.DashboardState.owner_id(owner notices DM this owner). It then recomputes_slack_enabledfrom the tokens and re-awaitsinit_socket_mode+_connect_slackon the gateway loop. The socket client must be built on a thread with a running loop. The bootSeenCacheis reused, so redelivered envelopes are still dropped.slack_socket_connected/slack_connect_errorwhereGET /api/slack/configreads them, and runs the same tracked-channel probe boot runs after connecting.tokens_missing,owner_id_missing,enterprise_validation_failed,denied_by_policy,workspace_switch_needs_restart. Slack API codes such asinvalid_authpass through. An unexpected exception leaves Slack down with its class name. It never leaves a half-built socket.asyncio.shield), so a double click never races two handshakes, and a caller that goes away does not cancel the attempt.auth.testteam of the Web API client it published (boot:pin_boot_workspace→record_connected_workspace, fire-and-forget). Boot counts as having published a client when eitherorch.slackor the dashboard'sslack_clientcopy is set, sinceinit_socket_modecan clearorch.slackalone while dashboard senders keep the copy; a boot that published neither, such as a leftover bot token without its app token, pins nothing. If a later reconnect's bot token belongs to another team, or that team could not be confirmed, Slack stays off withworkspace_switch_needs_restart. A gateway that never connected adopts whatever workspace the saved token names. While a reconnect runs with no client published, the three Slack queue drains (_on_done,_on_transport_done,_drain_slack_queue) and_route_messagekeep their entries queued instead of dispatching them into the cleared client (events_queue.hold_if_slack_down), and a connected reconnect starts the held keys again (resume_held_slack_drains). A reconnect that retires a published client and fails keeps that hold (_slack_client_lost) for the next reconnect, the retry, forHELD_WORK_GIVE_UP_SECS(300 s). If that window ends with no client, the hold gives up (events_queue.give_up_held_slack_work): each held message leaves its queue, its deferred temp files are unlinked, and the owner gets one dashboard notification (dashboard_state.notify, "Slack: message not delivered") that names the channel in words (a tracked channel's saved name, "a direct message", else "a Slack channel") and quotes the first 80 characters of the message, or says it was a voice memo or an attachment. Raw Slack ids, timestamps and user ids stay out of the body (they are in the notice'smeta). Then the hold is released. A gateway no reconnect took a client from (no reconnect, or one on a gateway that never published a client) handles a missing client exactly as on main;test/test_events_forward.pyis unchanged. A drain that does dispatch passes_dispatch_queuedthe client it read in the same step as the dequeue (slack=keyword), so a reconnect that clearsorch.slackduring the reaction removal cannot hand the turn aNoneclient. The closed predecessor ran into a design conflict on exactly this subsystem (a workspace-switch sweep vs. thread-eviction safety); refusing the switch avoids that conflict and needs no new state file.POST /api/slack/reconnect(dashboard/messaging_api/slack_settings.pyapi_slack_reconnect, registered beside the PUT indashboard/routes/messaging.py). It sits behind the same dashboard token auth + CSRF as the PUT and is direct-local only (is_direct_local_request, remote → 403remote_read_only). 503slack_reconnect_unavailablewhen no gateway owns the socket (API-only server); 500credential_store_unreadable. Answers{connected, connect_error}, the pair the GET already reports. SEL access logslack.reconnect.PUT /api/slack/confignow returnsreconnect_requiredfor a token/owner write and keepsrestart_requiredforcommandonly.service_boot.pykeeps the bootSeenCacheon the orchestrator and setsDashboardState.slack_reconnectafter dashboard init.orchestrator_init.py/gateway.pyinitialize and declare the four reconnect fields.handlers/messaging.pyandhandlers/__init__.pyexport the route.Frontend (
website/src/pages/settings/SlackPanel.tsx,api/client/messaging.ts)RefreshCw) in the panel header beside the status pill, hidden on read-only remote sessions like Save. Pending: "Reconnecting…", disabled. Success: "Connected to Slack." and the pill flips (the GET is refetched). Decline: "Reconnect failed: ", where the reason comes from onedescribeConnectErrormapper shared with the recorded boot failure, so the same failure reads the same way either way. A gateway refusal shows its own reason. A request that never reached a gateway is "Reconnect failed. Is the gateway running?".slackPanelkeys inen.manual.json, the 11 translated catalogs and the regenerateden-XA, plus twoen.context.jsonentries. Four restart-only keys that nothing reads any more are removed from every catalog.Docs:
docs/system-specs/modules/messaging.md(Slack settings API) anddocs/feature-map/README.md.Supersedes #14574, which was 3292 commits behind main after the messaging handlers moved into
messaging_api/*. This is a smaller redo for the current layout. It drops the predecessor's workspace-switch machinery (state file, link sweep, generation fence, client affinity), which its own review left as an open design question.Security
The new route changes which credentials the gateway's Slack connection uses, so it takes the PUT's exact guards: dashboard token auth, the CSRF middleware, and the direct-local check (loopback peer, no forwarding headers). It is registered in the dashboard route block, not the token-less API-only route set. The dashboard listener is unchanged (loopback bind). The reconnect never widens access: a declined attempt clears the previous owner from the handler allowlist and from
DashboardState, and no Web API client is published without a connected, gate-admitted socket. The response carries only a short reason code, never a token.Backwards compatibility
reconnect_required) on the PUT. An existing client that reads onlyrestart_requiredseesfalsefor a pure credential save; the restart it would have offered is no longer needed.POST /api/restartis untouched and still works.Tests
Backend,
test/test_slack_reconnect.py(new, 49 tests):_slack_enabledand hoists the new tokens/owner (also handler owner +DashboardState.owner_id); red on main, which has noreconnect_slackinit_socket_modeon the running loop with the bootSeenCachetokens_missing,owner_id_missing(previous owner cleared), Slackinvalid_authpassthrough,enterprise_validation_failed,denied_by_policy, failed handshake (socket retired), close that raises, unexpected exceptionrecord_connected_workspacereads the socket's client, and leaves the team unknown on failureorch.slackis cleared mid-dispatchtokens_missing) is held by the turn-end drain and delivered once, with the new client, when the retry connectstest/test_slack_config_handlers.py: a credential save flagsreconnect_required, notrestart_required; a command change still flagsrestart_required.test/test_handlers_messaging_composition_contract.py: package re-export count 59 → 60.test/test_slack_events_coverage_route_flow.pyandtest/test_stop_clears_only_its_own_sender_slack.py: their_dispatch_queuedfakes accept the newslack=keyword.Frontend,
website/src/test/SettingsSlackPanelCoverage.test.tsx: existing wording assertions updated, and a newReconnectblock covering success, pending (disabled, recorded failure off screen), a decline worded like the recorded failure as the only notice, each named decline, the gateway's 503/500 refusals, a network error and an unstructured 5xx, the save-row button surviving a config-only save and a failed reconnect and retiring on success, the slash-command restart line, and the button hidden on read-only.ApiClient.refactor.surface.test.tslistsreconnectSlack.Known unrelated:
website/src/test/kiroUsageRefetchInterval.test.ts:92fails on main too. It expects 'api-key' for reason 'api_key_auth', andwebsite/src/api/kiroUsage.tshas no branch for it (from #22387 and #25434). This backend-only change does not touch either file.Proof: not provable -- other: this host runs no local tests; CI runs them
Manual verification
Static gates run locally on the changed files: black 26.10.1, isort, flake8, mypy 1.14.1;
tsc -p tsconfig.app.json, eslint,I18N_BASE_REF=origin/main node scripts/i18n-check.mjs,gen-ui-index --check, the theme/phantom-class/restyle lints;scripts/check_comment_history.py,check_feature_map.py,check_file_line_cap.py,check_sync_io_in_async.py,check_loop_bound_locks.py. Tests run in CI.Screenshots come from an isolated capture page (real
SlackPaneland stylesheet,apiSlack seams stubbed, vite on 127.0.0.1). Before frames use the same page on a detachedmainworktree. Not committed.Screenshots / video
Before (main): the recorded failure says to restart the gateway, and there is no Reconnect.
Before (main): a credential save answers "Saved. Restart the gateway to apply."
After: the recorded failure points at the header Reconnect button.
After: pending, the button reads Reconnecting… and is disabled, and the recorded failure steps aside.
After: the click's decline, labelled as its outcome.
After: connected, the pill flips and "Connected to Slack." shows.
After: a credential save points at Reconnect, with the button beside the confirmation.
Related Issues
Fixes #10306
Supersedes #14574
Sibling sweep
Swept: git grep -n "_slack_enabled = |restart_required|init_socket_mode" -- src/kiro_crew/slack src/kiro_crew/dashboard/messaging_api
Sibling: src/kiro_crew/slack/gateway_runtime/channel_lifecycle.py
restart_channel-- not affected (registry channels already restart in place)Sibling: src/kiro_crew/dashboard/messaging_api/discord_settings.py and the other channel savers -- not affected (their credential writes restart the channel through the config applier)
Sibling: src/kiro_crew/slack/gateway_runtime/service_boot.py -- changed here (boot keeps the SeenCache and records the connected workspace)
Pattern harvest
Rule candidate: review-prompt
Pattern: a "retry" entry point that re-calls an init routine guarded by a sticky enabled/failed flag must recompute the flag from current inputs first, or the retry is a silent no-op.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributed under the project's Apache-2.0 license.