Commit Graph

10 Commits

Author SHA1 Message Date
Ben Barclay b521fd9dc9 docs(relay): finish the QA-N scrub in the new relay test files
The earlier scrub covered adapter.py; nine internal QA-campaign tracker IDs
remained in the two new test files, including a module docstring and an
assertion message. They mean nothing to a future reader — describe the
behavior instead. Comments only, no assertion changes.
2026-07-29 12:03:01 -07:00
Victor Kyriazakos 277fc97a0a feat(relay): dm_top_level_threads_as_sessions escape hatch — native session-keying parity
Review finding: native gates per-message DM sessions behind
platforms.slack.extra.dm_top_level_threads_as_sessions; the relay lane
coupled session keying to reply_in_thread alone, so 'threaded replies +
one rolling session' was expressible on native but not here.

Adds the same knob to the relay subset (platforms.relay.extra.slack.
dm_top_level_threads_as_sessions, default true = per-message sessions,
unchanged behavior). false keeps thread-per-message reply placement but
skips the session stamp — one rolling DM session, legacy steer posture.
TDD: opt-out + default-unchanged tests written first.
2026-07-28 11:42:51 +00:00
Victor Kyriazakos 09c4a1d349 refactor(relay): remove dead _strip_synthetic_dm_thread; pin the run.py anchor-suppression boundary
Review finding (2026-07-28): every path through _strip_synthetic_dm_thread
returned metadata unmodified — the actual strip was removed when prompts
switched to trusting the run.py thread stamp, leaving a 50-line no-op and
four tests that passed against it (verified by reviewer's negative control).

- delete the function + its _send_prompt call site (verbatim pass-through
  with a pointer comment to the single mode authority)
- rewrite the three pass-through tests as end-to-end placement contracts
  (forward run.py's stamp untouched)
- NEW boundary tests pinning run.py._resolve_progress_thread_id itself:
  flat mode suppresses the synthetic self-anchor / preserves real threads;
  thread mode keeps the first-turn self-anchor. This is the cross-module
  coupling the review flagged as unpinned — if the upstream suppression
  regresses, these fail instead of prompts silently threading.
2026-07-28 11:42:51 +00:00
Victor Kyriazakos 85a75f3155 refactor(relay): drop the flat_dm_status knob — liveliness is unconditional; add relay docs page
flat_dm_status was speculative config (rubric violation): no user wants
'make my agent look dead', and the only real consumer of status
suppression was native's placement-contamination guard — which the relay
lane handles structurally (QA-6/7 send-side anchor strip, leak-guard
test), not via preference. Status now anchors whenever an inbound ts
exists, in both modes.

Docs: new website/docs/user-guide/messaging/relay.md — enterprise-only
relay lane page documenting the platforms.relay.extra.<platform> subset
shape (nested wins, flat fallback), the Slack reply_in_thread control,
and always-on liveliness. Kept out of the native slack.md on purpose:
relay controls are not Slack config.
2026-07-28 00:05:41 +00:00
Victor Kyriazakos 9864e00fb4 feat(relay): flat-DM liveliness — status anchors to the triggering ts, replies stay flat (QA-8)
Victor's correction: flat DMs CAN have a live thinking status. setStatus
on the triggering message's ts renders '… thinking'/per-tool phrases in
that message's thread-footer space and clears without leaving a message
artifact. Native suppresses this because ITS reply routing could inherit
the activated thread; the relay lane's flat-mode sends strip their
anchors explicitly (QA-6/7), so the status anchor cannot leak into reply
placement — proven by the new leak-guard test.

send_typing/stop_typing now anchor the status in flat mode too, gated by
platforms.relay.extra.slack.flat_dm_status (default ON; false restores
the fully anchorless posture). Thread mode unchanged.
2026-07-27 23:08:11 +00:00
Victor Kyriazakos 71d5c47e21 fix(relay): per-message sessions for fronted Slack DMs — stamp the inbound ts as session thread (QA-3)
A 2nd top-level DM while a turn was in flight resolved to the SAME
session key and steered the running turn ('Redirected current run')
instead of starting its own. Native SlackAdapter stamps thread_ts =
event.thread_ts or ts on EVERY inbound, so build_session_key isolates
each top-level message; the connector normalizes top-level messages with
thread_id=null and the relay lane never reproduced the stamp.

_stamp_slack_session_thread applies native parity on the inbound bridge:
top-level Slack message + thread-per-message mode => source.thread_id =
its own ts (fresh session, parallel turns). Real thread replies and flat
mode untouched (flat keeps the shared rolling DM session on purpose).

Also introduces the enterprise config shape for relay-fronted Slack:
platforms.relay.extra.slack.<subset of native Slack fields> (nested
object wins; legacy flat extra.reply_in_thread still honoured). All
reply_in_thread reads (send/typing/stop_typing/run.py progress) now
route through one resolver.
2026-07-27 23:08:11 +00:00
Victor Kyriazakos 467534b43e fix(relay): typing/status targets the per-message thread — synthesize the anchor from the inbound ts (QA-1)
Slack's thinking-status line (thread replies footer, plain chat:write —
no assistant scopes needed) is thread-only: the connector's typing case
no-ops without thread_ts. The typing lane's metadata has no anchor for a
top-level DM (base.py builds from source.thread_id = None), so every
status heartbeat was silently dropped — the trace showed typing frames
with meta_keys=['user_id'] only.

Cache the triggering message ts per chat on inbound (_capture_scope) and
synthesize metadata.thread_id on send_typing/stop_typing in
thread-per-message mode, mirroring native send_typing's
_resolve_thread_ts(metadata.message_id). Flat mode unchanged (#18859);
real-thread metadata wins over the cache; the clear frame targets the
same synthesized thread so the status never sticks.
2026-07-27 16:06:43 +00:00
Victor Kyriazakos b493bf63c7 feat(relay): rich Slack status-line parity — advertise supports_status_text, carry live per-tool phrase on typing frames (QA-1)
Native Slack shows dynamic assistant-status text ('Finding answers…',
'is running pytest…') because SlackAdapter sets supports_status_text=True
and renders the set_status_text() phrase in send_typing. The relay lane
advertised nothing, so run.py's live-status lane never fed it phrases and
the connector fell back to the static default.

- supports_status_text: descriptor-gated property (Slack only; other
  fronted platforms keep textless bubbles)
- send_typing: carry the stashed phrase as the typing op's content; omit
  when unset (empty string is Slack's explicit clear, reserved for
  stop_typing). Connector already renders content via
  assistant.threads.setStatus (#154).
2026-07-27 16:06:42 +00:00
Victor Kyriazakos 95103db645 fix(relay): prompts trust the run.py thread stamp — no self-anchor re-derivation (QA-5)
The threading mode (flat vs thread-per-message) is decided once, in run.py's
_resolve_progress_thread_id (reply_in_thread knob), and encoded in the
metadata stamp: flat => no thread_id, threaded => thread_id for the turn
(first turn: == message_id, the synthetic root IS the thread).

_strip_synthetic_dm_thread re-derived the mode with an unconditional
thread_id == message_id strip, exiling approval/clarify cards (and their
resolved-state swaps) to the DM root while progress bubbles honoured the
thread (2026-07-27 mixed-placement report). Trust the stamp instead; flat
mode is unaffected because flat metadata never carries an anchor.
2026-07-27 16:06:02 +00:00
Victor Kyriazakos 08d67792ab fix(relay): post Slack clarify/approval prompts at DM root not in thread
A prompt (approval/clarify) is emitted in reply to the triggering inbound event,
so its metadata carries that event's synthetic DM thread anchor; forwarded to
the connector it threads the Block Kit prompt under the user's message instead
of posting flat at the DM root. Main routes all prompts through the single
_send_prompt prompt-op choke point, so strip the synthetic DM thread anchor
there via _strip_synthetic_dm_thread — preserving real threads (distinct
thread_id), tenant scope (scope_id/slack_team_id), and non-DM/non-Slack chats.
Preserves main's hp1 prompt-codec; no competing ap:/cl: encoding.
2026-07-26 17:20:31 +00:00