fix: 延长用户输入超时时间从10秒到60秒

修复用户输入超时问题:
- 将默认交互超时从10秒延长到60秒,给用户充足输入时间
- 避免用户在第9秒开始输入但来不及完成的问题
- 更新timeout_prompt和timeout_choice_prompt默认参数
- 在config.yaml添加interaction_timeout配置项
- 更新settings.py中的默认配置值

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
sladro 2025-10-09 17:08:17 +08:00
parent 2702e5020c
commit 18f85a1fa7
3 changed files with 10 additions and 6 deletions

View File

@ -36,6 +36,10 @@ performance:
max_workers: 4
timeout: 300
# 交互设置
interaction:
interaction_timeout: 60 # 用户输入超时时间(秒)
# 日志设置
logging:
level: INFO

View File

@ -58,7 +58,7 @@ class Settings(BaseSettings):
timeout: int = Field(default=300, description="超时时间(秒)")
# 交互配置
interaction_timeout: int = Field(default=10, description="用户交互超时时间(秒)")
interaction_timeout: int = Field(default=60, description="用户交互超时时间(秒)")
# 日志配置
log_level: str = Field(default="INFO", description="日志级别")

View File

@ -16,7 +16,7 @@ console = Console()
def timeout_prompt(
prompt: str,
default: Optional[str] = None,
timeout: int = 10,
timeout: int = 60,
choices: Optional[List[str]] = None,
) -> str:
"""带超时的输入提示
@ -24,7 +24,7 @@ def timeout_prompt(
Args:
prompt: 提示文本
default: 默认值
timeout: 超时时间()
timeout: 超时时间(),默认60秒给用户充足输入时间
choices: 可选的选项列表(如果提供,则进行验证)
Returns:
@ -66,7 +66,7 @@ def timeout_prompt(
except Empty:
# 超时 - 需要打印换行以清除输入行
print() # 打印空行以清理输入提示
console.print(f"[yellow]⏰ {timeout}秒内未输入,自动使用默认值: {default}[/yellow]")
console.print(f"[yellow]⏰ {timeout}秒内未完成输入,自动使用默认值: {default}[/yellow]")
return default or ""
@ -74,7 +74,7 @@ def timeout_choice_prompt(
prompt: str,
options: List[str],
default: Optional[str] = None,
timeout: int = 10,
timeout: int = 60,
) -> str:
"""带超时的选择输入
@ -82,7 +82,7 @@ def timeout_choice_prompt(
prompt: 提示文本
options: 选项列表
default: 默认选项
timeout: 超时时间()
timeout: 超时时间(),默认60秒
Returns:
选择的选项索引(字符串形式,"1","2")