-
Notifications
You must be signed in to change notification settings - Fork 52.7k
feat: Alt+Enter queues follow-up messages, Alt+Up recalls them #8492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
iRonin
wants to merge
5
commits into
NousResearch:main
Choose a base branch
from
iRonin:ironin/queue-followup
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+239
−4
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d8ba475
feat: Alt+Enter queues follow-up messages without interrupting agent
iRonin a66f37b
feat: Alt+Up recalls queued follow-ups back into input
iRonin a9167a8
fix: no separator before first recalled follow-up
iRonin fbd6334
fix: use UUID tags for followup cancellation, fix phantom queue pops
iRonin efa94d3
test: add tests for PR #4788
iRonin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,140 @@ | ||
| """Tests for PR #4788 feat/queue-followup. | ||
|
|
||
| Covers: Alt+Enter queues followup messages. | ||
| Attributes on HermesCLI: _followup_queue, _cancelled_followups, _followup_recall_count. | ||
| """ | ||
|
|
||
| import os | ||
| import sys | ||
| from unittest.mock import MagicMock, patch | ||
|
|
||
| sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) | ||
|
|
||
|
|
||
| def _make_cli(env_overrides=None, config_overrides=None, **kwargs): | ||
| """Create a HermesCLI instance with minimal mocking (mirrors test_cli_init.py).""" | ||
| import importlib | ||
|
|
||
| _clean_config = { | ||
| "model": { | ||
| "default": "anthropic/claude-opus-4.6", | ||
| "base_url": "https://openrouter.ai/api/v1", | ||
| "provider": "auto", | ||
| }, | ||
| "display": {"compact": False, "tool_progress": "all"}, | ||
| "agent": {}, | ||
| "terminal": {"env_type": "local"}, | ||
| } | ||
| if config_overrides: | ||
| for key, value in config_overrides.items(): | ||
| if key in _clean_config and isinstance(_clean_config[key], dict) and isinstance(value, dict): | ||
| _clean_config[key] = {**_clean_config[key], **value} | ||
| else: | ||
| _clean_config[key] = value | ||
|
|
||
| clean_env = {"LLM_MODEL": "", "HERMES_MAX_ITERATIONS": ""} | ||
| if env_overrides: | ||
| clean_env.update(env_overrides) | ||
|
|
||
| prompt_toolkit_stubs = { | ||
| "prompt_toolkit": MagicMock(), | ||
| "prompt_toolkit.history": MagicMock(), | ||
| "prompt_toolkit.styles": MagicMock(), | ||
| "prompt_toolkit.patch_stdout": MagicMock(), | ||
| "prompt_toolkit.application": MagicMock(), | ||
| "prompt_toolkit.layout": MagicMock(), | ||
| "prompt_toolkit.layout.processors": MagicMock(), | ||
| "prompt_toolkit.filters": MagicMock(), | ||
| "prompt_toolkit.layout.dimension": MagicMock(), | ||
| "prompt_toolkit.layout.menus": MagicMock(), | ||
| "prompt_toolkit.widgets": MagicMock(), | ||
| "prompt_toolkit.key_binding": MagicMock(), | ||
| "prompt_toolkit.completion": MagicMock(), | ||
| "prompt_toolkit.formatted_text": MagicMock(), | ||
| "prompt_toolkit.auto_suggest": MagicMock(), | ||
| } | ||
| with patch.dict(sys.modules, prompt_toolkit_stubs), \ | ||
| patch.dict("os.environ", clean_env, clear=False): | ||
| import cli as _cli_mod | ||
| _cli_mod = importlib.reload(_cli_mod) | ||
| with patch.object(_cli_mod, "get_tool_definitions", return_value=[]), \ | ||
| patch.dict(_cli_mod.__dict__, {"CLI_CONFIG": _clean_config}): | ||
| return _cli_mod.HermesCLI(**kwargs) | ||
|
|
||
|
|
||
| class TestFollowupQueueInit: | ||
| """_followup_queue must be initialized as an empty list.""" | ||
|
|
||
| def test_followup_queue_attribute_exists(self): | ||
| cli = _make_cli() | ||
| assert hasattr(cli, "_followup_queue"), ( | ||
| "_followup_queue must be initialized in HermesCLI.__init__" | ||
| ) | ||
|
|
||
| def test_followup_queue_is_empty_list(self): | ||
| cli = _make_cli() | ||
| assert cli._followup_queue == [] | ||
|
|
||
| def test_followup_queue_is_list_type(self): | ||
| cli = _make_cli() | ||
| assert isinstance(cli._followup_queue, list), ( | ||
| "_followup_queue must be a list (not a queue or deque)" | ||
| ) | ||
|
|
||
|
|
||
| class TestCancelledFollowupsInit: | ||
| """_cancelled_followups must be initialized as an empty set.""" | ||
|
|
||
| def test_cancelled_followups_attribute_exists(self): | ||
| cli = _make_cli() | ||
| assert hasattr(cli, "_cancelled_followups"), ( | ||
| "_cancelled_followups must be initialized in HermesCLI.__init__" | ||
| ) | ||
|
|
||
| def test_cancelled_followups_is_empty_set(self): | ||
| cli = _make_cli() | ||
| assert cli._cancelled_followups == set() | ||
|
|
||
| def test_cancelled_followups_is_set_type(self): | ||
| cli = _make_cli() | ||
| assert isinstance(cli._cancelled_followups, set), ( | ||
| "_cancelled_followups must be a set (not a list)" | ||
| ) | ||
|
|
||
|
|
||
| class TestFollowupRecallCountInit: | ||
| """_followup_recall_count must be initialized to 0.""" | ||
|
|
||
| def test_followup_recall_count_attribute_exists(self): | ||
| cli = _make_cli() | ||
| assert hasattr(cli, "_followup_recall_count"), ( | ||
| "_followup_recall_count must be initialized in HermesCLI.__init__" | ||
| ) | ||
|
|
||
| def test_followup_recall_count_is_zero(self): | ||
| cli = _make_cli() | ||
| assert cli._followup_recall_count == 0 | ||
|
|
||
| def test_followup_recall_count_is_int(self): | ||
| cli = _make_cli() | ||
| assert isinstance(cli._followup_recall_count, int) | ||
|
|
||
|
|
||
| class TestFollowupQueueIndependence: | ||
| """Each HermesCLI instance has its own queue/set (no shared mutable defaults).""" | ||
|
|
||
| def test_two_instances_have_independent_queues(self): | ||
| cli_a = _make_cli() | ||
| cli_b = _make_cli() | ||
| cli_a._followup_queue.append("item") | ||
| assert cli_b._followup_queue == [], ( | ||
| "_followup_queue must not be shared between instances" | ||
| ) | ||
|
|
||
| def test_two_instances_have_independent_cancelled_sets(self): | ||
| cli_a = _make_cli() | ||
| cli_b = _make_cli() | ||
| cli_a._cancelled_followups.add("uid-abc") | ||
| assert cli_b._cancelled_followups == set(), ( | ||
| "_cancelled_followups must not be shared between instances" | ||
| ) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tuple is no longer Alt-only on current main: Shift+Enter and enhanced-terminal Ctrl+Enter are intentionally aliased to
(Escape, ControlM)so they reach the multiline-newline handler (tests/cli/test_cli_shift_enter_newline.py:40-78,tests/cli/test_ctrl_enter_newline.py:97-109). Reassigning it to queueing would change all of those shortcuts as well.