Skip to content
Python

OPE-153: the Slack mirror gets the same way out the card has

Devika Verma77a035db8da6
diff --git a/coworker/interactions.py b/coworker/interactions.py
index f40943b8..371f3350 100644
--- a/coworker/interactions.py
+++ b/coworker/interactions.py
@@ -17,7 +17,7 @@ from dataclasses import dataclass
from typing import Optional
from .inbox import KIND_APPROVAL, KIND_QUESTION
-from .tools.ask import option_label
+from .tools.ask import SKIP_SENTINEL, option_label
@dataclass
@@ -56,8 +56,15 @@ def buttons_for(item) -> list[Button]:
if item.kind == KIND_QUESTION and getattr(item, "options", None):
# One button per option; the resolution IS the chosen option's label (what the agent
# gets). Rich {label, description, …} options button as their label.
+ #
+ # Skip trails the options (OPE-153) so the channel has the same way out the card has:
+ # without it, a reader whose answer isn't on the list can only pick a wrong option or
+ # leave the agent suspended. It grants nobody new authority — anyone who can click an
+ # option here could already decide the question — it only adds declining to what they
+ # can already do. Grouped questions stay button-less on purpose: they fall back to the
+ # "(Open the app to respond.)" text, and the app is where their per-question skip lives.
return [
Button(option_label(opt), encode(item.id, option_label(opt)))
for opt in item.options
- ]
+ ] + [Button("Skip", encode(item.id, SKIP_SENTINEL))]
return []
diff --git a/tests/test_ask_user_upgrades.py b/tests/test_ask_user_upgrades.py
index ba18808a..f142d808 100644
--- a/tests/test_ask_user_upgrades.py
+++ b/tests/test_ask_user_upgrades.py
@@ -201,10 +201,30 @@ def test_buttons_use_rich_option_labels(tmp_path):
options=["staging", {"label": "prod", "description": "the real one"}],
)
btns = buttons_for(item)
- assert [b.label for b in btns] == ["staging", "prod"]
+ assert [b.label for b in btns] == ["staging", "prod", "Skip"]
assert decode(btns[1].value) == (item.id, "prod") # resolution IS the label
+def test_mirrored_question_offers_a_skip_button(tmp_path):
+ """OPE-153 — the channel gets the same way out the card has. Skip trails the options and
+ carries the sentinel, which answer_result() turns into a null answer."""
+ store = InboxStore(tmp_path / "inbox.json")
+ item = store.add_question("s1", "Env?", options=["staging", "prod"])
+ skip = buttons_for(item)[-1]
+ assert skip.label == "Skip"
+ assert decode(skip.value) == (item.id, SKIP_SENTINEL)
+ # and that resolution is what the agent ends up seeing
+ assert answer_result(item.questions, SKIP_SENTINEL)["answer"] is None
+
+
+def test_questions_without_options_get_no_buttons(tmp_path):
+ """A free-text question still mirrors as plain text — no lone Skip button, since the
+ "(Open the app to respond.)" fallback is the only way to answer it at all."""
+ store = InboxStore(tmp_path / "inbox.json")
+ item = store.add_question("s1", "What should I name it?")
+ assert buttons_for(item) == []
+
+
def test_grouped_questions_get_no_buttons(tmp_path):
store = InboxStore(tmp_path / "inbox.json")
fields = question_item_fields(
diff --git a/tests/test_interactions.py b/tests/test_interactions.py
index 993dea2a..64994e36 100644
--- a/tests/test_interactions.py
+++ b/tests/test_interactions.py
@@ -5,6 +5,7 @@ import json
from coworker.inbox import InboxStore
from coworker.interactions import Button, buttons_for, decode, encode
+from coworker.tools.ask import SKIP_SENTINEL
from coworker.connectors.base import InteractionEvent
from coworker.connectors.senders import _slack_blocks
from coworker.providers import ModelCapabilities, ProviderClient
@@ -39,8 +40,10 @@ def test_buttons_for_kinds(tmp_path):
q = st.add_question("s1", "Which region?", options=["us-east-1", "us-west-2"])
qb = buttons_for(q)
- assert [b.label for b in qb] == ["us-east-1", "us-west-2"]
+ # Skip trails the options (OPE-153) — the channel gets the card's way out too.
+ assert [b.label for b in qb] == ["us-east-1", "us-west-2", "Skip"]
assert decode(qb[0].value) == (q.id, "us-east-1") # resolution IS the option text
+ assert decode(qb[-1].value) == (q.id, SKIP_SENTINEL)
# free-text question (no options) and notifications get no buttons → "open the app"
assert buttons_for(st.add_question("s1", "Say something")) == []