Files
team/memory/tmux-send-keys-enter.md
2026-04-19 21:47:08 +08:00

42 lines
1.6 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
name: tmux send-keys 回车问题
description: tmux send-keys 发送长文本到 cc 时 Enter 可能未生效,已创建 tmux-send-prompt.sh 脚本解决
type: feedback
originSessionId: 1f32ccfc-9806-4b86-91a1-367a9a07f713
---
## 问题
`tmux send-keys -t %1 '长中文文本...' Enter` 在 cc 输入框中,Enter 可能未被正确接收。
## 根因
1. **文本和 Enter 同时发送**: `tmux send-keys 'text' Enter` 在长文本场景下,Enter 可能在 cc 还未准备好接收时就被发送
2. **前一个命令未完成**: `/effort max` 执行后 sleep 时间不够(只等 5s),cc 的 prompt(❯)还没出现
3. **无法确认提交状态**: 没有验证 Enter 是否生效
## 解决方案
使用 `/workspace/scripts/tmux-send-prompt.sh` 脚本:
```bash
/workspace/scripts/tmux-send-prompt.sh <pane_id> '文本内容'
/workspace/scripts/tmux-send-prompt.sh <pane_id> /path/to/prompt.md
```
脚本做了 4 件事:
1. 等待 prompt 就绪(检测 ❯ 字符,最多 30s)
2. 文本和 Enter 分开发送(先文本→sleep 1s→Enter
3. 验证提交状态(检查输入框是否清空)
4. 自动重试(最多 3 次)
## 手动发送注意事项
```bash
# 1. 发送文本(不带 Enter
tmux send-keys -t %1 '长文本内容'
sleep 1
# 2. 单独发送 Enter
tmux send-keys -t %1 Enter
sleep 2
# 3. 验证
tmux capture-pane -t %1 -p | tail -5
```
**Why:** pane-1/pane-2 发送评审任务后 Enter 未生效,内容停留在输入框中
**How to apply:** 向 cc 发送长文本时用 tmux-send-prompt.sh 脚本;手动发送时分两步(文本→sleep→Enter→验证)