diff --git a/.agents/notes/implemented/architecture/2026-11-16-local-shell-integration-shim.md b/.agents/notes/implemented/architecture/2026-11-16-local-shell-integration-shim.md index b4909c6215..59190b93fc 100644 --- a/.agents/notes/implemented/architecture/2026-11-16-local-shell-integration-shim.md +++ b/.agents/notes/implemented/architecture/2026-11-16-local-shell-integration-shim.md @@ -32,6 +32,12 @@ Unix 后端(`localshell/backend_unix.go`)在 `args == nil`、令牌有效、 脚本内容是 Motty 的 `integration.go`(0ae3ba59),去掉了 Lithe 不读的输出编码、主目录和当前目录(OSC 7)上报,保留 `;motty=` 后缀和 `MOTTY_*` 变量名,方便以后同步时直接对比差异。本地启动与 Motty 的差别只在开头和结尾:目录由调用方给出(`$3`),不用 `mktemp` 和 `trap`;最后一行用 `exec` 变成 Shell,不等待它(`startScript` 的 `owned` 参数)。 +bash 部分另有两处与 Motty 不同,同步时不要改回: + +- PS0 用提示符转义写命令开始标记(`PS0='\e]133;C…\a'${PS0-}`),不用 `$'…'`。`$'…'` 在赋值语句的文本里就展开成 ESC 和 BEL,用户的 DEBUG trap 回显 `BASH_COMMAND` 时会把一个带本会话令牌的 C 标记原样打到终端,终端把它当成一次命令开始。PS0 显示时和 PS1 一样解码 `\e`、`\a`。 +- DEBUG trap 路径(Bash 4.4 之前没有 PS0)遇到数组形式的 `PROMPT_COMMAND`,同样在首尾加入 `__motty_disarm` 和 `__motty_arm`,和 PS0 路径对数组的处理一致。原来遇到数组就整段跳过,一次命令开始都不报。systemd 257 起的 `/etc/profile.d/80-systemd-osc-context.sh`(Ubuntu 26.04 默认带)会把 `PROMPT_COMMAND` 改成数组,并在 PS0 前放命令替换;集成先读 `/etc/profile`,所以用户和 CI 都会遇到。Bash 5.1 之前只执行数组的第 0 项,这种组合下仍不上报,和原来一样。 +- 回归测试:`TestIntegratedBashReportsEachCommandLineOnce`、`TestIntegratedBashDebugTrapReportsEachCommandLineOnce` 的 `array prompt command` 用例在测试自己的 `.bash_profile` 里照 systemd 的写法设置,不依赖宿主的 `/etc/profile`。 + ### 临时目录归 Lithe 所有,sh 变成 Shell - Lithe 在 `wait` 里、`cmd.Wait()` 返回后删除目录(`removeRuntime`),启动失败时也删除。无论 Shell 怎么结束,包括启动文件还没跑完就被关闭、忽略挂断后被强制结束,目录都不会留下。`Done()` 关闭前目录已经删除。 diff --git a/desktop/internal/localshell/integration_scripts.go b/desktop/internal/localshell/integration_scripts.go index baba5e03c8..db1d85e411 100644 --- a/desktop/internal/localshell/integration_scripts.go +++ b/desktop/internal/localshell/integration_scripts.go @@ -246,44 +246,45 @@ case $(declare -p PROMPT_COMMAND 2>/dev/null) in *) PROMPT_COMMAND=__motty_command_finished$'\n'${PROMPT_COMMAND:+$PROMPT_COMMAND$'\n'}__motty_report ;; esac if (( __MOTTY_FORCE__ == 0 && (BASH_VERSINFO[0] > 4 || (BASH_VERSINFO[0] == 4 && BASH_VERSINFO[1] >= 4)) )); then - PS0=$'\e]133;C__MOTTY_SUFFIX__\a'${PS0-} + # Prompt escapes, not $'...': the assignment's own text, which a user's + # DEBUG trap sees in BASH_COMMAND, must not carry the marker itself. + PS0='\e]133;C__MOTTY_SUFFIX__\a'${PS0-} printf '\033]133;C__MOTTY_SUFFIX__\007' else # No PS0 before Bash 4.4: report the start of a command line from a DEBUG # trap, which runs before every simple command. PROMPT_COMMAND ends by # arming it, and the first command after that reports once and disarms. # An empty Enter reruns PROMPT_COMMAND, whose first entry disarms again so - # that its own commands never count. An array PROMPT_COMMAND (Bash 5.1+) is - # not taken here; those versions have PS0. + # that its own commands never count. An array PROMPT_COMMAND, which a + # profile such as systemd's 80-systemd-osc-context.sh makes, gets the same + # first and last entries. + __motty_disarm() { local _motty_status=$?; _motty_armed=0; return "$_motty_status"; } + __motty_arm() { _motty_armed=1; } + __motty_debug() { + [[ ${_motty_armed-} == 1 && $BASH_COMMAND != __motty_disarm && -z ${COMP_POINT-} ]] || return 0 + _motty_armed=0 + printf '\033]133;C__MOTTY_SUFFIX__\007' + } + _motty_armed=0 case $(declare -p PROMPT_COMMAND 2>/dev/null) in - 'declare -a '*) ;; - *) - __motty_disarm() { local _motty_status=$?; _motty_armed=0; return "$_motty_status"; } - __motty_arm() { _motty_armed=1; } - __motty_debug() { - [[ ${_motty_armed-} == 1 && $BASH_COMMAND != __motty_disarm && -z ${COMP_POINT-} ]] || return 0 - _motty_armed=0 - printf '\033]133;C__MOTTY_SUFFIX__\007' - } - _motty_armed=0 - PROMPT_COMMAND=__motty_disarm$'\n'${PROMPT_COMMAND:+$PROMPT_COMMAND$'\n'}__motty_arm - # Keep the user's own DEBUG trap and run it first, so that it sees - # the same $?, $_ and BASH_COMMAND as without us. trap -p is read - # through a file because a command substitution is a subshell. - trap -p DEBUG > "$_motty_runtime/debug-trap" - _motty_trap=$(<"$_motty_runtime/debug-trap") - __motty_unquote() { eval "set -- ${1#trap -- }"; _motty_trap=$1; } - if [[ -n $_motty_trap ]]; then - __motty_unquote "$_motty_trap" - trap -- "$_motty_trap"$'\n''__motty_debug' DEBUG - else - trap -- '__motty_debug' DEBUG - fi - unset -f __motty_unquote - unset _motty_trap - printf '\033]133;C__MOTTY_SUFFIX__\007' - ;; + 'declare -a '*) PROMPT_COMMAND=(__motty_disarm "${PROMPT_COMMAND[@]}" __motty_arm) ;; + *) PROMPT_COMMAND=__motty_disarm$'\n'${PROMPT_COMMAND:+$PROMPT_COMMAND$'\n'}__motty_arm ;; esac + # Keep the user's own DEBUG trap and run it first, so that it sees + # the same $?, $_ and BASH_COMMAND as without us. trap -p is read + # through a file because a command substitution is a subshell. + trap -p DEBUG > "$_motty_runtime/debug-trap" + _motty_trap=$(<"$_motty_runtime/debug-trap") + __motty_unquote() { eval "set -- ${1#trap -- }"; _motty_trap=$1; } + if [[ -n $_motty_trap ]]; then + __motty_unquote "$_motty_trap" + trap -- "$_motty_trap"$'\n''__motty_debug' DEBUG + else + trap -- '__motty_debug' DEBUG + fi + unset -f __motty_unquote + unset _motty_trap + printf '\033]133;C__MOTTY_SUFFIX__\007' fi rm -rf -- "$_motty_runtime" unset _motty_runtime _motty_profile` diff --git a/desktop/internal/localshell/integration_unix_test.go b/desktop/internal/localshell/integration_unix_test.go index e4e240d65a..31d582efae 100644 --- a/desktop/internal/localshell/integration_unix_test.go +++ b/desktop/internal/localshell/integration_unix_test.go @@ -3,7 +3,9 @@ package localshell import ( + "context" "errors" + "fmt" "os" "os/exec" "path/filepath" @@ -406,13 +408,39 @@ func TestIntegratedBashDebugTrapReportsEachCommandLineOnce(t *testing.T) { if err != nil { t.Skip("bash unavailable") } - checkCommandStartReports(t, func(env []string, runtimeDir string) Config { - dir, err := os.MkdirTemp(runtimeDir, "motty-shell.") - if err != nil { - t.Fatal(err) - } - return Config{Shell: "/bin/sh", Args: integrationArgsWith(program, true, "debug-trap-token", dir), Env: env} - }, program) + for _, profile := range commandStartProfiles { + t.Run(profile.name, func(t *testing.T) { + profile.require(t, program) + checkCommandStartReports(t, func(env []string, runtimeDir string) Config { + dir, err := os.MkdirTemp(runtimeDir, "motty-shell.") + if err != nil { + t.Fatal(err) + } + return Config{Shell: "/bin/sh", Args: integrationArgsWith(program, true, "debug-trap-token", dir), Env: env} + }, program, profile.text) + }) + } +} + +// Bash 4.4 and later report the start of a command line from PS0. The user's +// DEBUG trap prints BASH_COMMAND, so a marker spelled out in the text of a +// startup command would be counted as a report. +func TestIntegratedBashReportsEachCommandLineOnce(t *testing.T) { + program, err := exec.LookPath("bash") + if err != nil { + t.Skip("bash unavailable") + } + if !bashAtLeast(t, program, 4, 4) { + t.Skipf("%s has no PS0", program) + } + for _, profile := range commandStartProfiles { + t.Run(profile.name, func(t *testing.T) { + profile.require(t, program) + checkCommandStartReports(t, func(env []string, _ string) Config { + return Config{Shell: program, PromptToken: "debug-trap-token", Env: env} + }, program, profile.text) + }) + } } // The Bash at /bin/bash is the one a user who chose Bash most often gets: 3.2 @@ -424,13 +452,53 @@ func TestIntegratedSystemBashReportsEachCommandLineOnce(t *testing.T) { } checkCommandStartReports(t, func(env []string, _ string) Config { return Config{Shell: "/bin/bash", PromptToken: "debug-trap-token", Env: env} - }, "/bin/bash") + }, "/bin/bash", commandStartProfiles[0].text) +} + +// commandStartProfiles are the user's login profiles the command-start tests +// run under. Each sets a prompt, a prompt command and a DEBUG trap of the +// user's own. +var commandStartProfiles = []struct { + name, text string + // require skips a profile the Bash at program cannot run as written. + require func(t *testing.T, program string) +}{ + {"string prompt command", commandStartProfile, func(*testing.T, string) {}}, + // systemd's /etc/profile.d/80-systemd-osc-context.sh (systemd 257 and + // later, as on Ubuntu 26.04) turns PROMPT_COMMAND into an array, leaving + // element 0 for a profile that assigns a string, and puts a command + // substitution in front of PS0. Bash runs an array PROMPT_COMMAND from 5.1. + {"array prompt command", "[ -n \"$(declare -p PROMPT_COMMAND 2>/dev/null)\" ] || PROMPT_COMMAND+=('')\n" + + "__system_hook() { printf 'system-%s\\n' hook; }\nPROMPT_COMMAND+=(__system_hook)\n" + + "__system_ps0() { printf 'system-%s' ps0; }\nPS0='$(__system_ps0)'\"${PS0:-}\"\n" + commandStartProfile, + func(t *testing.T, program string) { + if !bashAtLeast(t, program, 5, 1) { + t.Skipf("%s runs only the first element of an array PROMPT_COMMAND", program) + } + }}, +} + +const commandStartProfile = "PS1='user-prompt> '\nPROMPT_COMMAND='printf \"user-hook\\n\"'\ntrap 'printf \"user-debug:%s\\n\" \"$BASH_COMMAND\"' DEBUG\n" + +// bashAtLeast reports whether the Bash at program is at least major.minor. +func bashAtLeast(t *testing.T, program string, major, minor int) bool { + t.Helper() + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + out, err := exec.CommandContext(ctx, program, "-c", `echo "${BASH_VERSINFO[0]} ${BASH_VERSINFO[1]}"`).Output() + if err != nil { + t.Fatalf("read the version of %s: %v", program, err) + } + var gotMajor, gotMinor int + if _, err := fmt.Sscan(string(out), &gotMajor, &gotMinor); err != nil { + t.Fatalf("the version of %s, %q: %v", program, out, err) + } + return gotMajor > major || gotMajor == major && gotMinor >= minor } -func checkCommandStartReports(t *testing.T, config func(env []string, runtimeDir string) Config, program string) { +func checkCommandStartReports(t *testing.T, config func(env []string, runtimeDir string) Config, program, profile string) { t.Helper() home, runtimeDir := t.TempDir(), t.TempDir() - profile := "PS1='user-prompt> '\nPROMPT_COMMAND='printf \"user-hook\\n\"'\ntrap 'printf \"user-debug:%s\\n\" \"$BASH_COMMAND\"' DEBUG\n" if err := os.WriteFile(filepath.Join(home, ".bash_profile"), []byte(profile), 0o600); err != nil { t.Fatal(err) } @@ -468,6 +536,13 @@ func checkCommandStartReports(t *testing.T, config func(env []string, runtimeDir if !strings.Contains(s.output, "user-hook\r\n") { t.Fatalf("the user's PROMPT_COMMAND was lost: %q", s.output) } + // The profile prints these through a format, so that its own text, which + // the user's DEBUG trap echoes, does not contain them. + for _, hook := range []string{"system-hook\r\n", "system-ps0"} { + if strings.Contains(profile, "__system_") && !strings.Contains(s.output, hook) { + t.Fatalf("the profile's %q did not run: %q", hook, s.output) + } + } s.exit("exit 5\r", 5) emptyDirectory(t, runtimeDir) } diff --git a/shared/platform-feature-matrix/features/terminal-shell-integration.json b/shared/platform-feature-matrix/features/terminal-shell-integration.json index 977ced76c5..6681512a4b 100644 --- a/shared/platform-feature-matrix/features/terminal-shell-integration.json +++ b/shared/platform-feature-matrix/features/terminal-shell-integration.json @@ -62,6 +62,6 @@ ] }, "owner": "Terminal", - "verification": "macOS/Linux 打开默认的 zsh 或 bash 终端:Lithe 经 /bin/sh 小脚本启动用户 Shell,用户自己的启动文件、历史记录和提示符照常生效(TestIntegratedBashStartupMatchesALoginShell、TestIntegratedZshHistorySurvivesSessions)。执行一条命令后,Shell 带着本次启动新生成的令牌上报提示符、命令开始与结束和退出码(OSC 133 A/B/C/D);其他程序打印的同样序列、嵌套 Shell 和重启前旧 Shell 的令牌都不被采信(TestIntegratedShellReportsPromptsAndCommands、TestTheUsersShellReportsItsPromptsUnderATokenNewToEachStart)。带参数启动的程序、插件终端、Git Bash 和未识别的 Shell 不带令牌,照原样启动(TestAProgramWithArgumentsOfItsOwnGetsNoToken、TestShellsTheIntegrationDoesNotCoverStartAsThemselves)。启动文件写在 Lithe 于 TMPDIR 下新建、仅本人可读的临时目录,sh 写完后直接变成用户 Shell(exec),Shell 读完启动文件即删除目录;Shell 结束后 Lithe 再删一次,所以启动中途被关闭、挂断被忽略而被强制结束时也不留目录、不留 Shell 进程(TestClosingAShellDuringItsStartupRemovesItsPrivateDirectory),应用包字节不变(verify-runtime-bundle-immutability.sh)。终端启动的进程仍是用户 Shell,关闭确认的忙碌判断、挂断与退出码都和不集成时一样;关闭终端时 Shell 与它的后台任务都收到挂断(TestClosingAnIntegratedShellHangsUpTheShellAndItsJobs)。命令刚结束、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 后端不跟踪提示符标记,行为不变。" + "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 还没回到提示符(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 的脚本不同。" }