Skip to content

batch(2026-07-05): Slack multi-org, region filtering, mail-checker hang fixes, live-status dot - #100

Merged
fclairamb merged 78 commits into
mainfrom
batch/2026-07-05
Jul 5, 2026
Merged

fclairamb merged 78 commits into
mainfrom
batch/2026-07-05

Conversation

@fclairamb

@fclairamb fclairamb commented Jul 5, 2026 •

Copy link
Copy Markdown
Owner

Summary

This batch fixes a live production incident (mail checkers hanging the check-worker fleet) and adds several related features, implemented via /implement-todos with an independent completeness audit per spec before archiving.

Independently audited clean and archived:

  1. Slack multi-org (1/2): org-scoped installs — fixes a security bug where the unauthenticated Slack install endpoint honored org/channelUid params, plus a connection collision when one Slack workspace is installed into multiple orgs.
  2. Slack multi-org (2/2): inbound routing + uninstall fan-out — fixes ~13 inbound call sites (events, slash commands, mentions, interactions) that resolved the wrong org for a multi-org-connected workspace; uninstall now cleans up every org's connection instead of one at random.
  3. Check detail: Recent Results region column — the region column always rendered "-"; the fetch now requests the field it was already dropping.
  4. Response Times chart: per-region filtering — lets a user isolate one region's data instead of a merged, sawtooth-looking series across regions with very different baseline latencies.
  5. Mail checkers connection deadlines (root cause of the incident) — checkimap/checkpop3/checksmtp now set a socket deadline after dial, so a silent TLS-only endpoint times out cleanly instead of hanging the check forever.
  6. Checkworker runner watchdog — a hung or panicking checker can no longer permanently consume a worker goroutine or crash the process; abandoned executions are logged, counted, and surfaced as a clean timeout result.
  7. IMAP/POP3 default implicit TLS from the port — checks on port 993/995 with no explicit tls/starttls now default to implicit TLS (matching the existing checksmtp precedent), fixing the exact misconfiguration that triggered the incident; dashboard forms gained TLS/STARTTLS controls they didn't previously have, with a port↔TLS auto-toggle affordance.
  8. Sidebar live-connection status dot — a small green/gray/red indicator in the sidebar footer showing real-time WebSocket connection health. This spec appeared mid-batch from a separate concurrent session; implementation and merge are complete, but the coordinator's independent completeness audit was interrupted before reaching a final verdict, so its spec file is still in specs/todos/ rather than specs/done/. Worth a follow-up look before considering it fully closed out, though the interrupted audit had already verified nearly everything as ✅ (state machine, component, i18n, edge cases, unit tests) — the only open item was an E2E fixture issue that looked environmental rather than a real defect.

Test plan

  • Each spec independently audited by a fresh read-only agent against the merged code (not the implementing subagent's own self-report) before being archived — see individual spec files under specs/done/2026/07/ for what was verified.
  • make build-backend lint-back test green throughout.
  • make build-dash0 + dash0 eslint green with no new errors introduced (pre-existing ~45-error baseline unchanged).
  • make build-docs green.
  • Spec 04's regression tests independently proven to hang on the pre-fix code (via an isolated git worktree at the pre-batch commit) and pass post-fix.
  • Spec 05's race-detector and goleak results independently reproduced.
  • Spec 07 (sidebar live-status dot): E2E suite run was flagged as having a possibly-environmental fixture issue when run in full sequence — worth re-confirming.

🤖 Generated with Claude Code

fclairamb and others added 30 commits July 5, 2026 02:24
Placement changed from the main page header to the sidebar footer
utility row (next to LanguageSwitcher/ThemeToggle) to avoid overloading
the header.

Co-Authored-By: Claude Fable 5 <[email protected]>
Returns every non-deleted connection matching a settings property across
all orgs, ordered created_at ASC. Backs the Slack inbound-routing
deterministic fallback and app_uninstalled fan-out (spec 2026-07-05-02).
GetConnectionByTeamID is the single choke point every inbound handler
(mentions, slash commands, events, interactions, GetClient) goes through.
Reworked to: (1) prefer the org recorded in organization_providers for the
team (home org, first-install-wins — same org Marketplace/Sign-in-with-Slack
already land in), (2) fall back to the oldest connection (created_at ASC)
when there's no home org or its own connection was deleted, logging a
warning when more than one connection exists so ambiguity is observable.

Fixes the random-org bug where a workspace connected to two orgs would have
commands land in whichever row an unordered Scan happened to return.
Uninstalling the Slack app revokes the bot token for the whole workspace,
so every org's connection for that team_id shares the same now-dead
credentials. HandleAppUninstalled now loops ListChannelsByProperty and
soft-deletes each one, instead of deleting only the first row an
unordered lookup happened to return — the other orgs no longer keep
rendering a stale "connected" integration after uninstall.
Root cause: ListChannels unconditionally filtered
Where("organization_uid = ?", filter.OrganizationUID); CountInstalledTeams
called it with no OrganizationUID set, so the empty string matched zero
rows on both engines and the Socket Mode status snapshot silently always
reported 0 installed teams. Made the org filter conditional on a non-empty
OrganizationUID (every other ListChannels caller already passes a real org
UID, so this is a no-op for them) so an org-less filter genuinely lists
across all orgs.

CountInstalledTeams now lists globally and dedupes by settings.team_id,
so a workspace connected to two orgs counts once, matching what a single
Slack Socket Mode connection actually represents.
golangci-lint's typecheck failed because mockDBService (used only by
notifications tests) no longer satisfied db.Service after adding
ListChannelsByProperty to the interface. Stubs with the same
panic("not implemented") pattern as its neighboring methods, since no
test in this file exercises it.
Add a dedicated, minimal test for the spec's exact wording ("Socket Mode
status reports 1 installed team for a two-org workspace") rather than
relying only on the broader three-connection dedup test's arithmetic.
…s (2/2): inbound routing and uninstall fan-out

