refactor: rename imessage_send_thinking to channel_send_thinking for clarity
This commit is contained in:
@@ -192,7 +192,7 @@ def _cmd_channel(args: str, agent: Any, thread_id: str) -> None:
|
||||
|
||||
# Read send_thinking preference from config
|
||||
from ..config import load_config as _load_config
|
||||
send_thinking = _load_config().imessage_send_thinking
|
||||
send_thinking = _load_config().channel_send_thinking
|
||||
|
||||
server = IMessageServer(
|
||||
config,
|
||||
|
||||
@@ -437,7 +437,7 @@ def _main_callback(
|
||||
provider=config.provider,
|
||||
imessage_enabled=config.imessage_enabled,
|
||||
imessage_allowed_senders=config.imessage_allowed_senders,
|
||||
imessage_send_thinking=config.imessage_send_thinking,
|
||||
channel_send_thinking=config.channel_send_thinking,
|
||||
run_name=name,
|
||||
thread_id=thread_id,
|
||||
)
|
||||
|
||||
@@ -179,7 +179,7 @@ def cmd_interactive(
|
||||
provider: str | None = None,
|
||||
imessage_enabled: bool = False,
|
||||
imessage_allowed_senders: str = "",
|
||||
imessage_send_thinking: bool = True,
|
||||
channel_send_thinking: bool = True,
|
||||
run_name: str | None = None,
|
||||
thread_id: str | None = None,
|
||||
) -> None:
|
||||
@@ -197,7 +197,7 @@ def cmd_interactive(
|
||||
provider: LLM provider name to display in banner
|
||||
imessage_enabled: Whether to auto-start iMessage channel
|
||||
imessage_allowed_senders: Comma-separated allowed senders
|
||||
imessage_send_thinking: Whether to forward thinking to channel
|
||||
channel_send_thinking: Whether to forward thinking to channel
|
||||
run_name: Optional run name for /new session deduplication
|
||||
thread_id: Optional thread ID to resume a previous session
|
||||
"""
|
||||
@@ -541,7 +541,7 @@ def cmd_interactive(
|
||||
|
||||
# Auto-start iMessage channel if enabled in config
|
||||
if imessage_enabled and not _ChannelState.is_running():
|
||||
_auto_start_channel(state["agent"], state["thread_id"], imessage_allowed_senders, imessage_send_thinking)
|
||||
_auto_start_channel(state["agent"], state["thread_id"], imessage_allowed_senders, channel_send_thinking)
|
||||
|
||||
try:
|
||||
_print_separator()
|
||||
|
||||
@@ -1289,17 +1289,21 @@ def _setup_imessage() -> bool:
|
||||
return False
|
||||
|
||||
|
||||
def _step_channels(config: EvoScientistConfig) -> tuple[bool, str, bool]:
|
||||
"""Step 7: Select a channel to enable on startup.
|
||||
def _step_channels(config: EvoScientistConfig) -> tuple[str, dict]:
|
||||
"""Step 9: Select a channel to enable on startup.
|
||||
|
||||
Presents a single-select list with "Skip for now" as default.
|
||||
Selecting a channel triggers validation and guided installation.
|
||||
A common "Send thinking panel?" prompt appears after any channel
|
||||
is successfully selected (not when skipping).
|
||||
|
||||
Args:
|
||||
config: Current configuration.
|
||||
|
||||
Returns:
|
||||
Tuple of (imessage_enabled, imessage_allowed_senders_csv, imessage_send_thinking).
|
||||
Tuple of (channel_name, config_dict) where channel_name is
|
||||
"" for skip or e.g. "imessage", and config_dict contains
|
||||
key/value pairs to apply via ``setattr(config, k, v)``.
|
||||
"""
|
||||
# Determine default based on current config
|
||||
default = "imessage" if config.imessage_enabled else "skip"
|
||||
@@ -1308,8 +1312,7 @@ def _step_channels(config: EvoScientistConfig) -> tuple[bool, str, bool]:
|
||||
Choice(title="Skip for now", value="skip"),
|
||||
Choice(title="iMessage", value="imessage"),
|
||||
# Future channels:
|
||||
# Choice(title="Slack", value="slack"),
|
||||
# Choice(title="Email", value="email"),
|
||||
# Choice(title="Telegram", value="telegram"),
|
||||
]
|
||||
|
||||
selected = questionary.select(
|
||||
@@ -1325,9 +1328,11 @@ def _step_channels(config: EvoScientistConfig) -> tuple[bool, str, bool]:
|
||||
raise KeyboardInterrupt()
|
||||
|
||||
if selected == "skip":
|
||||
return False, "", True
|
||||
return "", {}
|
||||
|
||||
# --- iMessage selected — run guided setup ---
|
||||
channel_config: dict = {}
|
||||
|
||||
# iMessage selected — run guided setup
|
||||
ready = _setup_imessage()
|
||||
|
||||
if not ready:
|
||||
@@ -1342,9 +1347,9 @@ def _step_channels(config: EvoScientistConfig) -> tuple[bool, str, bool]:
|
||||
if enable_anyway is None:
|
||||
raise KeyboardInterrupt()
|
||||
if not enable_anyway:
|
||||
return False, "", True
|
||||
return "", {}
|
||||
|
||||
# Ask for allowed senders (indented to align with ✓ status lines)
|
||||
# Ask for allowed senders
|
||||
senders = questionary.text(
|
||||
"Allowed senders (comma-separated, empty = all):",
|
||||
default=config.imessage_allowed_senders,
|
||||
@@ -1355,7 +1360,9 @@ def _step_channels(config: EvoScientistConfig) -> tuple[bool, str, bool]:
|
||||
if senders is None:
|
||||
raise KeyboardInterrupt()
|
||||
|
||||
# Ask whether to forward thinking content to channel
|
||||
channel_config["imessage_allowed_senders"] = senders.strip()
|
||||
|
||||
# --- Common prompt: send thinking (shown for any channel) ---
|
||||
thinking_choices = [
|
||||
Choice(title="On (forward model reasoning)", value=True),
|
||||
Choice(title="Off (only send final responses)", value=False),
|
||||
@@ -1364,7 +1371,7 @@ def _step_channels(config: EvoScientistConfig) -> tuple[bool, str, bool]:
|
||||
send_thinking = questionary.select(
|
||||
"Send thinking panel in channel?",
|
||||
choices=thinking_choices,
|
||||
default=config.imessage_send_thinking,
|
||||
default=config.channel_send_thinking,
|
||||
style=WIZARD_STYLE,
|
||||
qmark=f" {QMARK}",
|
||||
use_indicator=True,
|
||||
@@ -1373,7 +1380,9 @@ def _step_channels(config: EvoScientistConfig) -> tuple[bool, str, bool]:
|
||||
if send_thinking is None:
|
||||
raise KeyboardInterrupt()
|
||||
|
||||
return True, senders.strip(), send_thinking
|
||||
channel_config["channel_send_thinking"] = send_thinking
|
||||
|
||||
return "imessage", channel_config
|
||||
|
||||
|
||||
# =============================================================================
|
||||
@@ -1516,10 +1525,10 @@ def run_onboard(skip_validation: bool = False) -> bool:
|
||||
_step_mcp_servers()
|
||||
|
||||
# Step 9: Channels
|
||||
imessage_enabled, imessage_allowed_senders, imessage_send_thinking = _step_channels(config)
|
||||
config.imessage_enabled = imessage_enabled
|
||||
config.imessage_allowed_senders = imessage_allowed_senders
|
||||
config.imessage_send_thinking = imessage_send_thinking
|
||||
channel_name, channel_config = _step_channels(config)
|
||||
config.imessage_enabled = (channel_name == "imessage")
|
||||
for key, value in channel_config.items():
|
||||
setattr(config, key, value)
|
||||
|
||||
# Confirm save
|
||||
console.print()
|
||||
|
||||
@@ -87,7 +87,7 @@ class EvoScientistConfig:
|
||||
# Channel Settings
|
||||
imessage_enabled: bool = False
|
||||
imessage_allowed_senders: str = "" # comma-separated, empty = allow all
|
||||
imessage_send_thinking: bool = True # forward thinking to channel
|
||||
channel_send_thinking: bool = True # forward thinking to any channel
|
||||
|
||||
|
||||
# =============================================================================
|
||||
|
||||
@@ -542,7 +542,7 @@ def display_final_results(
|
||||
|
||||
if state.response_text:
|
||||
# Strip trailing standalone "..." lines
|
||||
clean_response = state.response_text.rstrip()
|
||||
clean_response = state.response_text.strip()
|
||||
while clean_response.endswith("\n...") or clean_response.rstrip() == "...":
|
||||
clean_response = clean_response.rstrip().removesuffix("...").rstrip()
|
||||
console.print()
|
||||
@@ -721,7 +721,7 @@ def _run_streaming(
|
||||
show_tools=True,
|
||||
)
|
||||
|
||||
return state.response_text or ""
|
||||
return (state.response_text or "").strip()
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -803,11 +803,11 @@ async def _astream_to_console(
|
||||
|
||||
# 4) Response
|
||||
if state.response_text:
|
||||
clean = state.response_text.rstrip()
|
||||
clean = state.response_text.strip()
|
||||
while clean.endswith("\n...") or clean.rstrip() == "...":
|
||||
clean = clean.rstrip().removesuffix("...").rstrip()
|
||||
console.print()
|
||||
console.print(Markdown(clean or state.response_text))
|
||||
console.print()
|
||||
|
||||
return state.response_text or ""
|
||||
return (state.response_text or "").strip()
|
||||
|
||||
@@ -536,7 +536,7 @@ class TestStepChannels:
|
||||
mock_q.select.return_value.ask.return_value = "skip"
|
||||
result = _step_channels(config)
|
||||
|
||||
assert result == (False, "", True)
|
||||
assert result == ("", {})
|
||||
|
||||
def test_returns_enabled_when_setup_passes(self):
|
||||
"""Test channels step returns enabled when setup succeeds."""
|
||||
@@ -547,7 +547,7 @@ class TestStepChannels:
|
||||
select_mock_1 = MagicMock()
|
||||
select_mock_1.ask.return_value = "imessage"
|
||||
select_mock_2 = MagicMock()
|
||||
select_mock_2.ask.return_value = True
|
||||
select_mock_2.ask.return_value = True # send thinking = True
|
||||
|
||||
with patch("EvoScientist.config.onboard.questionary") as mock_q, \
|
||||
patch("EvoScientist.config.onboard._setup_imessage", return_value=True):
|
||||
@@ -555,7 +555,7 @@ class TestStepChannels:
|
||||
mock_q.text.return_value.ask.return_value = ""
|
||||
result = _step_channels(config)
|
||||
|
||||
assert result == (True, "", True)
|
||||
assert result == ("imessage", {"imessage_allowed_senders": "", "channel_send_thinking": True})
|
||||
|
||||
def test_returns_enabled_with_senders(self):
|
||||
"""Test channels step returns enabled with specific senders."""
|
||||
@@ -566,7 +566,7 @@ class TestStepChannels:
|
||||
select_mock_1 = MagicMock()
|
||||
select_mock_1.ask.return_value = "imessage"
|
||||
select_mock_2 = MagicMock()
|
||||
select_mock_2.ask.return_value = False
|
||||
select_mock_2.ask.return_value = False # send thinking = False
|
||||
|
||||
with patch("EvoScientist.config.onboard.questionary") as mock_q, \
|
||||
patch("EvoScientist.config.onboard._setup_imessage", return_value=True):
|
||||
@@ -574,7 +574,7 @@ class TestStepChannels:
|
||||
mock_q.text.return_value.ask.return_value = "+1234567890,+0987654321"
|
||||
result = _step_channels(config)
|
||||
|
||||
assert result == (True, "+1234567890,+0987654321", False)
|
||||
assert result == ("imessage", {"imessage_allowed_senders": "+1234567890,+0987654321", "channel_send_thinking": False})
|
||||
|
||||
def test_setup_fails_user_declines(self):
|
||||
"""Test channels step returns disabled when setup fails and user declines."""
|
||||
@@ -588,7 +588,7 @@ class TestStepChannels:
|
||||
mock_q.confirm.return_value.ask.return_value = False
|
||||
result = _step_channels(config)
|
||||
|
||||
assert result == (False, "", True)
|
||||
assert result == ("", {})
|
||||
|
||||
def test_setup_fails_user_enables_anyway(self):
|
||||
"""Test channels step enables when setup fails but user confirms."""
|
||||
@@ -599,7 +599,7 @@ class TestStepChannels:
|
||||
select_mock_1 = MagicMock()
|
||||
select_mock_1.ask.return_value = "imessage"
|
||||
select_mock_2 = MagicMock()
|
||||
select_mock_2.ask.return_value = True
|
||||
select_mock_2.ask.return_value = True # send thinking = True
|
||||
|
||||
with patch("EvoScientist.config.onboard.questionary") as mock_q, \
|
||||
patch("EvoScientist.config.onboard._setup_imessage", return_value=False):
|
||||
@@ -608,7 +608,7 @@ class TestStepChannels:
|
||||
mock_q.text.return_value.ask.return_value = ""
|
||||
result = _step_channels(config)
|
||||
|
||||
assert result == (True, "", True)
|
||||
assert result == ("imessage", {"imessage_allowed_senders": "", "channel_send_thinking": True})
|
||||
|
||||
def test_raises_keyboard_interrupt_on_cancel(self):
|
||||
"""Test channels step raises KeyboardInterrupt on cancel."""
|
||||
|
||||
Reference in New Issue
Block a user