This is an automated email from the ASF dual-hosted git repository. github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/dev/pr-12634-c033fb3190f9ace9a8a823a940abc6460287f757 in repository https://gitbox.apache.org/repos/asf/seatunnel.git
commit 9ed8823c25aa760d057281ae542d38abf18ae12d Author: hutiefang76 <[email protected]> AuthorDate: Thu Oct 8 13:35:31 2026 +0000 [Fix][CLI] Clear pending clarification on session changes (#12634) --- seatunnel-cli/README.md | 2 ++ seatunnel-cli/README.zh-CN.md | 2 ++ seatunnel-cli/seatunnel_cli/cli.py | 3 ++ seatunnel-cli/tests/test_cli_sessions.py | 56 ++++++++++++++++++++++++++++++++ 4 files changed, 63 insertions(+) diff --git a/seatunnel-cli/README.md b/seatunnel-cli/README.md index 97b8772665..dc315dd464 100644 --- a/seatunnel-cli/README.md +++ b/seatunnel-cli/README.md @@ -311,6 +311,8 @@ Options: | `/help` | Show help panel | | `/quit` | Exit | +`/new`, `/clear`, and a successful `/resume` discard any unanswered clarification from the previous session. The next request uses the selected session only. + ## Examples ### MySQL to S3 (Batch) diff --git a/seatunnel-cli/README.zh-CN.md b/seatunnel-cli/README.zh-CN.md index 54d68339e1..c4cc2e578b 100644 --- a/seatunnel-cli/README.zh-CN.md +++ b/seatunnel-cli/README.zh-CN.md @@ -279,6 +279,8 @@ seatunnel [request] [options] | `/help` | 显示帮助面板 | | `/quit` | 退出 | +`/new`、`/clear` 和成功的 `/resume` 会丢弃上一会话未回答的澄清请求,下一条请求只使用所选会话的上下文。 + ## 示例 ### MySQL 到 S3(批处理) diff --git a/seatunnel-cli/seatunnel_cli/cli.py b/seatunnel-cli/seatunnel_cli/cli.py index 89f8d7c028..fe77068fa2 100644 --- a/seatunnel-cli/seatunnel_cli/cli.py +++ b/seatunnel-cli/seatunnel_cli/cli.py @@ -336,6 +336,7 @@ class SeaTunnelCLI: loaded, last_config = self.session_manager.load_session(session_id) self.orchestrator.load_history(loaded) self.last_config = last_config + self._pending_request = None self.console.print( f" Resumed [bold]{session_id}[/bold] ({len(loaded)} messages)", style="success" ) @@ -356,6 +357,7 @@ class SeaTunnelCLI: pass self.orchestrator.conversation_history.clear() self.last_config = None + self._pending_request = None sid = self.session_manager.new_session() self.console.print(f" New session: [bold]{sid}[/bold]", style="success") @@ -1102,6 +1104,7 @@ class SeaTunnelCLI: ) self.orchestrator.conversation_history.clear() self.last_config = None + self._pending_request = None self.session_manager.new_session() self.console.print(" Cleared. New session started.", style="info") diff --git a/seatunnel-cli/tests/test_cli_sessions.py b/seatunnel-cli/tests/test_cli_sessions.py new file mode 100644 index 0000000000..079e8dfcdc --- /dev/null +++ b/seatunnel-cli/tests/test_cli_sessions.py @@ -0,0 +1,56 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Tests for pending clarification state across session changes.""" + +from unittest.mock import Mock + +import pytest + +from seatunnel_cli.cli import SeaTunnelCLI + + [email protected] +def cli(): + instance = SeaTunnelCLI.__new__(SeaTunnelCLI) + instance.console = Mock() + instance.session_manager = Mock() + instance.orchestrator = Mock() + instance.orchestrator.conversation_history = [] + instance.last_config = "old config" + instance._pending_request = "Sync old source to old sink" + instance.client = Mock() + return instance + + [email protected]("command", ["/new", "/clear", "/resume other"]) +def test_successful_session_change_discards_pending_clarification(cli, command): + cli.session_manager.load_session.return_value = ([], "resumed config") + cli._handle_command(command) + assert cli._pending_request is None + + +def test_failed_resume_preserves_pending_clarification(cli): + cli.session_manager.load_session.side_effect = FileNotFoundError("not found") + cli._cmd_resume("missing") + assert cli._pending_request == "Sync old source to old sink" + assert cli.last_config == "old config" + + +def test_non_session_command_preserves_pending_clarification(cli): + cli._handle_command("/help") + assert cli._pending_request == "Sync old source to old sink"