Reworks GetConnectionByTeamID (the single choke point every inbound Slack
handler goes through) to resolve to the workspace's home org first, with a
deterministic oldest-connection fallback, so commands/mentions/interactions
no longer land in a random org for a multi-org workspace. Fans out
app_uninstalled cleanup across every connected org's connection, and fixes
CountInstalledTeams to count distinct workspaces instead of connection rows
(which also fixes a latent bug where it silently always returned 0).
fclairamb added 21 commits July 5, 2026 10:04
…r panicking checker must never take down the fleet
…flag

The plain bool captured by the child goroutine's closure was written
by the select's abandon branch (parent goroutine) and read by the
child's deferred cleanup with no synchronization between them —
go test -race didn't reliably catch it because the child's defer runs
long after the write in the tests, but it is a genuine race under
different scheduling. Switched to atomic.Bool.
…— a hung or panicking checker must never take down the fleet
… panicking checker must never take down the fleet
…ll-known port (and mirror it in the check form)
…m the well-known port (and mirror it in the check form)
Mirrors checksmtp's useImplicitTLS := port == implicitTLSPort && !StartTLS
precedent: when neither tls nor starttls is set on a stored check, port
993 (IMAP) / 995 (POP3) now dials with implicit TLS at execution time
instead of speaking plaintext to a TLS-only endpoint and hanging/timing
out. An explicit tls:true is preserved at any port; an explicit
starttls:true still wins over the port-derived default. Execution-time
derivation only — PATCH semantics and Validate()'s tls+starttls rejection
are unchanged, so existing stored checks start working on deploy with no
edit required.
checkimap/samples.go already sets TLS: true alongside port 993 (verified,
no change needed). The docs site's IMAP/POP3 sections only showed URL
forms (imaps://, pop3s://); add TLS/STARTTLS option rows plus a tip
calling out that a JSON check config should set "tls": true explicitly
with port 993/995, so a reader translating the URL form into JSON
doesn't drop the flag (D3) — independent of the execution-time
derivation, which is a safety net rather than the documented contract.
…o-toggle

The IMAP/POP3 check config forms had no TLS/STARTTLS UI at all (only
host/port/username/password) despite the backend config fully supporting
tls/starttls — so there was no way to express the settings the new
server-side derivation (checkimap/checkpop3) reasons about.

Split "ssh" out of the shared "ssh"/"pop3"/"imap" case (ssh has no TLS
concept) and add, for pop3/imap only:
- A "Use implicit TLS" checkbox and a "Use STARTTLS" checkbox, reusing
  the tls/startTLS state already shared globally across the form (same
  hooks SMTP/gRPC/Kafka/MQTT/RabbitMQ already use).
- D2's port<->TLS auto-toggle affordance: typing the well-known implicit-
  TLS port (993 IMAP / 995 POP3) auto-checks the TLS checkbox and shows a
  "Port NNN uses implicit TLS." hint; the port input's placeholder
  reflects the current TLS state (993/995 when TLS is on, 143/110
  otherwise) rather than being static. Purely client-side guidance — the
  server derives independently regardless of what the client sends.
- Wire tls/starttls into both existing config-building switches (preview
  useMemo and submit handler).

Add the hint-under-checkbox pattern to the design reference (previously
undocumented) since this fix introduces the first real usage of it.

Extend e2e/checks.spec.ts with two new tests covering the auto-toggle
behavior and the tls:true round-trip through create -> edit.
…e well-known port (and mirror it in the check form)
… TLS from the well-known port

Derives implicit TLS from the well-known port (993 IMAP / 995 POP3) at
execution time when neither tls nor starttls is explicitly set, mirroring
the checksmtp precedent. Existing stored checks (e.g. the o365 webingenia
ones) start working on deploy with no edit needed. Adds symmetric unit
tests for both checkers (derivation logic + a real TLS-listener dial),
adds the previously-missing TLS/STARTTLS UI to the dash0 IMAP/POP3 forms
with a client-side port<->TLS auto-toggle affordance, and spells out
tls:true explicitly in samples/docs so copy-pasted configs stay
unambiguous.
… well-known port (and mirror it in the check form)
Previously gated on authenticated=true (set only after hello), so a
failed connect attempt (server unreachable, close before hello) emitted
no callback at all. A connection-status consumer derived from these
callbacks would show "connecting" forever while attempts fail in a
loop.
Replaces the private globalLive boolean with connecting/live/
reconnecting/disabled, derived getGlobalLive() so useLiveStatus/
useScopeLive and poll stretching stay unchanged, and a new
useLiveConnectionStatus() hook for the upcoming sidebar status dot.
disabled is terminal and sticky at the registry level.
New LiveStatusDot component reads useLiveConnectionStatus() and maps
it to the existing ok/warning/error dot conventions (green/red/gray),
wrapped in the shared Tooltip primitive with data-testid/data-status
for tests. Mounted in the AppSidebar footer utility row alongside
LanguageSwitcher/ThemeToggle; nothing added to the main page header.
Added to the design reference page per the catalog convention.
live/connecting/reconnecting/unavailable labels for the sidebar live-
connection status dot, in common.json alongside the other sidebar-
footer utility strings (switchToDarkMode etc.).
Two new cases in live-updates.spec.ts: the dot shows data-status="live"
once the dashboard is streaming, and it flips to "reconnecting" on a
forced server-initiated close (routeWebSocket pass-through proxy, same
pattern as the existing reconnect-replay test) before the automatic
reconnect brings it back to "live". The reconnecting-state watch is
armed via waitForFunction before navigating, in parallel with the
initial connect/close/reconnect cycle — on localhost that whole cycle
can complete in under a second, faster than a sequential
wait-for-live-then-poll-for-red assertion could ever observe.
…n status dot (green/gray/red)

- live-socket.ts: onDisconnected now fires on every non-permanent close,
  regardless of authentication state, so a status consumer never gets
  stuck showing "connecting" during a run of failed attempts.
- LiveEventsContext.tsx: four-state LiveConnectionStatus
  (connecting/live/reconnecting/disabled) replaces the private boolean;
  getGlobalLive() is now derived so useLiveStatus/useScopeLive and poll
  stretching are unchanged; new useLiveConnectionStatus() hook.
- New LiveStatusDot component in the AppSidebar footer utility row
  (green/red/gray), added to the design reference page.
- i18n liveStatus.* strings in en/fr/de/es.
- Unit tests for the registry state machine and live-socket signaling;
  Playwright coverage for the green and red states via routeWebSocket.
@fclairamb
fclairamb merged commit 35f3aa2 into main Jul 5, 2026
11 checks passed
@fclairamb
fclairamb deleted the batch/2026-07-05 branch July 5, 2026 11:26
@fclairamb fclairamb mentioned this pull request Jul 5, 2026
fclairamb added a commit that referenced this pull request Jul 5, 2026
PR #100's squash commit bundled 8 independently-audited specs behind
one flattened bullet, and PR #104's squash commit used a non-standard
"Batch:" type prefix that release-please's conventional-commit parser
doesn't recognize at all, so its 7 specs were silently absent from
this release entirely. Expand both into their actual constituent
features, sourced from each PR's own itemized description.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
fclairamb added a commit that referenced this pull request Jul 8, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.2.1](v0.2.0...v0.2.1)
(2026-07-08)


