Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions desktop/internal/localshell/integration_unix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,15 @@ func (s *integrated) lastExit() int {
// await feeds the shell's output to the terminal until done holds. The
// terminal's state changes only with output, and every output wakes the wait.
func (s *integrated) await(what string, done func() bool) {
s.awaitWithin(what, 10*time.Second, done)
}

// awaitWithin uses the caller's bounded deadline for the first cold shell
// startup under full-CI load, without changing the interactive command budget.
func (s *integrated) awaitWithin(what string, timeout time.Duration, done func() bool) {
s.t.Helper()
deadline := time.After(10 * time.Second)
deadline := time.NewTimer(timeout)
defer deadline.Stop()
for {
data := s.shell.Drain(nil)
s.output += string(data)
Expand All @@ -80,7 +87,7 @@ func (s *integrated) await(what string, done func() bool) {
}
select {
case <-s.wakes:
case <-deadline:
case <-deadline.C:
s.t.Fatalf("waiting for %s (ready=%d starts=%d): %q", what, s.ready(), s.starts(), s.output)
}
}
Expand Down
5 changes: 4 additions & 1 deletion desktop/internal/localshell/wsl_unix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ func TestWSLScriptStartsTheLoginShellInTheStartFolder(t *testing.T) {
}, "wsl-test-token")
// The shell starts in the folder the environment named, not the home
// folder, and the user's own startup file ran.
s.await("the first prompt", func() bool { return s.ready() > 0 })
// Login startup reads /etc/profile and the runner's shell initialization.
// Under full desktop CI load it may not emit its first byte in 10s;
// later interactive commands still use the normal bounded 10s wait.
s.awaitWithin("the first prompt", 30*time.Second, func() bool { return s.ready() > 0 })
s.run("printf 'in=%s\\n' \"$PWD\"\r", 1, "in="+startDir+"\r\n")
if !strings.Contains(s.output, "user-profile-loaded") {
t.Fatalf("the user's startup file did not run: %q", s.output)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"desktop/internal/settingswindow/terminal_behavior_view.go",
"desktop/internal/settingswindow/terminal_behavior_view_test.go",
"desktop/internal/workbench/terminal_env.go",
"desktop/internal/workbench/terminal_behavior_test.go"
"desktop/internal/workbench/terminal_behavior_test.go",
"desktop/internal/localshell/wsl_unix_test.go"
]
},
"windows": {
Expand Down Expand Up @@ -58,10 +59,11 @@
"desktop/internal/settingswindow/terminal_behavior_view.go",
"desktop/internal/settingswindow/terminal_behavior_view_test.go",
"desktop/internal/workbench/terminal_env.go",
"desktop/internal/workbench/terminal_behavior_test.go"
"desktop/internal/workbench/terminal_behavior_test.go",
"desktop/internal/localshell/integration_unix_test.go"
]
},
"owner": "Terminal",
"verification": "macOS/Linux 打开默认的 zsh 或 bash 终端:Lithe 经 /bin/sh 小脚本启动用户 Shell,用户自己的启动文件、历史记录和提示符照常生效(TestIntegratedBashStartupMatchesALoginShell、TestIntegratedZshHistorySurvivesSessions)。执行一条命令后,Shell 带着本次启动新生成的令牌上报提示符、命令开始与结束和退出码(OSC 133 A/B/C/D);其他程序打印的同样序列、嵌套 Shell 和重启前旧 Shell 的令牌都不被采信(TestIntegratedShellReportsPromptsAndCommands、TestTheUsersShellReportsItsPromptsUnderATokenNewToEachStart)。bash 的登录配置把 PROMPT_COMMAND 设成数组、在 PS0 前放命令替换(systemd 257 起的 /etc/profile.d/80-systemd-osc-context.sh 就这样做,Ubuntu 26.04 默认带),或用户自己的 DEBUG trap 回显 BASH_COMMAND 时,每条命令行仍只上报一次命令开始,用户的 PROMPT_COMMAND、PS0 和 DEBUG trap 照常运行;Bash 4.4 起的 PS0 路径和更早 Bash 的 DEBUG trap 路径都覆盖(TestIntegratedBashReportsEachCommandLineOnce、TestIntegratedBashDebugTrapReportsEachCommandLineOnce、TestIntegratedSystemBashReportsEachCommandLineOnce)。带参数启动的程序、插件终端、Git Bash 和未识别的 Shell 不带令牌,照原样启动(TestAProgramWithArgumentsOfItsOwnGetsNoToken、TestShellsTheIntegrationDoesNotCoverStartAsThemselves)。启动文件写在 Lithe 于 TMPDIR 下新建、仅本人可读的临时目录,sh 写完后直接变成用户 Shell(exec),Shell 读完启动文件即删除目录;Shell 结束后 Lithe 再删一次,所以启动中途被关闭、挂断被忽略而被强制结束时也不留目录、不留 Shell 进程(TestClosingAShellDuringItsStartupRemovesItsPrivateDirectory),应用包字节不变(verify-runtime-bundle-immutability.sh)。终端启动的进程仍是用户 Shell,关闭确认的忙碌判断、挂断与退出码都和不集成时一样;关闭终端时 Shell 与它的后台任务都收到挂断(TestClosingAnIntegratedShellHangsUpTheShellAndItsJobs)。Shell 退出后再关闭伪终端主端,避免读取 EOF 抢在挂断处理之前(TestCloseLetsTheShellHandleHangupBeforeReleasingThePTY)。命令刚结束、Shell 还没回到提示符(bash 正在运行 PROMPT_COMMAND)时关闭终端,Lithe 等 Shell 打出提示符标记再挂断,最多等 1 秒,后台任务同样结束;一直不回提示符的 Shell 在 1 秒后照常挂断(TestClosingAnIntegratedShellRightAfterACommandHangsUpItsJobs、TestClosingAnIntegratedShellThatNeverPromptsStillEndsIt、TestPromptMarksFindTheSessionsMarksInPiecesOfOutput)。 在提示符处拖动窗口或分隔条改变终端宽度:屏幕跟随每一步,提示符行留给 Shell 自己重绘,Shell 在尺寸保持 100 毫秒后只收到一次新尺寸,回到原尺寸则不发送;结束后只有一份提示符,没有重复或被截断的提示符行(TestAShellAtItsPromptIsToldItsSizeOnceItHolds、TestASizeThatComesBackIsNotSentToAShellAtItsPrompt、TestResizeLeavesTheShellPromptForTheShellToRedraw、TestResizeBackToItsWidthRestoresThePrompt)。运行命令或全屏程序时尺寸立即发送(TestAProgramIsToldItsSizeAtOnce)。 在正在输入的命令行上单击或 Option+单击:Shell 光标移到点击处(按程序要求的光标键编码发送左右方向键,宽字符、软换行按显示计算);拖动仍是选择,点在提示符上、输入行以外、命令运行中或备用屏时不发送按键(TestOptionClickMovesTheShellCursorWithinTheInputLine、TestPlainClickMovesTheCursorButADragDoesNot、TestAClickLeavesTheKeyboardAloneWhereItCannotPlaceTheCursor、TestInputMoveAcrossSoftWrap)。与 Motty 一致,Shell 至少执行过一条命令后点击移动才生效。 Windows:PowerShell 5.1 与 7 在 PSReadLine 交回用户确认的命令行后、命令运行前上报命令开始(包住 PSConsoleHostReadLine,行内容和上一条命令的成败状态不变,没有 PSReadLine 时不包;TestPowerShellReadLineIntegrationMarksTheCommandStart),之后提示符处延迟调整大小和点击移动光标对 PowerShell 生效(TestWindowsShellsMarkTheirPromptsUnderTheToken)。cmd 读完一行就直接运行,没有可插入的时机,只上报提示符,这两项对它不生效,尺寸立即发送、点击只是点击。WSL 发行版里的 bash/zsh 走同一脚本,三项都生效。Windows 运行时测试与 PowerShell、cmd、WSL 实机验收 pending;macOS 真实产品交互验收 pending。",
"notes": "2026-11-16:同步 Motty 203857c9(调整大小只保留一份提示符)与 b2357d69(点击命令行移动光标),并把 Motty internal/sshconn/integration.go(0ae3ba59)的 bash/zsh 集成脚本用于本地 Shell 与 WSL,见 termview/NOTICE。#1984 留下的令牌链路(localshell.Config.PromptToken,原名 DirectoryToken;term.SetPromptToken)由 termview 接通,每次启动生成新令牌;Windows 的 PowerShell/cmd 集成因此首次真正启用。#1984 随后删除了没有消费方的部分:term 的目录、提示符、命令与输入环境回调和 OSC 7、OSC 9;9 目录解析,以及集成脚本里的目录上报(Unix OSC 7,WSL、PowerShell、cmd 的 OSC 9;9);OSC 133 标记照常上报并被使用(TestPromptMarksAcrossEverySplit、TestACommandEndReclaimsOnlyWithAValidStatus),WSL 起始目录(MOTTY_WSL_CD)保留(TestWSLScriptStartsTheLoginShellInTheStartFolder)。与 Motty 的差异:不提供点击移动的设置开关;调整大小不等待鼠标松开,只等尺寸保持 100 毫秒;见 .agents/notes/implemented/architecture/2026-11-16-local-shell-integration-shim.md。Windows 为 partial:cmd 不上报命令开始,后两项在 cmd 中不生效;PowerShell 自 #2008 起经 PSReadLine 上报命令开始(与 VS Code 的 PowerShell 集成做法相同)。 2026-11-16:#2005 关闭时把挂断推迟到 Shell 回到提示符(最多 1 秒),修复 bash 在 PROMPT_COMMAND 期间被关闭时留下后台任务;Windows 后端不跟踪提示符标记,行为不变。 2026-11-16:bash 的 PS0 改用提示符转义写命令开始标记,赋值语句的文本里不再带标记字节,用户 DEBUG trap 回显 BASH_COMMAND 时不会伪造一次命令开始;DEBUG trap 路径遇到数组形式的 PROMPT_COMMAND 也在首尾加入钩子,不再整段跳过而一次命令开始都不报。这两处与 Motty 的脚本不同。"
"verification": "macOS/Linux 打开默认的 zsh 或 bash 终端:Lithe 经 /bin/sh 小脚本启动用户 Shell,用户自己的启动文件、历史记录和提示符照常生效(TestIntegratedBashStartupMatchesALoginShell、TestIntegratedZshHistorySurvivesSessions)。执行一条命令后,Shell 带着本次启动新生成的令牌上报提示符、命令开始与结束和退出码(OSC 133 A/B/C/D);其他程序打印的同样序列、嵌套 Shell 和重启前旧 Shell 的令牌都不被采信(TestIntegratedShellReportsPromptsAndCommands、TestTheUsersShellReportsItsPromptsUnderATokenNewToEachStart)。bash 的登录配置把 PROMPT_COMMAND 设成数组、在 PS0 前放命令替换(systemd 257 起的 /etc/profile.d/80-systemd-osc-context.sh 就这样做,Ubuntu 26.04 默认带),或用户自己的 DEBUG trap 回显 BASH_COMMAND 时,每条命令行仍只上报一次命令开始,用户的 PROMPT_COMMAND、PS0 和 DEBUG trap 照常运行;Bash 4.4 起的 PS0 路径和更早 Bash 的 DEBUG trap 路径都覆盖(TestIntegratedBashReportsEachCommandLineOnce、TestIntegratedBashDebugTrapReportsEachCommandLineOnce、TestIntegratedSystemBashReportsEachCommandLineOnce)。带参数启动的程序、插件终端、Git Bash 和未识别的 Shell 不带令牌,照原样启动(TestAProgramWithArgumentsOfItsOwnGetsNoToken、TestShellsTheIntegrationDoesNotCoverStartAsThemselves)。启动文件写在 Lithe 于 TMPDIR 下新建、仅本人可读的临时目录,sh 写完后直接变成用户 Shell(exec),Shell 读完启动文件即删除目录;Shell 结束后 Lithe 再删一次,所以启动中途被关闭、挂断被忽略而被强制结束时也不留目录、不留 Shell 进程(TestClosingAShellDuringItsStartupRemovesItsPrivateDirectory),应用包字节不变(verify-runtime-bundle-immutability.sh)。终端启动的进程仍是用户 Shell,关闭确认的忙碌判断、挂断与退出码都和不集成时一样;关闭终端时 Shell 与它的后台任务都收到挂断(TestClosingAnIntegratedShellHangsUpTheShellAndItsJobs)。Shell 退出后再关闭伪终端主端,避免读取 EOF 抢在挂断处理之前(TestCloseLetsTheShellHandleHangupBeforeReleasingThePTY)。命令刚结束、Shell 还没回到提示符(bash 正在运行 PROMPT_COMMAND)时关闭终端,Lithe 等 Shell 打出提示符标记再挂断,最多等 1 秒,后台任务同样结束;一直不回提示符的 Shell 在 1 秒后照常挂断(TestClosingAnIntegratedShellRightAfterACommandHangsUpItsJobs、TestClosingAnIntegratedShellThatNeverPromptsStillEndsIt、TestPromptMarksFindTheSessionsMarksInPiecesOfOutput)。 在提示符处拖动窗口或分隔条改变终端宽度:屏幕跟随每一步,提示符行留给 Shell 自己重绘,Shell 在尺寸保持 100 毫秒后只收到一次新尺寸,回到原尺寸则不发送;结束后只有一份提示符,没有重复或被截断的提示符行(TestAShellAtItsPromptIsToldItsSizeOnceItHolds、TestASizeThatComesBackIsNotSentToAShellAtItsPrompt、TestResizeLeavesTheShellPromptForTheShellToRedraw、TestResizeBackToItsWidthRestoresThePrompt)。运行命令或全屏程序时尺寸立即发送(TestAProgramIsToldItsSizeAtOnce)。 在正在输入的命令行上单击或 Option+单击:Shell 光标移到点击处(按程序要求的光标键编码发送左右方向键,宽字符、软换行按显示计算);拖动仍是选择,点在提示符上、输入行以外、命令运行中或备用屏时不发送按键(TestOptionClickMovesTheShellCursorWithinTheInputLine、TestPlainClickMovesTheCursorButADragDoesNot、TestAClickLeavesTheKeyboardAloneWhereItCannotPlaceTheCursor、TestInputMoveAcrossSoftWrap)。与 Motty 一致,Shell 至少执行过一条命令后点击移动才生效。 Windows:PowerShell 5.1 与 7 在 PSReadLine 交回用户确认的命令行后、命令运行前上报命令开始(包住 PSConsoleHostReadLine,行内容和上一条命令的成败状态不变,没有 PSReadLine 时不包;TestPowerShellReadLineIntegrationMarksTheCommandStart),之后提示符处延迟调整大小和点击移动光标对 PowerShell 生效(TestWindowsShellsMarkTheirPromptsUnderTheToken)。cmd 读完一行就直接运行,没有可插入的时机,只上报提示符,这两项对它不生效,尺寸立即发送、点击只是点击。WSL 发行版里的 bash/zsh 走同一脚本,三项都生效。Windows 运行时测试与 PowerShell、cmd、WSL 实机验收 pending;macOS 真实产品交互验收 pending。 #2108:运行 TestWSLScriptStartsTheLoginShellInTheStartFolder(bash/zsh),验证第一次提示符延长预算后脚本仍在指定目录、仍运行启动文件、命令上报/退出正确;再跑 localshell 全包并行及 Linux/macOS CI 验证是否消除原先偶发启动超时;没有完整 CI 负载复测前维持 pending。",
"notes": "2026-11-16:同步 Motty 203857c9(调整大小只保留一份提示符)与 b2357d69(点击命令行移动光标),并把 Motty internal/sshconn/integration.go(0ae3ba59)的 bash/zsh 集成脚本用于本地 Shell 与 WSL,见 termview/NOTICE。#1984 留下的令牌链路(localshell.Config.PromptToken,原名 DirectoryToken;term.SetPromptToken)由 termview 接通,每次启动生成新令牌;Windows 的 PowerShell/cmd 集成因此首次真正启用。#1984 随后删除了没有消费方的部分:term 的目录、提示符、命令与输入环境回调和 OSC 7、OSC 9;9 目录解析,以及集成脚本里的目录上报(Unix OSC 7,WSL、PowerShell、cmd 的 OSC 9;9);OSC 133 标记照常上报并被使用(TestPromptMarksAcrossEverySplit、TestACommandEndReclaimsOnlyWithAValidStatus),WSL 起始目录(MOTTY_WSL_CD)保留(TestWSLScriptStartsTheLoginShellInTheStartFolder)。与 Motty 的差异:不提供点击移动的设置开关;调整大小不等待鼠标松开,只等尺寸保持 100 毫秒;见 .agents/notes/implemented/architecture/2026-11-16-local-shell-integration-shim.md。Windows 为 partial:cmd 不上报命令开始,后两项在 cmd 中不生效;PowerShell 自 #2008 起经 PSReadLine 上报命令开始(与 VS Code 的 PowerShell 集成做法相同)。 2026-11-16:#2005 关闭时把挂断推迟到 Shell 回到提示符(最多 1 秒),修复 bash 在 PROMPT_COMMAND 期间被关闭时留下后台任务;Windows 后端不跟踪提示符标记,行为不变。 2026-11-16:bash 的 PS0 改用提示符转义写命令开始标记,赋值语句的文本里不再带标记字节,用户 DEBUG trap 回显 BASH_COMMAND 时不会伪造一次命令开始;DEBUG trap 路径遇到数组形式的 PROMPT_COMMAND 也在首尾加入钩子,不再整段跳过而一次命令开始都不报。这两处与 Motty 的脚本不同。 #2108 首次模拟 WSL 登录 Shell 的提示符独立给 30 秒有界冷启动预算,以覆盖完整 CI 高负载下 /etc/profile 与用户启动文件;其他提示符和命令等待仍为 10 秒。未修改生产 Shell 或 WSL 脚本。"
}
Loading