Visual Studio Code, rebuilt in Rust
Rust
docs(port): record the libghostty-vt terminal backend
rokarturc380712c1b39
diff --git a/port/ledger.md b/port/ledger.mdindex e949dc3419d..a0b7d1e363d 100644--- a/port/ledger.md+++ b/port/ledger.md@@ -364,7 +364,7 @@ One row per upstream unit, generated by `bun port/tools/gen-ledger.ts`; mileston| platform/state | src/vs/platform | M10 | verified | | storage/src/state.rs FileStorage (stateService.ts, immediate saves) with every state.test.ts case (cargo test -p storage state); User/globalStorage/storage.json keeps machineId, devDeviceId, the profiles and their associations || platform/storage | src/vs/platform | M10 | verified | | cargo test -p storage (storage.integrationTest.ts cases); port/tools/settings-check state: globalState and workspaceState survive a restart and the state.vscdb rows match the reference; the port keeps one Storage per scope (application = the default profile's, profile, workspace, shared for workspace trust) with synchronous writes, so storageService.test.ts's typed getters, StorageTarget and keys (Settings Sync, removed) and the change events between windows have no counterpart || platform/telemetry | src/vs/platform | M19 | verified | | product without enableTelemetry: supportsTelemetry false, NullTelemetryService, nothing sent (port/notes.md milestone 19); port/tools/privacy-check (Bun and Node, 5/5 each: isTelemetryEnabled false, TelemetryLogger never calls its sender, inert @vscode/extension-telemetry and vscode-tas-client); port/tools/telemetry-source-check |-| platform/terminal | src/vs/platform | M15 | verified | | terminal/pty.rs (node-pty), terminal.rs (process, environment, exit messages), terminal/profiles.rs, shell_integration.rs, prompt_input.rs, environment_collection.rs on alacritty_terminal; cargo test -p app terminal (105 tests) and the terminal api-tests (port/results/api-tests.md milestone 15: 47 passing, 0 failing); the pty host process layer is n/a (one process); terminal/pty.rs (node-pty), terminal.rs (process, environment, exit messages) on alacritty_terminal; cargo test -p app terminal |+| platform/terminal | src/vs/platform | M15 | verified | | terminal/pty.rs (node-pty), terminal.rs (process, environment, exit messages), terminal/profiles.rs, shell_integration.rs, prompt_input.rs, environment_collection.rs on libghostty-vt (native/crates/ghostty_vt, cargo test -p ghostty_vt); cargo test -p app terminal (105 tests) and the terminal api-tests (port/results/api-tests.md milestone 15: 47 passing, 0 failing); the pty host process layer is n/a (one process); terminal/pty.rs (node-pty), terminal.rs (process, environment, exit messages) on libghostty-vt (native/crates/ghostty_vt, cargo test -p ghostty_vt); cargo test -p app terminal || platform/test | src/vs/platform | M6 | n/a | | upstream test infrastructure; the port tests with cargo test and port/tools || platform/theme | src/vs/platform | M7 | verified | | registry defaults for dark, light, hcDark, hcLight with the color transforms (`transparent`, `withOpacity`, `darken`, `lighten`, `opaque`, `lessProminent`), `asCssVariableName` for webviews (theme.rs, webview.rs): every color the port resolves equals the reference workbench's `--vscode-*` variable in all 13 themes of port/fixtures/theme-colors (cargo test -p app theme::tests::resolved_colors_match_the_reference_workbench_variables); ids the port never paints stay unresolved; iconRegistry.ts and codicons.ts: every codicon and registered icon id draws the SVG of the code point codicon.css gives it, including codicons.ts's code point aliases (cargo test -p app codicons::tests::every_icon_id_draws_the_svg_of_its_code_point) || platform/tunnel | src/vs/platform | | removed | | no remote or tunnels by decision (port/notes.md); one local extension host |@@ -643,7 +643,7 @@ One row per upstream unit, generated by `bun port/tools/gen-ledger.ts`; mileston| workbench/contrib/tags | workbench contribution | | removed | | no AI or Microsoft services by decision (port/notes.md); API stays inert || workbench/contrib/tasks | workbench contribution | M15 | verified | | workbench/task_service.rs, workbench/task_quick_pick.rs, workbench/task_matcher_prompt.rs, workbench/task_configure.rs, workbench/configuration_resolver.rs, tasks/: cargo test -p app tasks:: task_quick_pick task_configure configuration_resolver task_matcher_prompt open_user_tasks user_tasks_are_listed the_run_task_picker_pins_items tasks_json_errors_go_to_the_tasks_output_channel string_arguments_resolve_against_the_active_file_and_its_folder task terminal presentation; ui-pair m11/user-tasks.json, m11/user-tasks-rerun.json (port/results/manage-menu.md) || workbench/contrib/telemetry | workbench contribution | M19 | verified | | the contribution logs to the NullTelemetryService and registers Show Telemetry only when supportsTelemetry, false in the built product: nothing to port; port/tools/telemetry-source-check no endpoint in 18370 shipped files (SELF_TEST finds 9 in the inert packages) |-| workbench/contrib/terminal | workbench contribution | M15 | verified | | workbench/terminal_view.rs, workbench/terminal_decorations.rs, terminal/marks.rs, terminal/serialize_html.rs, terminal/label.rs: cargo test -p app new_with_profile a_ctrl_d_exit_shows_no_exit_alert terminal::marks serialize_html terminal_decorations hover a_recording_keeps_each_kind_of_event toggle_visibility_writes_the_decorations_setting the_cwd_setting_resolves_its_variables terminal::label terminal_view::tests paths_are_quoted call_operator a_tab_row_is_inset_and_its_label_is_one_line_of_text panel_terminals_revive_in_their_groups_after_a_restart a_terminal_editor_revives_with_its_history_after_a_restart; ui-pair OSC 99, decorations, overview ruler, Copy as HTML, Record Terminal Session, terminal tabs (port/results/terminal.md), m12/folder-terminal.json (but the reference's Ports overflow, removed), m11/task-presentation.json (port/results/manage-menu.md) |+| workbench/contrib/terminal | workbench contribution | M15 | verified | | workbench/terminal_view.rs, workbench/terminal_decorations.rs, terminal/marks.rs, terminal/serialize_html.rs, terminal/label.rs: cargo test -p app new_with_profile a_ctrl_d_exit_shows_no_exit_alert terminal::marks serialize_html terminal_decorations hover a_recording_keeps_each_kind_of_event toggle_visibility_writes_the_decorations_setting the_cwd_setting_resolves_its_variables terminal::label terminal_view::tests paths_are_quoted call_operator a_tab_row_is_inset_and_its_label_is_one_line_of_text panel_terminals_revive_in_their_groups_after_a_restart a_terminal_editor_revives_with_its_history_after_a_restart, typing frame time (`cargo test --release -p app -- --ignored terminal_typing_frame_time`, p95 under 16 ms); ui-pair OSC 99, decorations, overview ruler, Copy as HTML, Record Terminal Session, terminal tabs (port/results/terminal.md), m12/folder-terminal.json (but the reference's Ports overflow, removed), m11/task-presentation.json (port/results/manage-menu.md) || workbench/contrib/terminalContrib | workbench contribution | M15 | verified | | terminal/link_parsing.rs, link_computer.rs, workbench/terminal_links.rs, terminal/auto_replies.rs, terminal/search.rs, workbench/terminal_find.rs, terminal/prompt_input.rs, workbench/terminal_suggest.rs, terminal/history.rs, workbench/terminal_quick_access.rs, terminal/sticky_scroll.rs, workbench/terminal_environment.rs, terminal/osc99.rs, terminal/quick_fix.rs, terminal/accessible_buffer.rs, workbench/terminal_initial_hint.rs: cargo test -p app link_ terminal::search prompt_input auto_replies terminal_contrib terminal_links terminal::history sticky_scroll quick_access environment_collection terminal::marks osc99 quick_fix accessible; ui-pair Run Recent Command, `term `, sticky scroll, the initial hint. No counterpart: Show Terminal Texture Atlas, Restart Pty Host. Removed: Copilot CLI, chat and voice (AI), wslRecommendation (Windows) (port/notes.md milestone 15) || workbench/contrib/testing | workbench contribution | M16 | verified | | cargo test -p app testing:: testing_filter testing_message_colorizer testing_results:: coverage the_gutter_menu_shows_the_tests_actions_before_the_line_number_items a_line_with_two_tests_shows_run_all_and_a_submenu_per_test reveal_in_test_explorer_expands_the_tests_parents the_run_group_dropdown_lists_its_profiles_and_runs_the_picked_one select_default_profile_stores_the_picked_defaults the_run_group_chevron_keeps_the_view_title_actions_in_the_side_bar runs_from_the_explorer_exclude_the_tests_the_filter_hides a_hidden_test_leaves_the_tree_and_runs_until_it_is_unhidden a_test_row_shows_the_test_item_menu_s_inline_group a_test_rows_context_menu_shows_and_runs_the_test_item_actions children_sort_by_line_then_by_file_name_order the_view_title_dropdown_starts_and_stops_one_profile_of_several continuous_run_using_picks_from_the_tests_controller_only a_continuous_run_holds_one_cancellable_request_per_profile_until_it_stops the_testing_item_spins view_as_list_shows_the_leaves_and_the_more_menu_checks_the_mode peek_error_opens_the_failed_childs_message_at_the_test a_test_run_waits_for_workspace_trust_and_completes_when_it_is_refused a_line_with_more_than_30_tests_picks_the_rest_from_a_quick_pick reveal_in_test_explorer_selects_and_scrolls_to_the_row the_run_group_chevron_is_active_while_its_menu_is_open the_workbench_context_has_the_testing_service_keys; ui-pair port/fixtures/debug-node with tests-provider (Testing tree, Run All, results tree, row menus, opened message, run glyphs and the gutter menu on math.test.js line 2, the run profile dropdown); ui-pair port/fixtures/testing-messages (diff message, markdown message output and selection copy, ANSI message, stack trace and a press in a frame); ui-pair m16/coverage.json; ui-pair m16/inline-coverage.json (Toggle Inline Coverage in the editor title, inline ranges with hit-count badges, the coverage toolbar); scrollbars: cargo test -p app the_panels_draw_their_bodies_in_a_scrollable || workbench/contrib/themes | workbench contribution | M9 | verified | | Color Theme picker (`workbench.action.selectTheme`, Cmd+K Cmd+T): rows, order and descriptions as the reference, 200ms preview, Escape restores, accept writes `workbench.colorTheme`; File Icon Theme picker (`workbench.action.selectIconTheme`, Themes submenu): None and the installed themes, preview, Escape restores, accept writes `workbench.iconTheme` (null for None) (cargo test -p app themes); Product Icon Theme picker (`workbench.action.selectProductIconTheme`, Themes submenu): Default and the installed themes, writes `workbench.productIconTheme` (cargo test -p app product_icon; product-icons-pair `picker`: the same rows, except the reference's "Test Product Icon Theme" of vscode-colorize-tests, a test extension the port does not ship); no Marketplace browsing, no `window.autoDetectColorScheme` |diff --git a/port/notes.md b/port/notes.mdindex 7ce270c8cea..f1d9aed757c 100644--- a/port/notes.md+++ b/port/notes.md@@ -629,7 +629,11 @@ Scope (milestone 13): diagnostics, hover, completion, go to definition and peek,## Milestone 15: integrated terminal-- Backend: `alacritty_terminal` 0.25 (Apache-2.0) is the VT parser and screen model in place of xterm.js; the PTY is the port's own node-pty (`terminal/pty.rs`: openpty, setsid, TIOCSCTTY, PWD set to the cwd as `unixTerminal.ts` does). Wu's `terminal` crate is GPL-3.0 and is not used.+- Backend: libghostty-vt 1.0.2 (MIT, tag `vt-1.0.2`, Ghostty's C API VT library) is the VT parser and screen model in place of xterm.js, behind `native/crates/ghostty_vt` (the only `unsafe` code of the terminal: bindgen bindings of `vt.h` in `sys.rs`, a safe `Term` in `lib.rs`); the PTY is the port's own node-pty (`terminal/pty.rs`: openpty, setsid, TIOCSCTTY, PWD set to the cwd as `unixTerminal.ts` does; ConPTY on Windows). Wu's `terminal` crate is GPL-3.0 and is not used. It replaced `alacritty_terminal` 0.25 for the parser's throughput and for a maintained VT core with a stable C ABI; `Term` keeps alacritty's shapes (`Line` relative to the active area's top, negative into the scrollback, `Point`, `Cell`, `Flags`, `TermMode`) so the call sites read the same.+- libghostty-vt build (`ghostty_vt/build.rs`): the release source and dependency tarballs from release.files.ghostty.org, checked against pinned SHA-256s, built with Zig 0.17 (`-Doptimize=ReleaseFast -Dcpu=baseline`, macOS deployment target 12.0 as `package-app`'s `LSMinimumSystemVersion`); `GHOSTTY_VT_LIB_DIR` links a prebuilt one instead. macOS arm64 and Linux arm64/x64 build their own target; Windows builds `*-windows-msvc` from source on Windows (windows.yml), while a cross build from macOS (`port/tools/windows-build`) links the `*-windows-gnu` archive with lld-link, as Zig 0.17 cannot compile the bundled simdutf and highway against cargo-xwin's MSVC SDK (Microsoft's link.exe rejects that archive's COMDATs, LNK1143, lld-link takes it). Zig is in the Linux image, linux.yml and windows.yml.+- libghostty-vt 1.0.2 drops U+FE0F after an emoji modifier base (U+270C, U+1F44D) outside grapheme cluster mode 2027, as its Unicode tables give those `emoji_modifier_base` and not `extended_pictographic`; xterm.js keeps it, so `build.rs` patches the one check in `Terminal.zig` (`a_variation_selector_stays_with_its_emoji`, prompt_input's `emoji_input`).+- What the port takes from libghostty-vt and what it keeps: the grid, scrollback, modes, cursor style, OSC 4/10/11/12 colors, title, bell, DA1/DA2/XTVERSION replies (set to xterm.js 6.1.0-beta.337's: `?1;2c`, `>0;276;0c`) come from libghostty-vt's callbacks; OSC 52, OSC 633/133/1337/7 stay with `terminal/shell_integration.rs` (it splits the stream before the parser), OSC 99 with `terminal/osc99.rs`, keys and mouse reports with `terminal/keys.rs` and `terminal/mouse.rs` (xterm.js's encodings, not libghostty-vt's key encoder). Selection follows alacritty 0.25's rules (`ghostty_vt/src/selection.rs`: simple, semantic, lines, block) with its anchors as libghostty-vt tracked references, so a selection moves with scrolled output as xterm.js's does.+- Terminal throughput and typing (Mac Studio, release): `cat` of 32 MB of colored `ls -l` lines into a 120x40 terminal with 10000 lines of scrollback, 143 MB/s with alacritty_terminal, 700 MB/s with libghostty-vt; reading the 4800 visible cells after one echoed key, p95 8 us with alacritty, 120 us with libghostty-vt (each cell is a grid reference call); a key echoed and the workbench drawn (`terminal_typing_frame_time`), p95 4.0 to 4.4 ms before and 4.0 to 5.1 ms after, against the 16 ms gate.- Keys follow xterm.js `Keyboard.ts` (`terminal/keys.rs`), mouse reports `CoreMouseService` DEFAULT and SGR (`terminal/mouse.rs`). `terminal/skip_shell.rs` is `DEFAULT_COMMANDS_TO_SKIP_SHELL` plus the terminalContrib lists of 1.147.0: a keybinding to one of them runs instead of reaching the shell.- The Terminal view is a panel view (milestone 11, `register_terminal_panel_view`); its title actions (the active terminal, New with the profiles dropdown, Split, Kill, per `tabs.showActiveTerminal` and `tabs.showActions`) are in the panel's title bar. The tabs list, splits and groups are drawn inside the view.- shortcut: the view title's "..." menu (a panel view's menu) is not ported. Contributed profiles came with 3108345ce25 (`a_contributed_profile_is_picked_and_created_by_its_provider`); the Ctrl+D exit exception keeps xtermTerminal.ts `lastInputEvent` (`a_ctrl_d_exit_shows_no_exit_alert`).@@ -637,7 +641,7 @@ Scope (milestone 13): diagnostics, hover, completion, go to definition and peek,- Cursor blinking: `cursorBlinking` is the default cursor style's blink, a program's DECSCUSR overrides it; the focused cursor toggles every 600 ms (`CursorBlinkStateManager`) and shows again on a key.- External terminal (`workbench/external_terminal.rs`): Open New External Terminal runs `/usr/bin/open -a <terminal.external.osxExec> <folder>`. shortcut: in a multi-root workspace the active editor's folder is used, where upstream asks with a folder picker.- Without workspace trust (not ported, see milestone 12) the restricted settings `terminal.integrated.profiles.osx`, `defaultProfile.osx`, `env.osx` and `cwd` are read from workspace settings too, as in the reference with `security.workspace.trust.enabled` off: a folder's `.vscode/settings.json` picks the shell and its arguments.-- OSC 52 writes reach the clipboard and the `?` query is answered with the clipboard's text (ClipboardAddon's `readText`); alacritty's `Osc52::CopyPaste`. Bracketed paste replaces ESC with U+241B as xterm's `bracketTextForPaste` does.+- OSC 52 writes reach the clipboard and the `?` query is answered with the clipboard's text (ClipboardAddon's `_setOrReportClipboard`, `terminal.rs` `clipboard_sequence`, fed by the shell integration scanner); the reply drops control characters from the selection parameter, as xterm.js's parser drops C0 inside OSC, so a CR in it cannot reach the shell. Bracketed paste replaces ESC with U+241B as xterm's `bracketTextForPaste` does.- The port opens a workspace folder by its resolved path, so a folder under `/var` shows as `/private/var` in the prompt where the reference shows `/var`; the cause is the workspace, not the terminal.- ui-pair of the profile picker, `exit` and the split rows (`/tmp/term/steps4.json` on the Studio): the picker sorts each list by name with the `defaultProfile.osx` profile first, shows a PATH profile by its basename (`isFromPath`) and has the "Configure Terminal Profile" gear button (copies the profile into `terminal.integrated.profiles.osx` under a new name); the tab row actions take no space until hovered (`.actions { display: none }`); the inline Split and Kill and the single tab entry follow `tabs.showActions` and `tabs.showActiveTerminal`.- Extension host (`workbench/terminal_host.rs`, mainThreadTerminalService.ts and mainThreadTerminalShellIntegration.ts): `$createTerminal` (shell path and args or the default profile, cwd without `terminal.integrated.cwd`, env merged or `strictEnv`, `hideFromUser` terminals outside the groups until `$show`, `location` parent splits), `$show`, `$hide` (closes the view tab), `$dispose`, `$sendText`, data and command event toggles, extension pseudoterminals (`$startExtensionTerminal`, `$sendProcessData/Ready/Property/Exit`, input as `$acceptProcessInput`), the change events (opened, closed with exit reason, active, process id, title, dimensions, shell type from the foreground process, selection, interaction) and `$acceptDefaultProfile`. Environment variable collections (`terminal/environment_collection.rs`) are applied to new terminals and kept in workspace storage (`terminal.integrated.environmentVariableCollectionsV2`).@@ -1057,7 +1061,7 @@ GPUI or Rust std limits Artur accepted as differences from 1.147.0; one line eac- GPUI's StyledText holds no inline elements: a dialog's message icon sits beside the text, so wraps under it differ.- GPUI text runs carry no font size: code spans of setting descriptions keep 13px where settingsEditor2.css sets 11px.- No screen reader announcements: the search editor's match navigation has no `alert`.-- Terminal persistence serializes the alternate screen when one is active, not the normal buffer: alacritty_terminal keeps `Term::inactive_grid` private (terminal/serialize.rs).+- Terminal persistence serializes the alternate screen when one is active, not the normal buffer: libghostty-vt's points address the active screen only (`GHOSTTY_TERMINAL_DATA_ACTIVE_SCREEN` names it; terminal/serialize.rs).- No ICU collation in Rust std: `localeCompare` (command palette, terminal suggest `ignorePunctuation`) and `compareFileNames` follow a few ASCII rules; non-ASCII punctuation and accents sort by code point. `editor.wordSegmenterLocales` keeps any well-formed BCP 47 tag, where V8 drops tags ICU has no segmenter data for.- GPUI text runs have no overline, double underline, baseline shift, font family or animation: the Debug Console drops SGR 53 (overline), 5/6 (blink), 10-20 (fonts) and 73/74 (super/subscript), and draws 21 (double underline) as a single underline.- GPUI's line wrapper counts a trailing space before a break where Chrome hangs it: the editor placeholder's 450px max width is 454px (editor_placeholder.rs), so a 450 to 454px line without a space there stays unwrapped.