Repository navigation
Conversation
1b43c7e to
2bec420
Compare
The GPUI shell had no clear-screen action at all: the macOS config table's ⌘K ClearHistory default executes only in the legacy shell, so after unbinding the Shell picker row ⌘K stayed inert and no settings row offered clear screen — the known limitation recorded in the 2026-09-21 macOS command-key aliases note. Map config::Action::ClearHistory to a new ClearTerminal workspace action and expose it as a Terminal-group row on the settings keymap page. No default shortcut changes on any platform: ⌘K stays on the Shell picker, and the feature is opt-in through a user keybind= row that applies without restart. After an instant app-side wipe of the viewport and scrollback, the action branches on the pane's foreground state: at a prompt it writes ^L to the pane's PTY so the shell repaints its prompt on the fresh screen; while a command runs it moves the terminal cursor home app-side so sequential output continues from the top; on the alternate screen it does nothing. The row label uses a typed i18n message (zh/en catalogs, English fallback elsewhere). Adds adapter, dispatch-probe and label regressions, and the decision note architecture/notes/nebula_app/gpui_shell/2026-10-14-terminal-clear-action.md (recording why pre-existing files need one re-record after upgrading, and why an app-side cursor-home and an unconditional ^L were rejected).
…trol group The platform-cfg ratchet counts cfg! macros outside platform/ and the clear-screen adapter regression added one. Build the static default keymap identically on every platform instead: the precedence being tested is source-tier, not platform-specific, and the macOS-only registration behavior stays guarded by its own runtime-platform test.
…policy Upstream cf77ccd releases plain Control-character workspace defaults on macOS, so the Shell picker's Ctrl+K default may legitimately be absent. Derive the Ctrl+K expectation from the control group's own shape instead of asserting it unconditionally; the user clear binding must neither steal a present default nor resurrect a released key.
10520b6 to
94cdb39
Compare
|
Added focused maintainer fixes at 92516fe and merged the current main baseline. The actual TerminalView tests now cover prompt-only Ctrl+L delivery, no PTY input while a command runs, cursor-home/history/selection clearing, and an unchanged alternate screen plus primary history. The macOS keymap regression preserves Command+K ownership for the Shell picker; the stale note has been corrected. Windows validation: The action is user-triggered: it reuses the terminal's existing bounded grid/history clear operations and adds one prompt-state branch, with no polling or background work. Native shell redraw acceptance remains distinct from the standalone PTY regression fixtures. |
Kuddev
left a comment
There was a problem hiding this comment.
Reviewed db35ebd. All five actual Native tests jobs and both macOS release workspace checks passed on this head. The clear action now reaches the focused GPUI terminal; focused regression cases verify prompt-only Ctrl+L, running-command cursor reset without PTY input, cleared viewport/history/selection, and an unchanged alternate screen. The shortcut policy retains Command+K for the macOS Shell picker, with Clear screen unbound until explicitly assigned.
This is a user-triggered operation using the existing grid/history clear primitives, with no polling, extra subprocess, or per-frame work. Windows focused tests and architecture checks passed locally. The standalone PTY fixture proves dispatched bytes and terminal state; it is not a claim that every third-party shell redraw behavior was exercised.
|
The Re-running via an empty push; if it fails again consistently, it reproduces independently of this branch and likely needs a look upstream. |
|
The re-run failed on the same case: This branch changes nothing under Since PR authors cannot re-run upstream jobs, could a maintainer re-run the failed job once? If it keeps failing there while |
…nal-action # Conflicts: # nebula_app/src/display/keymap.rs
|
Friendly ping for a re-review. Your Oct 19 approval was dismissed as stale by the follow-up pushes (the repo requires approval of the latest reviewable push), and PR authors cannot re-request reviewers, so this comment is the nudge. The branch is now conflict-free against |
There was a problem hiding this comment.
复核了 554235a8。F9 重绘与 F11 粘贴已拆开;此前 Bash 的普通后缀反例,以及 zsh 字符串宏和同名 widget 的反例均已解决。33 项 Bash/zsh 回归测试通过。两个真实 PTY 用例和一处源码检查仍发现绑定所有权误判:
-
Bash:匹配子串仍可能认错键。
grep -qF会把另一行里的固定子串当成完整绑定。在已有重绘声明的会话中运行:bind '"\C-x\"\e[46~": clear-screen' bind '"\e[46~": "QUOTED-KEY-MACRO"'
下一提示符仍声明重绘,发送目标键实际插入
QUOTED-KEY-MACRO。临时改成grep -qxF后,同一 PTY 用例正确撤销声明,相关的 3 项 Bash 测试也通过。 -
zsh:提示符期间切换 Vi 键表后仍会发送原来的键。
bindkey查询 在提示符处验证主键表。在真实 PTY 中,viins的\e[46~绑定.clear-screen,vicmd的同一键绑定用户 widget。提示符先声明重绘,输入时切到vicmd没有撤销;此时发送重绘键实际调用用户 widget。请覆盖同一提示符内的键表切换:当前绑定无法确认时撤销或不声明,并保留用户的vicmd绑定。 -
PowerShell:
Function是显示用的描述,不能证明处理程序是内建函数。 安装和复查 都接受Function == 'ClearScreen'。PSReadLine 2.3.6 接受脚本块的自定义BriefDescription,并将该描述写入查询结果的Function,也用它计算Group。按这条代码路径,-ScriptBlock { … } -BriefDescription ClearScreen在启动前可能被覆盖,启动后重新绑定则会继续被当成原生重绘。源码路径和下方实测均指向这一问题;请补上同名脚本块在启动前和重新绑定后的测试。
补充实测(同一提交 554235a8): 在 Linux 真 PTY 中使用 PowerShell 7.6.8 / PSReadLine 2.4.5。启动前确认 Ctrl+Shift+F9 已绑定描述为 ClearScreen 的用户脚本块,集成启动后仍覆盖成原生清屏。启动后再把 F9 绑回该脚本块,下一提示符仍声明支持重绘;发送 Ctrl+Shift+F9 实际向编辑缓冲区插入了脚本块的 USER-F9 文本。
该提交已有的四项 PowerShell 重绘和粘贴用例均通过;同名脚本块是它们没覆盖的反例。
…tches The Bash probe matched the clear-screen entry as a fixed substring, so a lookalike binding line that merely contains it kept a revoked chord announced while a quoted macro on the key fired user text. The probe now matches the complete binding line. The zsh probe validated only the prompt-time keymap; switching to vicmd inside the same prompt could route the byte into a user widget while the redraw capability stayed announced. Ownership now requires the built-in widget (or an inert unbound key) in every keymap one prompt can reach; the probe only reads, so user bindings stay untouched. PowerShell accepted Function == ClearScreen as ownership, but Function is PSReadLine's display description: a scriptblock with BriefDescription ClearScreen could take the chord before startup or rebind it afterwards and still count as native redraw. The installation now tags its binding with a Description token and both the startup probe and the per-prompt re-check match that token; anything else on the chord is user-owned and stays untouched.
|
All three points are addressed on head 90860de (branch also merged current main first):
Environment note: this machine has zsh but neither pwsh nor Bash ≥ 4, so the zsh keymap-switch suite ran locally (completion editor 21 tests + shell suites 44, green); the Bash-5 decoy path and both PowerShell cases run on the Linux CI runner, same as the previous rounds. |
Kuddev
left a comment
There was a problem hiding this comment.
复核了 90860de9。Linux 真 PTY 上,Bash/zsh 的 21 项编辑器测试通过,包括上一轮的 Bash 相似绑定和 zsh 普通 Vi widget。PowerShell 7.6.8 / PSReadLine 2.4.5 有 7 个断言失败和 1 个错误;3 个旧版编辑器用例因未配置旧模块跳过。需要修复三处:
- PowerShell:安装重绘时中断了后续编辑器初始化。
completion.ps1把-Function ClearScreen和-Description用在同一个调用。PSReadLine 2.4.5 的两个参数属于不同参数集,实际返回Parameter 'Function' cannot be specified in parameter set 'ScriptBlock'.默认空闲的 F9 无法安装,后续原生指针初始化也没走完;清屏声明消失,鼠标位置查询返回unsupported。同一环境用554235a8跑清屏/粘贴并存和 Unicode 光标定位,两项均通过。请用 PSReadLine 支持的绑定方式验证所有权,并把重绘安装失败隔离在可选重绘功能里。 - zsh:其他键表里的字符串宏仍可能被当成未绑定。
*undefined-key*也接受内容里有undefined-key的带引号宏。真 PTY 中,插入模式是内置清屏,命令模式是同一键上的aundefined-key宏,提示符仍声明重绘;按 Esc 切过去后发送重绘键,缓冲区变为echo tailundefined-key。请只接受未加引号的undefined-key结果,并对无法查询的键表撤销声明。 - Bash:也有同一个提示符内切到 Vi 命令键表的路径。 目前只查提示符时的默认键表。在 Bash 5.2.21 的真 PTY 上,
vi-insert绑定清屏、vi-command绑定字符串宏,启动仍声明重绘;Esc 后发送重绘键会执行用户宏并插入文本。请同时验证可在同一提示符切换到的 Readline 键表。
PSReadLine 2.4.5 keeps -Function and -Description in different parameter
sets, so the redraw install threw ('Parameter Function cannot be
specified in parameter set ScriptBlock.') and the outer catch killed the
whole editor and pointer init with it. The redraw now installs through
the ScriptBlock set — a handler performing the native ClearScreen work
(erase display and scrollback, re-prompt) — carrying the session token
in -Description inside its own try, so a refusing PSReadLine only leaves
the redraw advertisement off. Identity moves with it: the per-prompt
re-check matches the Description token alone, since Function is a
display name scriptblocks imitate.
The zsh ownership probe accepted any report containing undefined-key,
so a quoted vicmd macro whose body merely contains the word stayed
announced and fired user text; the probe now matches the bare
space-anchored undefined-key tail an unbound keymap reports and revokes
keymaps it cannot query.
The bash probe validated only the prompt-time keymap; the probe now
walks every keymap reachable within one prompt (emacs-standard/-ctlx/
-meta, vi-insert, vi-command, vi-move) inside a single subshell,
anchoring entries to the key's complete binding line and restoring the
original keymap before returning, so a user macro waiting in vi-command
revokes while an unbound chord elsewhere stays inert.
The PowerShell and bash-5 paths run on the Linux CI as before; the zsh
editor suite is green locally.
|
All three points are addressed on head 30b5aed (branch also merged current main first):
Environment note: this machine has zsh but neither pwsh nor Bash ≥ 4, so the zsh editor suite (11 tests) ran locally green along with a probe smoke test; the bash-5 and PowerShell paths run on the Linux CI as before. I did not touch the red run on 90860de — this push supersedes it. |
Kuddev
left a comment
There was a problem hiding this comment.
复核了 30b5aed9。本机 Linux 真 PTY 上,Bash Vi 键表和 zsh 字符串宏的新增反例都通过;PowerShell 7.6.8 / PSReadLine 2.4.5 的两处失败与 Ubuntu CI 一致。两个对照都只调整测试时序或夹具,未改生产脚本:
test_redraw_install_failure_is_isolated_from_the_editor的正则没有匹配实际的Ctrl+Shift+F9参数,安装没有被拒绝。改用$args -contains 'Ctrl+Shift+F9'并断言拒绝标记后,重绘声明未发出,编辑器查询和指针初始化都成功。test_rebinding_to_a_same_name_scriptblock_revokes_the_advertisement等到PS>就立即发 F9,缓冲区收到~;。等下一次qa_ready并完成 PTY 的光标位置握手后,撤销声明与用户绑定都通过,缓冲区收到USER-F9。
请让夹具明确断言故障已注入,并等待下一次编辑器读取就绪,再重跑原生检查。当前 Ubuntu 和两个 macOS 原生检查仍为失败。
… the handshake The isolation fixture's refusal never fired: the stub pattern went through two escaping layers and became a regex matching a literal backslash, so Ctrl+Shift+F9 slipped through to the real cmdlet and the redraw advertised anyway. Match the argument with -contains instead and emit a SetUserVar marker before throwing, which the test asserts before the isolation conditions — a silently-passing stub can no longer hide. Rebinding-to-a-scriptblock keyed the raw chord as soon as the prompt appeared, inside the read's cursor-position handshake, so the escape sequence reached the editor split and the buffer received "~;". Wait for the next editor read to announce itself and settle the handshake before keying the chord; the revocation and USER-F9 assertions then hold.
|
Both are fixed on head 8a743a0, production scripts untouched:
|
Kuddev
left a comment
There was a problem hiding this comment.
复核了 8a743a01。Bash、zsh 和 PowerShell 7.6.8 的真实 PTY 套件有 35 项通过、3 项旧 PSReadLine 用例因缺模块跳过。上轮两处 PowerShell 夹具问题已修复。
新反例:zsh 启用 bindkey -v 且没有自定义重绘键时,当前实现仍会声明重绘能力:viins 有 .clear-screen,vicmd 的 undefined-key 也被视为安全。我在真实 zsh PTY 输入 printf 'LINE:%s\n' original,按 Esc 进入 vicmd,随后发送应用实际使用的 ESC [ 46 ~。按 Enter 后输出 LINE:originaL;省略清屏键或在 vicmd 也绑定原生 .clear-screen 时,均输出 LINE:original。未绑定的多字节序列并不一定会整体被忽略,尾部的 ~ 可以被 Vi 当作切换大小写命令。
请只在可到达的键表都能完整消费该重绘序列时声明能力,或在无法确认时回退到应用侧清屏。请把无自定义按键的 Vi 模式也纳入回归。当前 PR 保留待修改。
…he chord
A multi-byte chord is not consumed as a whole in an unbound keymap: zsh
vicmd and readline vi-command keep the trailing "~" bound to the
invert-case command, so a redraw sent into a merely-unbound keymap
rewrote the user's line ("original" became "originaL" in the review
reproduction). "Unbound is inert" is gone from the contract.
Installation now scans every reachable keymap and either installs the
built-in clear-screen into each of them — vi users keep the capability,
with vicmd / vi-command consuming the full chord mid-line — or, when any
keymap holds a user binding, installs nothing and the capability stays
off. zsh protected keymaps (.safe) refuse binding and cannot be reached
through a typed chord, so they are excluded from the contract instead of
killing it, and the per-prompt probe re-verifies exactly the recorded
keymap set: a rebind, an unbind, a macro or an unbound keymap all revoke
the announcement to the app-side cursor home.
The plain-vi-mode review reproduction is a regression now: the chord is
announced, sent after ESC, and the line must survive as LINE:original.
|
Handled on head 0aa8f10 (the branch also merged current main first). The ownership contract is now all-or-nothing across keymaps — your read of the hazard was exactly right, and "unbound is inert" is gone from both shells:
The all-or-nothing decision is recorded as an amendment in the clear-action design note. Locally the editor suite (25 tests, both new vi-mode cases included) is green; the bash-5 and PowerShell paths run on the Linux CI as before. |
- ShellSession.wait attributes each read window exactly up to its sentinel and carries the remainder into the next window; a read block that coalesced a command's sentinel with the following prompt's precmd markers could swallow the editor-ready marker into the previous command's output, which failed the zsh rebind revocation test on loaded macOS runners. - application_drag_stays_with_the_original_pane advances past the resize debounce gates before reading expectations or firing gestures; the pixel-driven grid resize could land between the read and the drag and encode one column past view.cols. - check_redraw_vi_mode_plain waits for the rendered newline it asserts.
|
Both CI failures on head c93b4ac (run 43674994798) are test-timing races, fixed on head a3833cb. No product code changed — between the green head 476ae02 and the red head the only delta was main's
|
|
Follow-up on head f093a23: the only change is formatting. The lint job's stable rustfmt breaks the settle chain differently than the pinned 1.97.1 ( |
…nal-action # Conflicts: # architecture/notes/pebrel_app/gpui_shell/2026-10-14-terminal-clear-action.md # pebrel_app/src/gpui_shell/terminal/view.rs
The macos-26-intel CI failure (Missing SetUserVar=pebrel_editor=) was a harness turn overlap, not an editor flake: the snapshot chord landed inside the previous chord's render burst, PSReadLine tore the ESC prefix into a standalone Escape plus literal tail keys (line reverted, buffer littered with ; / [ / ~), and the handler never ran. A byte-level trace of a failing run pinned the overlap (304 ms of zero output between two chord writes), and a 4-way parallel stress loop reproduced the signature in 23/40 runs. The harness now waits for the editor's first reaction byte after each write and drains the burst before the next chord, and answers cursor probes on a 20 ms poll instead of 100 ms. Assertions are unchanged; the same stress shows 0/40 tear failures afterwards. Evidence and the rejected alternatives are recorded in architecture/notes/pebrel_terminal/tty/2026-11-17-pointer-chord-turn-serialization.md.
|
Root-caused on head 79001f6: the remaining native-test failures on this PR are a test-harness defect, not an editor flake — as suspected, ours. Diagnosis. In the failing run (43903487733, macos-26-intel) a byte-level trace of both PTY directions shows the numeric query completing normally, then the move chord and the snapshot chord written 304 ms apart with zero output between them: pwsh had not yet reacted to the move chord when the snapshot chord landed inside its in-flight render burst. PSReadLine accepts an ESC-prefixed chord only while the rest of the sequence is already readable, so the burst overlap tears it into a standalone Escape plus literal tail keys — the captured renders show the line reverted to empty (Windows-mode Escape → RevertLine), A 4-way parallel stress loop on macOS x64 reproduces the exact signature in 23/40 runs; without load it never reproduces, which matches the intermittent CI picture. Fix (79001f6). The harness now serializes protocol turns: before writing any chord it waits (bounded) for the editor's first reaction byte to the previous write, then drains the burst to quiet ( The decision, rejected alternatives (retry-masking, longer quiet windows, chord redesign) and the production-exposure caveat (the GUI sends the same chords over a real PTY; the protocol's query/snapshot replies let it detect a desynchronized editor) are recorded in |
Result / 用户结果
Users can now bind a clear-screen shortcut themselves. The GPUI shell had no clear-screen action at all: the macOS config table's
⌘K → ClearHistorydefault executes only in the legacy shell, so after unbinding the Shell picker row ⌘K stayed inert and no settings row offered clear screen — the known limitation recorded in the 2026-09-21 macOS command-key aliases note ("⌘K after unbinding does not clear the screen").Settings → Key Bindings gains a Terminal-group "Clear screen / 清屏" row. No default shortcut changes on any platform: ⌘K stays on the Shell picker, and the feature is opt-in through a user
keybind=row (e.g.keybind=cmd+k:ClearHistory) that applies without restart.Design / 设计边界
gpui_shell/workspace/keyboard_bindings.rsmapsconfig::Action::ClearHistoryto a newClearTerminalworkspace action (alongside theSelectTab/QuitAppadapter actions);gpui_shell/terminal/view.rsimplements the pane-level clear;display/keymap.rsowns the editable row; catalogs addcommon.clear_screen. The existing keymap authority (config table +MACOS_COMMAND_ALIASESunbind vocabulary) is reused unchanged.ClearMode::All+Saved), the action branches on the pane's foreground state:nebula_prompt_active): writes^Lto that pane's PTY so the shell repaints its prompt on the fresh screen with its line state in sync (same visible behavior as the legacy ⌘K pair).^Lwould clear the screen a second time when the command exits, wiping the output produced in between. The view moves the terminal cursor home app-side; sequential output continues from the top.^Lis a redraw there, not a clear.^Lis a direct PTY write on the focused pane, not a user-input event, so broadcast fan-out is untouched.architecture/notes/nebula_app/gpui_shell/2026-10-14-terminal-clear-action.md.Evidence / 验证依据
cargo fmt --all -- --check;cargo check -p nebula --bin pebrel --features gpui-shell --tests --locked(0 errors);keyboard_bindings25 passed (including thegpui-test-supportdispatch module),display::keymap46 passed,settings_pane24 passed, i18n contract 24 passed,nebula-settings99 passed,file_line_budget2 passed;python3 scripts/check_architecture.py --base <merge-base 13659697>passes with budgets unchanged — the new action lives inkeyboard_bindings.rsspecifically becauseworkspace.rssits at its ratcheted 2773-line budget.clear_history_maps_to_the_clear_terminal_actionfails without the adapter arm (a user-bound clear must win over the static ⌘K picker binding while Ctrl+K stays on the picker);clear_screen_shortcut_dispatches_and_stays_out_of_the_terminal_streamfails without the dispatch path (the key must not enter the PTY input stream);clear_screen_is_editable_and_localized_through_the_typed_messagefails without the catalog entries.PEBREL_CONFIG_DIR): prompt clear repaints at the top-left, clear during a running command keeps output flowing from the top, vim is untouched, the Shell picker keeps Ctrl+K, and the binding survives restart. Platform/feature coverage limitation: Windows/Linux paths rely on the shared keymap tests and CI; no native manual run there.Required Review / 必须确认
CONTRIBUTING.md,docs/architecture.md, anddocs/project-constraints.md.python3 scripts/check_architecture.py --base <PR-base-commit>passes; budgets were not inflated to fit the change.