### Features

* **dash0:** one-click MCP connector setup — AI assistants page with a
URL-only OAuth flow, per-client icons, shared copy/collapsible code
primitives ([#111](#111))
([d105be4](d105be4))
* **dash0:** Recent activity links directly to the originating
incident/check and shows the channel name; incident lifecycle events
enriched with check UID/name
([#111](#111))
([d105be4](d105be4))
* **entitlements:** SaaS Free-plan defaults now match the billing Free
plan (10 checks, 6/min, no SSO), with a backend-driven
"Free"/"Team"/"Self-hosted" plan display identity
([#111](#111))
([d105be4](d105be4))
* **devloop:** `make dev`/`make dev-test` supervise dash0 and status0
with size-rotated per-process logs instead of unbounded raw output
([#111](#111))
([d105be4](d105be4))


### Bug Fixes

* **checks:** list endpoint no longer overfetches O(retention) raw rows
per check for `lastResult` — one row per check via `DISTINCT ON`
([#111](#111))
([d105be4](d105be4))
* **e2e:** dashboard E2E suite flaked on per-test login contention;
authenticate once per Playwright worker instead of once per test
([#111](#111))
([d105be4](d105be4))
* **db:** embedded-Postgres orphan sweep + watchdog reclaims leaked
dev/test instances left behind by crashed processes
([#111](#111))
([d105be4](d105be4))
* **realtime:** check-detail live subscription used the URL slug instead
of the canonical uid, silently breaking live updates on slug-based check
URLs ([#111](#111))
([d105be4](d105be4))
* **e2e:** hardcoded `localhost:4000` in several spec files ignored
`E2E_BASE_URL`, breaking test runs against non-default servers
([#111](#111))
([d105be4](d105be4))
* **checkworker:** check results fell back to a null region for
default-region checks instead of the executing worker's own region
([#111](#111))
([d105be4](d105be4))
* **notifications:** a malformed notification UID errored on the
Postgres `uuid` column cast instead of rendering the friendly not-found
state ([#111](#111))
([d105be4](d105be4))
* **dash0:** live-socket CONNECTING crash + route-level error boundaries
([#108](#108))
([008c015](008c015))
* **deps:** update go dependencies (non-major)
([#109](#109))
([ec616d4](ec616d4))
* **deps:** update module github.com/oapi-codegen/oapi-codegen/v2 to
v2.7.2 ([#110](#110))
([09d6ad0](09d6ad0))
* **deps:** update module github.com/ohler55/ojg to v1.28.2
([#107](#107))
([335615c](335615c))
* **deps:** update module github.com/wneessen/go-mail to v0.8.0
([#103](#103))
([aa533c1](aa533c1))
* Slack multi-org, region filtering, mail-checker hang fixes,
live-status dot
([#100](#100))
([35f3aa2](35f3aa2))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
This was referenced Sep 8, 2026
fclairamb added a commit that referenced this pull request Sep 22, 2026
…s thread (#420)

## Summary
Pressing **Acknowledge** on a Discord alert rewrote the alert card in
the channel ("✅ #100 … acknowledged by @you") and posted a follow-up —
but into the alerts channel, never into the incident's thread, while
every later follow-up ("Incident resolved", …) lands in that thread. The
comment is a lie in `postAcknowledgmentNotice` (it says "into the
incident's thread" and posts to `interaction.ChannelID`), and the
ack-notice fan-out deliberately skips the origin guild on the promise
that the thread notice already happened (see the doc comment on
`AcknowledgeIncidentFromDiscord`). Net result: nothing about the ack
ever reached the thread.

- `postAcknowledgmentNotice` now resolves the incident's thread from the
forward `incidents/<uid>/discord/thread` state entry the notification
sender wrote at post time, un-archives it first (same dance
`postThreadReply` does for late follow-ups), and posts there.
- Falls back to the channel when no thread is on record (thread creation
denied, DM destination) — same as before.
- The state-entry key constants move to the discord integration package
so the sender and the interaction path share one definition.

## Test plan
- [x] New e2e-style unit test: with a seeded thread state entry, the ack
notice posts into `T-INC-1` (the thread), not `C-ALERTS`
- [x] New test pinning the no-thread fallback to the channel
- [x] `go test ./internal/integrations/discord/...
./internal/notifications/... ./internal/handlers/incidents/...` green;
golangci-lint (v2.13.2) clean on both touched packages
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