diff --git a/Cargo.lock b/Cargo.lock index d61faf5c25..0ba7087a9e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5017,6 +5017,7 @@ dependencies = [ "ignore", "notify", "parking_lot", + "rayon", "rustix", "serde", "serde_json", diff --git a/crates/ide-core/src/settings.rs b/crates/ide-core/src/settings.rs index 23470f8960..f8af97d517 100644 --- a/crates/ide-core/src/settings.rs +++ b/crates/ide-core/src/settings.rs @@ -100,16 +100,6 @@ pub struct AgentSettings { pub smooth_text: bool, /// Conversations and the composer expand to the full width of the pane instead of staying in a centred column. pub fit_window_width: bool, - /// While the agent works, playful words fill the pauses in what it reports. - pub playful_status: bool, - /// Seconds the agent reports nothing new before the playful words take over; 0 shows them - /// from the start. - pub playful_after_seconds: u32, - /// The user's playful words by activity (`working`, `thinking`, `reading`, …), replacing - /// the built-in ones of that activity; an empty list keeps its status factual. - #[serde(deserialize_with = "or_default")] - #[specta(type = BTreeMap>)] - pub playful_words: BTreeMap>, #[serde(deserialize_with = "or_default")] #[specta(type = ThinkingDisplay)] pub thinking: ThinkingDisplay, @@ -152,9 +142,6 @@ impl Default for AgentSettings { fold_turns: true, smooth_text: true, fit_window_width: false, - playful_status: false, - playful_after_seconds: 0, - playful_words: BTreeMap::new(), thinking: ThinkingDisplay::Auto, tool_calls: ToolCallDisplay::Grouped, expand_tool_output: false, diff --git a/crates/ide-vfs/Cargo.toml b/crates/ide-vfs/Cargo.toml index 231dfb5141..01c31e468f 100644 --- a/crates/ide-vfs/Cargo.toml +++ b/crates/ide-vfs/Cargo.toml @@ -22,6 +22,7 @@ parking_lot.workspace = true zip.workspace = true flate2.workspace = true tar.workspace = true +rayon.workspace = true [dev-dependencies] tempfile.workspace = true diff --git a/crates/ide-vfs/src/lib.rs b/crates/ide-vfs/src/lib.rs index 4eed858fb7..d091ca3d0d 100644 --- a/crates/ide-vfs/src/lib.rs +++ b/crates/ide-vfs/src/lib.rs @@ -10,6 +10,7 @@ mod rules; mod watch; use ide_core::{IdeError, IdeResult}; +use rayon::prelude::*; use serde::{Deserialize, Serialize}; use specta::Type; use std::cmp::Ordering; @@ -133,51 +134,57 @@ pub fn read_dir(dir: &Path, excludes: &[String]) -> IdeResult> { let base = gitignore.repo_root().unwrap_or(dir).to_path_buf(); let excludes = ExcludeMatcher::new(excludes); - let mut entries: Vec<(bool, FileEntry)> = Vec::new(); - for entry in fs::read_dir(dir)? { - let entry = match entry { - Ok(e) => e, + let paths: Vec = fs::read_dir(dir)? + .filter_map(|entry| match entry { + Ok(e) => Some(e.path()), Err(e) => { tracing::debug!("read_dir {}: {e}", dir.display()); - continue; + None } - }; - let path = entry.path(); - let name = entry.file_name().to_string_lossy().into_owned(); - let Ok(lmeta) = fs::symlink_metadata(&path) else { continue }; - let (kind, meta, target_kind) = if lmeta.file_type().is_symlink() { - match fs::metadata(&path) { - Ok(m) => { - let target = if m.is_dir() { EntryKind::Dir } else { EntryKind::File }; - (EntryKind::Symlink, m, Some(target)) + }) + .collect(); + // One stat per entry dominates a large folder (and every stat is a round trip on a network + // share): stat in parallel; small folders stay on this thread. + let mut entries: Vec<(bool, FileEntry)> = paths + .into_par_iter() + .with_min_len(256) + .filter_map(|path| { + let name = path.file_name()?.to_string_lossy().into_owned(); + let lmeta = fs::symlink_metadata(&path).ok()?; + let (kind, meta, target_kind) = if lmeta.file_type().is_symlink() { + match fs::metadata(&path) { + Ok(m) => { + let target = if m.is_dir() { EntryKind::Dir } else { EntryKind::File }; + (EntryKind::Symlink, m, Some(target)) + } + Err(_) => (EntryKind::Symlink, lmeta, None), } - Err(_) => (EntryKind::Symlink, lmeta, None), - } - } else if lmeta.is_dir() { - (EntryKind::Dir, lmeta, None) - } else { - (EntryKind::File, lmeta, None) - }; - let is_dir = meta.is_dir(); - let rel = path.strip_prefix(&base).unwrap_or(&path); - let excluded = excludes.is_excluded(rel); - let ignored = excluded || gitignore.is_ignored(&path, is_dir); - entries.push(( - is_dir, - FileEntry { - hidden: name.starts_with('.'), - size: if is_dir { 0 } else { meta.len() }, - mtime_ms: mtime_ms(&meta), - name, - path: path.into(), - kind, - ignored, - excluded, - target_kind, - }, - )); - } - entries.sort_by(|(da, a), (db, b)| db.cmp(da).then_with(|| natural_cmp(&a.name, &b.name))); + } else if lmeta.is_dir() { + (EntryKind::Dir, lmeta, None) + } else { + (EntryKind::File, lmeta, None) + }; + let is_dir = meta.is_dir(); + let rel = path.strip_prefix(&base).unwrap_or(&path); + let excluded = excludes.is_excluded(rel); + let ignored = excluded || gitignore.is_ignored(&path, is_dir); + Some(( + is_dir, + FileEntry { + hidden: name.starts_with('.'), + size: if is_dir { 0 } else { meta.len() }, + mtime_ms: mtime_ms(&meta), + name, + path: path.into(), + kind, + ignored, + excluded, + target_kind, + }, + )) + }) + .collect(); + entries.par_sort_by(|(da, a), (db, b)| db.cmp(da).then_with(|| natural_cmp(&a.name, &b.name))); Ok(entries.into_iter().map(|(_, e)| e).collect()) } diff --git a/docs/en/guide/agents.mdx b/docs/en/guide/agents.mdx index 89f8c34421..ac9a2284b5 100644 --- a/docs/en/guide/agents.mdx +++ b/docs/en/guide/agents.mdx @@ -137,7 +137,7 @@ Tasks are saved per project and survive restarts. When the agent supports resumi - **Agent Configs**: discovers servers already configured in `~/.copilot/mcp-config.json` (and installed Copilot CLI plugins), `~/.claude.json`, `~/.codex/config.toml`, `~/.cursor/mcp.json`, `~/.gemini/settings.json`, `~/.jetbrains/mcp/mcp.json`, `.mcp.json`, and `.vscode/mcp.json` so you can import them into Global or Project settings with one click. You can also add or edit servers via structured fields or raw `mcpServers` JSON (**Add from JSON**), and run **Test Connection** to inspect the tools a server advertises. - **Per-session (`MCP` / `/mcp`)**: in both **New Agent Task** and active task conversations, open **MCP** in the composer toolbar (or run `/mcp`) to enable or disable individual servers—including the built-in `openidea` server—for that task only, or click **Reset** to return to the inherited defaults. -While the agent works, the line under the conversation says what it is doing: thinking, reading, editing, running a command, writing its reply. **Settings › Agents › Working Status** can show playful words for what it does there instead; they are off by default. Once turned on, they take turns from the moment the work changes, or only after the agent reports nothing new for a number of seconds (0 to 600, 0 by default); screen readers still hear what the agent is doing. Each word stays eight seconds while the agent keeps at the same work, and at least three when it moves on, so the line doesn't flicker. The same page replaces the words: pick what the status says (**Reading…**, **Running a command…**…) and add or remove its words. **Restore Built-in Words** brings back OpenIDEA's; an activity left without words keeps its plain status. +While the agent works, the line under the conversation says what it is doing: thinking, reading, editing, running a command, writing its reply. ## Add a custom agent diff --git a/docs/zh/guide/agents.mdx b/docs/zh/guide/agents.mdx index c04c1f49cc..09f482a13b 100644 --- a/docs/zh/guide/agents.mdx +++ b/docs/zh/guide/agents.mdx @@ -137,7 +137,7 @@ agent 运行过一个任务后,新任务会以它自动批准所有操作的 - **智能体配置**:自动发现 `~/.copilot/mcp-config.json`(及已安装的 Copilot CLI 插件)、`~/.claude.json`、`~/.codex/config.toml`、`~/.cursor/mcp.json`、`~/.gemini/settings.json`、`~/.jetbrains/mcp/mcp.json`、`.mcp.json` 和 `.vscode/mcp.json` 中已配置的服务器,可一键导入到全局或项目设置。添加或编辑服务器时既可使用表单,也可直接粘贴 `mcpServers` JSON(**从 JSON 添加**),并可通过 **测试连接** 查看服务器声明的工具列表。 - **按会话覆盖(`MCP` / `/mcp`)**:在 **新建 Agent 任务** 和进行中的任务对话中,单击输入框工具栏的 **MCP**(或输入 `/mcp`),即可仅针对当前任务开启或关闭任意服务器(包括内置的 `openidea` 服务器),或点击 **重置** 恢复继承的默认状态。 -agent 工作时,对话下方的状态行显示它正在做什么:思考、读取、编辑、运行命令、输出回复。在 **设置 › 智能体 › 工作状态** 中可以让这里改为显示与当前工作相关的趣味文字,默认关闭。开启后,工作一变化就轮换显示,也可以设置在 agent 无新进展多少秒后才显示(0 到 600,默认 0);屏幕阅读器读出的仍是 agent 实际在做的事。agent 持续做同一类工作时,每条文字停留八秒;转向其他工作时也至少停留三秒,状态行不会频繁跳动。同一页面还可以替换这些文字:选择状态(**正在读取…**、**正在运行命令…**…),再添加或移除对应的文字。**恢复内置文字** 会换回 OpenIDEA 自带的文字;没有任何文字的状态只显示实际进展。 +agent 工作时,对话下方的状态行显示它正在做什么:思考、读取、编辑、运行命令、输出回复。 ## 添加自定义 agent diff --git a/e2e/interactiveRebaseLayout.spec.ts b/e2e/interactiveRebaseLayout.spec.ts new file mode 100644 index 0000000000..7e2922fcb5 --- /dev/null +++ b/e2e/interactiveRebaseLayout.spec.ts @@ -0,0 +1,90 @@ +import { expect, stubDesktop, test } from "./fixtures"; + +test("Interactive rebase keeps commit messages and plan controls usable at narrow widths", async ({ + workbench: page, +}) => { + const first = "Keep regional settlement references stable when reconciling delayed ledger updates"; + const second = "Add settlement summary"; + await stubDesktop(page); + await page.evaluate( + async ({ first, second }) => { + const root = "/dev/acme-api"; + const id = (n: string) => n.repeat(40); + const commits = [ + { id: id("c"), shortId: "cccccccc", parents: [id("b")], summary: second, timeMs: 1795100200000 }, + { id: id("b"), shortId: "bbbbbbbb", parents: [id("a")], summary: first, timeMs: 1795100100000 }, + ].map((commit) => ({ + ...commit, + refs: [], + author: "Sam Rivera", + email: "sam@example.com", + message: commit.summary + "\n\nKeep the audit trail linked to the settlement job.", + })); + const h = window.__ipc.handlers; + h.vcs_roots = () => [{ root, operation: null, head: "main", headCommit: id("c") }]; + h.vcs_branch_info = () => ({ + head: "main", + headCommit: id("c"), + upstream: null, + ahead: 0, + behind: 0, + operation: null, + }); + h.vcs_status = () => []; + h.vcs_log = () => commits; + h.vcs_log_refs = () => ({}); + h.vcs_log_users = () => ["Sam Rivera "]; + h.vcs_config_get = () => null; + h.vcs_commit_files = () => []; + h.vcs_log_details_batch = () => []; + const vcsPath = "/src/features/vcs/store.ts"; + const { useVcs } = await import(/* @vite-ignore */ vcsPath); + useVcs.setState({ available: true, root, roots: [root], repo: root, branchesLoaded: true }); + const contextPath = "/src/platform/context.ts"; + (await import(/* @vite-ignore */ contextPath)).setContext("vcsAvailable", true); + const actionsPath = "/src/platform/actions.ts"; + await (await import(/* @vite-ignore */ actionsPath)).executeAction("vcs.showLog"); + }, + { first, second }, + ); + const log = page.getByRole("listbox", { name: "Commits" }); + await log.getByRole("option", { name: new RegExp(first) }).click({ button: "right" }); + await page.getByRole("menuitem", { name: /Interactively Rebase from Here/ }).click(); + const dialog = page.getByRole("dialog", { name: /Rebasing 2 commits/ }); + await expect(dialog).toBeVisible(); + + await page.setViewportSize({ width: 440, height: 640 }); + const list = dialog.getByRole("list", { name: "Commits to rebase" }); + const originalRows = list.getByRole("listitem"); + await dialog.getByRole("button", { name: "Action for bbbbbbbb" }).click(); + await page.getByRole("option", { name: "Reword", exact: true }).click(); + const reword = dialog.getByRole("textbox", { name: "New message for bbbbbbbb" }); + await expect(reword).toHaveValue(first + "\n\nKeep the audit trail linked to the settlement job."); + const editor = (await reword.boundingBox())!; + expect(editor.width).toBeGreaterThan(260); + expect(editor.height).toBeGreaterThan(160); + + const divider = dialog.getByRole("separator", { name: "Resize rebase panes" }); + await expect(divider).toHaveAttribute("aria-orientation", "horizontal"); + const start = dialog.getByRole("button", { name: "Start Rebasing" }); + await expect(start).toBeDisabled(); + const message = "Keep settlement references stable\n\nPreserve the audit trail."; + await reword.fill(message); + await expect(start).toBeEnabled(); + + await dialog.getByRole("button", { name: "Move Down" }).click(); + await expect(originalRows.first()).toContainText(second); + await expect(reword).toHaveValue(message); + await originalRows + .first() + .getByRole("button", { name: new RegExp(second) }) + .click(); + const details = dialog.getByRole("region", { name: "Commit details" }); + await expect(details).toContainText("Keep the audit trail linked to the settlement job."); + + await page.setViewportSize({ width: 1120, height: 760 }); + await expect(divider).toHaveAttribute("aria-orientation", "vertical"); + await expect(details).toContainText(second); + await dialog.getByRole("button", { name: "Cancel", exact: true }).click(); + await expect(dialog).toBeHidden(); +}); diff --git a/e2e/keymapLayout.spec.ts b/e2e/keymapLayout.spec.ts new file mode 100644 index 0000000000..a61ee3e21a --- /dev/null +++ b/e2e/keymapLayout.spec.ts @@ -0,0 +1,56 @@ +import { expect, test } from "./fixtures"; + +test("Keymap fits a narrow Settings pane and keeps shortcut editing reachable", async ({ workbench: page }) => { + await page.setViewportSize({ width: 1080, height: 760 }); + await page.keyboard.press("Meta+,"); + const settings = page.getByRole("dialog", { name: "Settings", exact: true }); + await settings.getByRole("treeitem", { name: "Keymap", exact: true }).click(); + + const search = settings.getByRole("textbox", { name: "Search actions" }); + const expand = settings.getByRole("button", { name: "Expand All", exact: true }); + await expect(search).toBeVisible(); + const wideSearch = (await search.boundingBox())!; + const wideExpand = (await expand.boundingBox())!; + expect(wideExpand.x).toBeLessThan(wideSearch.x); + expect(Math.abs(wideExpand.y - wideSearch.y)).toBeLessThan(8); + + await page.setViewportSize({ width: 520, height: 760 }); + const narrowSearch = (await search.boundingBox())!; + const narrowExpand = (await expand.boundingBox())!; + expect(narrowSearch.y).toBeGreaterThan(narrowExpand.y + narrowExpand.height); + + const body = settings.locator("[class*='pageBody']"); + const fitPane = () => + expect.poll(() => body.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1); + await fitPane(); + + await search.fill("Reformat Code"); + const tree = settings.getByRole("tree", { name: "Actions", exact: true }); + const action = tree + .getByRole("treeitem") + .filter({ hasText: /Reformat Code/ }) + .first(); + await action.click(); + await settings.getByRole("button", { name: "Add Keyboard Shortcut", exact: true }).click(); + const recorder = page.getByRole("dialog", { name: /Keyboard Shortcut: Reformat Code/ }); + await recorder.getByRole("textbox", { name: "First stroke" }).press("Control+Alt+Shift+F8"); + await expect(recorder.getByText("No conflicts")).toBeVisible(); + await recorder.getByRole("button", { name: "OK", exact: true }).click(); + await expect(action.locator("kbd").filter({ hasText: "F8" })).toHaveCount(1); + + const title = action.getByText(/Reformat Code/).first(); + await expect.poll(() => title.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1); + await tree.evaluate((el) => { + el.scrollLeft = el.scrollWidth; + }); + expect(await tree.evaluate((el) => el.scrollLeft)).toBeGreaterThan(0); + await fitPane(); + + await settings.getByRole("button", { name: "Find Actions by Shortcut" }).click(); + await settings.getByRole("textbox", { name: "Find actions by shortcut" }).press("Control+Alt+Shift+F8"); + await expect(action).toBeVisible(); + await fitPane(); + + await settings.getByRole("button", { name: "Apply", exact: true }).click(); + await expect(settings.getByRole("button", { name: "Apply", exact: true })).toBeDisabled(); +}); diff --git a/e2e/pluginsLayout.spec.ts b/e2e/pluginsLayout.spec.ts new file mode 100644 index 0000000000..3f0812462e --- /dev/null +++ b/e2e/pluginsLayout.spec.ts @@ -0,0 +1,62 @@ +import { expect, test } from "./fixtures"; + +test("Plugin management keeps the selected details reachable when Settings narrows", async ({ workbench: page }) => { + const name = "ReconciliationTimelineInspectorEnterprise"; + const notes = "SettlementTimeline".repeat(18); + await page.evaluate( + async ({ name, notes }) => { + const path = "/src/features/plugins/backend.ts"; + const { createMemoryPluginsBackend, setPluginsBackend } = await import(/* @vite-ignore */ path); + const { plugins } = await createMemoryPluginsBackend().list(); + const longPlugin = { ...plugins[0], id: "settlement-inspector", name, changeNotes: notes }; + setPluginsBackend(createMemoryPluginsBackend([longPlugin, ...plugins.slice(1)])); + }, + { name, notes }, + ); + + await page.setViewportSize({ width: 1080, height: 760 }); + await page.keyboard.press("Meta+,"); + const settings = page.getByRole("dialog", { name: "Settings", exact: true }); + await settings.getByRole("treeitem", { name: "Plugins", exact: true }).click(); + await settings.getByRole("tab", { name: "Installed", exact: true }).click(); + + const filter = settings.getByRole("textbox", { name: "Filter plugins" }); + const list = settings.getByRole("list", { name: "Installed plugins" }); + const details = settings.getByLabel(`${name} details`); + const heading = details.getByRole("heading", { name, exact: true }); + await expect(heading).toBeVisible(); + + const filterBox = (await filter.boundingBox())!; + const headingBox = (await heading.boundingBox())!; + expect(headingBox.x).toBeGreaterThan(filterBox.x + filterBox.width); + + await page.setViewportSize({ width: 520, height: 760 }); + const body = settings.locator("[class*='pageBody']"); + await expect.poll(() => body.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1); + const divider = settings.getByRole("separator", { name: "Resize plugin panes" }); + await expect(divider).toHaveAttribute("aria-orientation", "horizontal"); + const sources = settings.getByRole("tablist", { name: "Plugin sources" }); + await expect(sources.getByRole("tab", { name: "Marketplace" })).toBeVisible(); + await expect(sources.getByRole("tab", { name: "Installed" })).toBeVisible(); + expect(await sources.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1); + + const before = (await divider.boundingBox())!.y; + await divider.focus(); + await page.keyboard.press("ArrowDown"); + await expect.poll(async () => (await divider.boundingBox())!.y).toBeGreaterThan(before); + await expect(details.getByRole("button", { name: "Disable", exact: true })).toBeVisible(); + + await details.getByRole("tab", { name: "What's New" }).click(); + await expect(details.getByText(notes, { exact: true })).toBeVisible(); + expect(await details.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1); + + await filter.click(); + await expect(filter).toBeFocused(); + await filter.pressSequentially("Harbor"); + await list.getByRole("button", { name: /Harbor Night Theme/ }).click(); + await expect(settings.getByRole("heading", { name: "Harbor Night Theme", exact: true })).toBeVisible(); + await page.setViewportSize({ width: 1080, height: 760 }); + await expect(divider).toHaveAttribute("aria-orientation", "vertical"); + await expect(filter).toHaveValue("Harbor"); + await expect(settings.getByRole("heading", { name: "Harbor Night Theme", exact: true })).toBeVisible(); +}); diff --git a/patches/@codemirror__view.patch b/patches/@codemirror__view.patch new file mode 100644 index 0000000000..dbead9aecc --- /dev/null +++ b/patches/@codemirror__view.patch @@ -0,0 +1,30 @@ +diff --git a/dist/index.cjs b/dist/index.cjs +index b20aa9d84be6ff4b85b126bdd930065277668a26..e677ab06ca9668407e202979e14b75ab7641d6b1 100644 +--- a/dist/index.cjs ++++ b/dist/index.cjs +@@ -9675,7 +9675,9 @@ const hideNativeSelection = state.Prec.highest(EditorView.theme({ + "& :focus": { + caretColor: "initial !important", + ...drawMainRange ? { +- "&::selection, & ::selection": { ++ // Not `& ::selection` too: a pseudo-class with a universal descendant restyles the ++ // whole subtree of every element that gains or loses focus. ++ "&::selection": { + backgroundColor: "Highlight !important" + } + } : {} +diff --git a/dist/index.js b/dist/index.js +index 216f754db06f65f7f17f056b47d8f6fab45067bf..22282993239d836ea1da19af10ccfc61b6480cc5 100644 +--- a/dist/index.js ++++ b/dist/index.js +@@ -9670,7 +9670,9 @@ const hideNativeSelection = /*@__PURE__*/Prec.highest(/*@__PURE__*/EditorView.th + "& :focus": { + caretColor: "initial !important", + ...drawMainRange ? { +- "&::selection, & ::selection": { ++ // Not `& ::selection` too: a pseudo-class with a universal descendant restyles the ++ // whole subtree of every element that gains or loses focus. ++ "&::selection": { + backgroundColor: "Highlight !important" + } + } : {} diff --git a/perf/scenarios.ts b/perf/scenarios.ts index 2b50c1959a..37b358e6af 100644 --- a/perf/scenarios.ts +++ b/perf/scenarios.ts @@ -323,6 +323,18 @@ const scroll: Scenario = { }, }; +/** + * Runs an action without a default shortcut from a key press: the press is the measured input, + * and the action runs in its handler, as from a key binding. Pause is bound to nothing. + */ +async function runActionOnKey(h: Harness, id: string) { + await h.page.evaluate((id) => { + const probe = (window as never as { __openideaPerf: { runAction(id: string): Promise } }).__openideaPerf; + addEventListener("keydown", () => void probe.runAction(id), { capture: true, once: true }); + }, id); + await h.page.keyboard.press("Pause"); +} + /** * Git Log with 20,000 commits on branching lanes, loaded page by page as the * backend does (150 ms a page, like `git log`): showing it, walking the @@ -339,12 +351,7 @@ const gitLog: Scenario = { ).__openideaPerf.fakeGitLog(20_000, 150), ); const showMs = await h.measure( - () => - h.page.evaluate(() => - (window as never as { __openideaPerf: { runAction(id: string): Promise } }).__openideaPerf.runAction( - "vcs.showLog", - ), - ), + () => runActionOnKey(h, "vcs.showLog"), '[role="listbox"][aria-label="Commits"]', "order flow step 0", ); @@ -430,16 +437,13 @@ const resizePanels: Scenario = { await h.page.evaluate(() => (window as never as { __openideaPerf: { fakeGitLog(n: number): void } }).__openideaPerf.fakeGitLog(2_000), ); - await h.measure( - () => - h.page.evaluate(() => - (window as never as { __openideaPerf: { runAction(id: string): Promise } }).__openideaPerf.runAction( - "vcs.showLog", - ), - ), - '[role="listbox"][aria-label="Commits"]', - "order flow step 0", + await h.page.evaluate(() => + (window as never as { __openideaPerf: { runAction(id: string): Promise } }).__openideaPerf.runAction( + "vcs.showLog", + ), ); + // Set-up, not measured: the splitters are dragged once the log is shown. + await h.inPage((p) => p.waitShown('[role="listbox"][aria-label="Commits"]', "order flow step 0", 10_000)); const refresh = await h.refreshMs(); const drag = async (name: string, dx: number, dy: number) => { const box = (await h.page.getByRole("separator", { name }).boundingBox())!; @@ -560,7 +564,9 @@ const agentTabs: Scenario = { window as never as { __openideaPerf: { runAction(id: string, arg?: unknown): Promise } } ).__openideaPerf.runAction("agents.openSampleConversations", { tasks: 2, turns: 150 }), ); - const shown = (n: number) => `[data-editor-focus] span[title="Sample task ${n}"]`; + // The conversation shown: its requests end with its task's title. + const SHOWN = "[data-editor-focus] [data-message]"; + const title = (n: number) => `(Sample task ${n})`; // Both conversations get their earlier entries painted in background batches, also the // first one, hidden behind the second as soon as it opened. await h.page.waitForFunction( @@ -575,25 +581,28 @@ const agentTabs: Scenario = { // Rows painted while hidden are laid out the first time their conversation shows. for (const n of [1, 2]) { await h.page.getByRole("tab", { name: `Sample task ${n}` }).click(); - await h.page.locator(shown(n)).waitFor(); + await h.page + .locator(SHOWN, { hasText: title(n) }) + .first() + .waitFor(); await h.page.waitForTimeout(300); } // WebKit restyles a hidden conversation in full when it is shown again (Chromium keeps its // style): what bounds that there is the history's DOM, and rows skipping rendering off screen. const { conversationNodes, rowsAlwaysRendered } = await h.page.evaluate((selector) => { - const conversation = document.querySelector(selector)!.closest("[data-editor-focus]")!; + const conversation = document.querySelector(selector)!; const rows = [...conversation.querySelector("[data-message]")!.parentElement!.children]; return { conversationNodes: conversation.querySelectorAll("*").length, rowsAlwaysRendered: rows.filter((r) => getComputedStyle(r).contentVisibility !== "auto").length, }; - }, shown(2)); + }, "[data-editor-focus]"); const t0 = await h.now(); const before = await h.counters(); const switches: number[] = []; for (let i = 0; i < 10; i++) { - switches.push(await h.measure(() => h.pressAction("navigate.switcher"), shown(i % 2 ? 2 : 1))); + switches.push(await h.measure(() => h.pressAction("navigate.switcher"), SHOWN, title(i % 2 ? 2 : 1))); await h.page.waitForTimeout(150); } const work = Harness.delta(before, await h.counters()); @@ -602,10 +611,7 @@ const agentTabs: Scenario = { // Scrolling up from the end, a step at a time: how far the text under the pointer moves // beyond the scroll itself. const scrollJumps = await h.page.evaluate(async (selector) => { - const stream = document - .querySelector(selector)! - .closest("[data-editor-focus]")! - .querySelector("[data-message]")!.parentElement!; + const stream = document.querySelector(selector)!.parentElement!; const frame = () => new Promise(requestAnimationFrame); stream.scrollTop = stream.scrollHeight; await frame(); @@ -626,7 +632,7 @@ const agentTabs: Scenario = { } stream.scrollTop = stream.scrollHeight; return jumps; - }, shown(2)); + }, SHOWN); const refresh = await h.refreshMs(); const box = (await h.page.locator("[data-editor-focus]").boundingBox())!; @@ -732,6 +738,9 @@ const projectTree: Scenario = { async run(h) { const generated = h.page.locator('[role="treeitem"][aria-level="2"]', { hasText: "generated" }).first(); await generated.click(); + // Measure from a settled selection: a key pressed in the click's own frame also pays for that frame. + await generated.and(h.page.locator('[aria-selected="true"]')).waitFor(); + await h.page.evaluate(() => new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(r)))); const expandMs = await h.measure( () => h.page.keyboard.press("ArrowRight"), '[role="tree"][aria-label="Project"]', diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a89062f9b1..6f0d4a8338 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -7,6 +7,9 @@ settings: overrides: mermaid>katex: ^0.18.2 +patchedDependencies: + '@codemirror/view': 0ee18e0fe711bd749ccc9f89f3566c74b5e08910f2892e166d207f286b0da0c5 + importers: .: @@ -61,7 +64,7 @@ importers: version: 6.7.6 '@codemirror/view': specifier: ^6.43.14 - version: 6.43.14 + version: 6.43.14(patch_hash=0ee18e0fe711bd749ccc9f89f3566c74b5e08910f2892e166d207f286b0da0c5) '@floating-ui/react-dom': specifier: ^2.1.9 version: 2.1.9(react-dom@19.3.1(react@19.3.1))(react@19.3.1) @@ -85,7 +88,7 @@ importers: version: 1.2.0 '@replit/codemirror-vim': specifier: 6.4.0 - version: 6.4.0(@codemirror/commands@6.11.1)(@codemirror/language@6.13.1)(@codemirror/search@6.7.2)(@codemirror/state@6.7.6)(@codemirror/view@6.43.14) + version: 6.4.0(@codemirror/commands@6.11.1)(@codemirror/language@6.13.1)(@codemirror/search@6.7.2)(@codemirror/state@6.7.6)(@codemirror/view@6.43.14(patch_hash=0ee18e0fe711bd749ccc9f89f3566c74b5e08910f2892e166d207f286b0da0c5)) '@tanstack/react-virtual': specifier: ^3.14.21 version: 3.14.21(react-dom@19.3.1(react@19.3.1))(react@19.3.1) @@ -591,7 +594,6 @@ packages: engines: {node: ^20.19.0 || >=22.12.0} cpu: [riscv64] os: [linux] - libc: [glibc] '@oxc-parser/binding-linux-riscv64-musl@0.155.0': resolution: {integrity: sha512-JSlhgoK+/g1TGJI5NuADx2+6syhxnQNLCWLXyO5QLFyetomcr/vIxSdiNlmyAv963YXUzCuwAwRG6npZ5xyJ1A==} @@ -1069,7 +1071,6 @@ packages: engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [linux] - libc: [musl] '@rolldown/binding-linux-ppc64-gnu@1.2.14': resolution: {integrity: sha512-4+Kl8daPV8NDHaD7mfCcc1pRM+Qg7ab8DyMm5FG5WoZgv4h2i3KFN1CybYBNbQqmuYm7ftJLvmMI1eHYJ22S/Q==} @@ -1083,14 +1084,12 @@ packages: engines: {node: ^20.19.0 || >=22.12.0} cpu: [s390x] os: [linux] - libc: [glibc] '@rolldown/binding-linux-x64-gnu@1.2.14': resolution: {integrity: sha512-WxalXzgrLVpKC93xfpaJ3gCXUWzeCr+FRCbDVD2mUAy4L6Vo3lNVz0epUEUpxPWJkLNYUwM4OSIikv36OJ9mLg==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [x64] os: [linux] - libc: [glibc] '@rolldown/binding-linux-x64-musl@1.2.14': resolution: {integrity: sha512-3G3tnAmTpdk9jO3GQtyHXqeFD2SlecfTws/Y3M2mmj9nMBwwuLT4kur8sZKeu7ENUHSpVO3cIsm5A52LEWWwlg==} @@ -1864,7 +1863,6 @@ packages: engines: {node: '>= 12.0.0'} cpu: [arm64] os: [linux] - libc: [glibc] lightningcss-linux-arm64-musl@1.33.0: resolution: {integrity: sha512-yiO5ROMuYQgXbC60yjZU5CYSFZGKXL0HFATXt9mHJn1+zW55oCtMI9NfcVhYLMFDL7gV7oBPon/EmMMGg2OvtQ==} @@ -1878,14 +1876,12 @@ packages: engines: {node: '>= 12.0.0'} cpu: [x64] os: [linux] - libc: [glibc] lightningcss-linux-x64-musl@1.33.0: resolution: {integrity: sha512-RYiYbkokw0trfKqqzfF55lginwEPrD3OJDfTuJzFs1MK6iFnDenaz1fqLLtX4ITG3OktJQXOeTaw1awrBAlZPw==} engines: {node: '>= 12.0.0'} cpu: [x64] os: [linux] - libc: [musl] lightningcss-win32-arm64-msvc@1.33.0: resolution: {integrity: sha512-1K+MPfLSFVpphzpdbfkhlWk6wBrTObBzS2T6db10PNOZgR9GoVsAWzwNyuhUYYbTp23j+4RrncfujZ4uAzXvwA==} @@ -2391,14 +2387,14 @@ snapshots: dependencies: '@codemirror/language': 6.13.1 '@codemirror/state': 6.7.6 - '@codemirror/view': 6.43.14 + '@codemirror/view': 6.43.14(patch_hash=0ee18e0fe711bd749ccc9f89f3566c74b5e08910f2892e166d207f286b0da0c5) '@lezer/common': 1.5.3 '@codemirror/commands@6.11.1': dependencies: '@codemirror/language': 6.13.1 '@codemirror/state': 6.7.6 - '@codemirror/view': 6.43.14 + '@codemirror/view': 6.43.14(patch_hash=0ee18e0fe711bd749ccc9f89f3566c74b5e08910f2892e166d207f286b0da0c5) '@lezer/common': 1.5.3 '@codemirror/lang-angular@0.1.4': @@ -2438,7 +2434,7 @@ snapshots: '@codemirror/lang-javascript': 6.2.5 '@codemirror/language': 6.13.1 '@codemirror/state': 6.7.6 - '@codemirror/view': 6.43.14 + '@codemirror/view': 6.43.14(patch_hash=0ee18e0fe711bd749ccc9f89f3566c74b5e08910f2892e166d207f286b0da0c5) '@lezer/common': 1.5.3 '@lezer/css': 1.3.9 '@lezer/html': 1.3.13 @@ -2454,7 +2450,7 @@ snapshots: '@codemirror/language': 6.13.1 '@codemirror/lint': 6.9.7 '@codemirror/state': 6.7.6 - '@codemirror/view': 6.43.14 + '@codemirror/view': 6.43.14(patch_hash=0ee18e0fe711bd749ccc9f89f3566c74b5e08910f2892e166d207f286b0da0c5) '@lezer/common': 1.5.3 '@lezer/javascript': 1.5.6 @@ -2464,7 +2460,7 @@ snapshots: '@codemirror/lang-html': 6.4.12 '@codemirror/language': 6.13.1 '@codemirror/state': 6.7.6 - '@codemirror/view': 6.43.14 + '@codemirror/view': 6.43.14(patch_hash=0ee18e0fe711bd749ccc9f89f3566c74b5e08910f2892e166d207f286b0da0c5) '@lezer/common': 1.5.3 '@lezer/highlight': 1.2.5 '@lezer/lr': 1.4.11 @@ -2488,7 +2484,7 @@ snapshots: '@codemirror/lang-html': 6.4.12 '@codemirror/language': 6.13.1 '@codemirror/state': 6.7.6 - '@codemirror/view': 6.43.14 + '@codemirror/view': 6.43.14(patch_hash=0ee18e0fe711bd749ccc9f89f3566c74b5e08910f2892e166d207f286b0da0c5) '@lezer/common': 1.5.3 '@lezer/highlight': 1.2.5 '@lezer/lr': 1.4.11 @@ -2499,7 +2495,7 @@ snapshots: '@codemirror/lang-html': 6.4.12 '@codemirror/language': 6.13.1 '@codemirror/state': 6.7.6 - '@codemirror/view': 6.43.14 + '@codemirror/view': 6.43.14(patch_hash=0ee18e0fe711bd749ccc9f89f3566c74b5e08910f2892e166d207f286b0da0c5) '@lezer/common': 1.5.3 '@lezer/markdown': 1.8.0 @@ -2562,7 +2558,7 @@ snapshots: '@codemirror/autocomplete': 6.20.3 '@codemirror/language': 6.13.1 '@codemirror/state': 6.7.6 - '@codemirror/view': 6.43.14 + '@codemirror/view': 6.43.14(patch_hash=0ee18e0fe711bd749ccc9f89f3566c74b5e08910f2892e166d207f286b0da0c5) '@lezer/common': 1.5.3 '@lezer/xml': 1.0.6 @@ -2606,7 +2602,7 @@ snapshots: dependencies: '@codemirror/state': 6.7.6 '@codemirror/streamparser': 6.0.0 - '@codemirror/view': 6.43.14 + '@codemirror/view': 6.43.14(patch_hash=0ee18e0fe711bd749ccc9f89f3566c74b5e08910f2892e166d207f286b0da0c5) '@lezer/common': 1.5.3 '@lezer/highlight': 1.2.5 '@lezer/lr': 1.4.11 @@ -2619,21 +2615,21 @@ snapshots: '@codemirror/lint@6.9.7': dependencies: '@codemirror/state': 6.7.6 - '@codemirror/view': 6.43.14 + '@codemirror/view': 6.43.14(patch_hash=0ee18e0fe711bd749ccc9f89f3566c74b5e08910f2892e166d207f286b0da0c5) crelt: 1.0.7 '@codemirror/merge@6.12.2': dependencies: '@codemirror/language': 6.13.1 '@codemirror/state': 6.7.6 - '@codemirror/view': 6.43.14 + '@codemirror/view': 6.43.14(patch_hash=0ee18e0fe711bd749ccc9f89f3566c74b5e08910f2892e166d207f286b0da0c5) '@lezer/highlight': 1.2.5 style-mod: 4.1.4 '@codemirror/search@6.7.2': dependencies: '@codemirror/state': 6.7.6 - '@codemirror/view': 6.43.14 + '@codemirror/view': 6.43.14(patch_hash=0ee18e0fe711bd749ccc9f89f3566c74b5e08910f2892e166d207f286b0da0c5) crelt: 1.0.7 '@codemirror/state@6.7.6': @@ -2642,7 +2638,7 @@ snapshots: '@codemirror/streamparser@6.0.0': {} - '@codemirror/view@6.43.14': + '@codemirror/view@6.43.14(patch_hash=0ee18e0fe711bd749ccc9f89f3566c74b5e08910f2892e166d207f286b0da0c5)': dependencies: '@codemirror/state': 6.7.6 crelt: 1.0.7 @@ -3105,13 +3101,13 @@ snapshots: '@replit/codemirror-vim-core@0.1.0': {} - '@replit/codemirror-vim@6.4.0(@codemirror/commands@6.11.1)(@codemirror/language@6.13.1)(@codemirror/search@6.7.2)(@codemirror/state@6.7.6)(@codemirror/view@6.43.14)': + '@replit/codemirror-vim@6.4.0(@codemirror/commands@6.11.1)(@codemirror/language@6.13.1)(@codemirror/search@6.7.2)(@codemirror/state@6.7.6)(@codemirror/view@6.43.14(patch_hash=0ee18e0fe711bd749ccc9f89f3566c74b5e08910f2892e166d207f286b0da0c5))': dependencies: '@codemirror/commands': 6.11.1 '@codemirror/language': 6.13.1 '@codemirror/search': 6.7.2 '@codemirror/state': 6.7.6 - '@codemirror/view': 6.43.14 + '@codemirror/view': 6.43.14(patch_hash=0ee18e0fe711bd749ccc9f89f3566c74b5e08910f2892e166d207f286b0da0c5) '@replit/codemirror-vim-core': 0.1.0 '@rolldown/binding-android-arm-eabi@1.2.14': diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index e2b74a7111..28d9eac998 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -3,3 +3,5 @@ allowBuilds: overrides: # GHSA-238p-pmpm-9mq7 (fixed in 0.18.2); mermaid 12.1 still asks for katex ^0.16. mermaid>katex: ^0.18.2 +patchedDependencies: + "@codemirror/view": patches/@codemirror__view.patch diff --git a/src/bindings.ts b/src/bindings.ts index 08e2cd677d..53dc5457c8 100644 --- a/src/bindings.ts +++ b/src/bindings.ts @@ -2602,18 +2602,6 @@ export type AgentSettings_Deserialize = { smoothText?: boolean, /** Conversations and the composer expand to the full width of the pane instead of staying in a centred column. */ fitWindowWidth?: boolean, - /** While the agent works, playful words fill the pauses in what it reports. */ - playfulStatus?: boolean, - /** - * Seconds the agent reports nothing new before the playful words take over; 0 shows them - * from the start. - */ - playfulAfterSeconds?: number, - /** - * The user's playful words by activity (`working`, `thinking`, `reading`, …), replacing - * the built-in ones of that activity; an empty list keeps its status factual. - */ - playfulWords?: { [key in string]: string[] }, thinking?: ThinkingDisplay, toolCalls?: ToolCallDisplay, /** A tool call's output (a command's, a diff) is shown without opening it. */ @@ -2654,18 +2642,6 @@ export type AgentSettings_Serialize = { smoothText: boolean, /** Conversations and the composer expand to the full width of the pane instead of staying in a centred column. */ fitWindowWidth: boolean, - /** While the agent works, playful words fill the pauses in what it reports. */ - playfulStatus: boolean, - /** - * Seconds the agent reports nothing new before the playful words take over; 0 shows them - * from the start. - */ - playfulAfterSeconds: number, - /** - * The user's playful words by activity (`working`, `thinking`, `reading`, …), replacing - * the built-in ones of that activity; an empty list keeps its status factual. - */ - playfulWords: { [key in string]: string[] }, thinking: ThinkingDisplay, toolCalls: ToolCallDisplay, /** A tool call's output (a command's, a diff) is shown without opening it. */ diff --git a/src/editor/core/cm/cornerInset.ts b/src/editor/core/cm/cornerInset.ts index de0ae8fe08..6e90f5da39 100644 --- a/src/editor/core/cm/cornerInset.ts +++ b/src/editor/core/cm/cornerInset.ts @@ -51,7 +51,9 @@ class CornerInset { private measure() { const corner = this.corner; - if (!corner) return; + // A hidden tab's view is detached and measures 0: keeping the inset spares every line + // a restyle when the tab hides and another when it shows again. + if (!corner || !this.view.dom.isConnected) return; const width = corner.getBoundingClientRect().width; let inset = width > 0 ? round(width) + CORNER_GAP : 0; // A narrow window or a wide corner: keep at least half of the width for text. diff --git a/src/editor/core/cm/indentGuides.ts b/src/editor/core/cm/indentGuides.ts index bd80022f23..1be1a066b6 100644 --- a/src/editor/core/cm/indentGuides.ts +++ b/src/editor/core/cm/indentGuides.ts @@ -20,16 +20,12 @@ import { countColumn, Facet, RangeSetBuilder, type EditorState, type Extension } import { Decoration, EditorView, ViewPlugin, type DecorationSet, type ViewUpdate } from "@codemirror/view"; import { getIndentUnit, matchBrackets, syntaxTree } from "@codemirror/language"; import { LINE_INSET } from "./lineInset"; +import { SPACE, spaceWidth } from "./spaceWidth"; import { BRACKET_COLORS, LONG_LINE, bracketScanner, type BracketScanner } from "./rainbowBrackets"; /** How far (px) a guide sits left of its column, so a caret in that column is right of it (IDEA's indent guide shift). */ const GUIDE_SHIFT = 2; -/** One column of indentation: a space in the editor font, as measured by the guides plugin. */ -const SPACE = "var(--openidea-space, 1ch)"; - -const SPACE_SAMPLE = 64; - /** Number of `--openidea-guide-` rainbow colours; deeper guides repeat them. */ export const GUIDE_COLORS = 5; @@ -325,37 +321,20 @@ function build( } export const indentGuides: Extension = [ + spaceWidth, ViewPlugin.fromClass( class { decorations: DecorationSet; - private probe: HTMLElement; private brackets: BracketCache[] = []; /** Guide variables of each decorated line, by its start: code lens rows above it repeat them. */ private lineVars = new Map(); private scanner: BracketScanner | null; constructor(readonly view: EditorView) { - // Inherits the editor font from the scroller, outside the content CodeMirror observes; - // the measured width goes on the scroller, where lines and code lens rows pick it up. - this.probe = document.createElement("span"); - this.probe.setAttribute("aria-hidden", "true"); - this.probe.style.cssText = "position: absolute; top: 0; left: 0; visibility: hidden; white-space: pre"; - this.probe.textContent = " ".repeat(SPACE_SAMPLE); - view.scrollDOM.appendChild(this.probe); const scanner = bracketScanner(view); this.scanner = scanner; this.decorations = build(view, scanner, this.brackets, this.lineVars); - this.measure(); this.syncLenses(); } - measure() { - this.view.requestMeasure({ - key: this, - read: (view) => this.probe.getBoundingClientRect().width / (view.scaleX || 1) / SPACE_SAMPLE, - write: (width, view) => { - if (width > 0) view.scrollDOM.style.setProperty("--openidea-space", `${+width.toFixed(3)}px`); - }, - }); - } /** Gives code lens rows the guides of the line they annotate, once they are in the DOM. */ syncLenses() { this.view.requestMeasure({ @@ -379,15 +358,12 @@ export const indentGuides: Extension = [ }); } destroy() { - this.probe.remove(); - this.view.scrollDOM.style.removeProperty("--openidea-space"); for (const el of this.view.contentDOM.querySelectorAll(".cm-openidea-lens")) { el.style.removeProperty("--openidea-guide-images"); el.style.removeProperty("--openidea-guide-positions"); } } update(u: ViewUpdate) { - if (u.geometryChanged) this.measure(); const scanner = bracketScanner(u.view); // A new scanner (rainbow brackets toggled or reconfigured) may colour blocks differently. const bracketsChanged = scanner !== this.scanner; diff --git a/src/editor/core/cm/prewarm.test.ts b/src/editor/core/cm/prewarm.test.ts new file mode 100644 index 0000000000..f6726b68f7 --- /dev/null +++ b/src/editor/core/cm/prewarm.test.ts @@ -0,0 +1,31 @@ +import { afterEach, expect, it, vi } from "vitest"; +import { registerEditorContribution } from "@/editor/api"; +import { prewarmEditor } from "./prewarm"; + +afterEach(() => vi.unstubAllGlobals()); + +it("builds an off-screen editor with embedded contributions only, then removes it", () => { + let frame: FrameRequestCallback | undefined; + vi.stubGlobal("requestAnimationFrame", (f: FrameRequestCallback) => ((frame = f), 1)); + const seen: string[] = []; + const offEmbedded = registerEditorContribution({ + id: "test.embedded", + embedded: true, + extensions: (ctx) => (seen.push(`embedded ${ctx.doc}`), []), + }); + const offFile = registerEditorContribution({ + id: "test.file", + extensions: () => (seen.push("file"), []), + }); + try { + prewarmEditor(); + expect(document.querySelectorAll(".cm-editor")).toHaveLength(1); + expect(seen).toEqual(["embedded -1"]); + frame!(0); + expect(document.querySelector(".cm-editor")).toBeNull(); + expect(document.body.children).toHaveLength(0); + } finally { + offEmbedded(); + offFile(); + } +}); diff --git a/src/editor/core/cm/prewarm.ts b/src/editor/core/cm/prewarm.ts new file mode 100644 index 0000000000..8fa78158f6 --- /dev/null +++ b/src/editor/core/cm/prewarm.ts @@ -0,0 +1,55 @@ +import { EditorState, type Extension } from "@codemirror/state"; +import { EditorView } from "@codemirror/view"; +import { editorContributions, type EditorDocContext } from "@/editor/api"; +import { baseExtensions } from "./setup"; + +/** + * Builds and drops an off-screen editor with the file editors' setup, so the first file opened + * does not also pay for compiling the editor code and mounting its stylesheets. The document is + * virtual and empty, and only contributions that accept such editors (`embedded`) take part: + * nothing reaches a language server or the file system. + */ +export function prewarmEditor(): void { + const host = document.createElement("div"); + host.setAttribute("aria-hidden", "true"); + host.style.cssText = "position:fixed;left:-10000px;top:0;width:480px;height:240px;visibility:hidden;contain:strict"; + document.body.appendChild(host); + const ctx: EditorDocContext = { + doc: -1, + path: "prewarm.txt", + language: "plaintext", + uiMode: null, + readOnly: true, + virtual: true, + }; + const contributions: Extension[] = []; + for (const c of editorContributions()) { + if (!c.embedded) continue; + try { + contributions.push(c.extensions(ctx)); + } catch { + // Warming is best effort: the real editor reports a failing contribution. + } + } + const view = new EditorView({ + parent: host, + state: EditorState.create({ + doc: "", + extensions: baseExtensions({ + ctx, + settings: undefined, + info: undefined, + language: null, + docLength: 0, + indent: { tabSize: 4, insertSpaces: true }, + wrapOverride: false, + contributions, + }), + }), + }); + // One frame so its measure pass runs too, then nothing of it is left behind. + requestAnimationFrame(() => { + view.destroy(); + host.remove(); + }); +} diff --git a/src/editor/core/cm/renderedDocs.gutter.test.ts b/src/editor/core/cm/renderedDocs.gutter.test.ts index 67db521fa6..a4239fc52f 100644 --- a/src/editor/core/cm/renderedDocs.gutter.test.ts +++ b/src/editor/core/cm/renderedDocs.gutter.test.ts @@ -189,7 +189,7 @@ it("indents by the code's character width, so a font size change keeps it in lin const v = open(true, ["class A {", "\t/**", "\t * Books.", "\t */", "\tvoid book() {}", "}"].join("\n")); const body = v.dom.querySelector(".cm-openidea-renderedDoc")!; // A tab is a tab size of columns, not one character. - expect(body.style.marginLeft).toContain(`${v.state.tabSize} * var(--openidea-doc-char`); + expect(body.style.marginLeft).toContain(`${v.state.tabSize} * var(--openidea-space`); }); it("forgets a flip whose comment is deleted, so the feature turns off again", async () => { diff --git a/src/editor/core/cm/renderedDocs.ts b/src/editor/core/cm/renderedDocs.ts index e589a9ed81..474bb36c60 100644 --- a/src/editor/core/cm/renderedDocs.ts +++ b/src/editor/core/cm/renderedDocs.ts @@ -61,6 +61,7 @@ import { tx, useI18n } from "@/platform/i18n"; import { loadMarkdown, markupToHtml } from "@/editor/lsp/markdown"; import { hasContent, renderDoc, type DocComment, type DocStyle, type RenderedDoc } from "./docRender"; import { LINE_INSET } from "./lineInset"; +import { SPACE, spaceWidth } from "./spaceWidth"; /** The file's default: render its doc comments or not. */ export const renderDocComments = Facet.define({ @@ -320,9 +321,9 @@ class DocWidget extends WidgetType { const titles = doc.sections.map(sectionTitle); const dom = document.createElement("div"); dom.className = "cm-openidea-renderedDoc"; - // In the code's character width, which `docMetrics` keeps current: the DOM stays - // right through a font size change or zoom, which does not draw the widget again. - const left = `(${this.indent} * var(--openidea-doc-char, 1ch) + ${LINE_INSET}px)`; + // In columns of the code's font (`spaceWidth`): the DOM stays right through a font + // size change or zoom, which does not draw the widget again. + const left = `(${this.indent} * ${SPACE} + ${LINE_INSET}px)`; dom.style.marginLeft = `calc${left}`; // The content is as wide as its longest line; the comment wraps at the visible width instead. dom.style.maxWidth = `calc(var(--openidea-doc-width, 100%) - ${left} - ${DOC_RIGHT_GAP}px)`; @@ -827,12 +828,10 @@ export function toggleRenderedViewAtCaret(view: EditorView): boolean { const DOC_RIGHT_GAP = 24; /** - * Publishes on the content the visible width of the text area, `--openidea-doc-width`, - * and the code's character width, `--openidea-doc-char`. A block widget is as wide as - * the content, which without soft wraps is as wide as the longest line, so a rendered - * comment needs the first to wrap where the reader can see, as IDEA's does; it indents - * by the second, which a font size change or zoom changes. Horizontal scrolling leaves - * both unchanged. + * Publishes on the content the visible width of the text area, `--openidea-doc-width`. + * A block widget is as wide as the content, which without soft wraps is as wide as the + * longest line, so a rendered comment needs it to wrap where the reader can see. + * Scrolling leaves it unchanged, so lines are not restyled while scrolling. */ const docMetrics = ViewPlugin.fromClass( class { @@ -845,18 +844,12 @@ const docMetrics = ViewPlugin.fromClass( measure() { this.view.requestMeasure({ key: this, - read: (view) => ({ - width: view.scrollDOM.clientWidth - view.contentDOM.offsetLeft, - char: view.defaultCharacterWidth, - }), - write: ({ width, char }, view) => { + read: (view) => view.scrollDOM.clientWidth - view.contentDOM.offsetLeft, + write: (width, view) => { const style = view.contentDOM.style; - const widthValue = `${Math.max(0, Math.floor(width))}px`; - if (style.getPropertyValue("--openidea-doc-width") !== widthValue) - style.setProperty("--openidea-doc-width", widthValue); - const charValue = `${char}px`; - if (style.getPropertyValue("--openidea-doc-char") !== charValue) - style.setProperty("--openidea-doc-char", charValue); + const value = `${Math.max(0, Math.floor(width))}px`; + if (style.getPropertyValue("--openidea-doc-width") !== value) + style.setProperty("--openidea-doc-width", value); }, }); } @@ -947,5 +940,6 @@ export const renderedDocsExtension: Extension = [ markdownReady, languageWatcher, docMetrics, + spaceWidth, docsTheme, ]; diff --git a/src/editor/core/cm/spaceWidth.ts b/src/editor/core/cm/spaceWidth.ts new file mode 100644 index 0000000000..5143f25da2 --- /dev/null +++ b/src/editor/core/cm/spaceWidth.ts @@ -0,0 +1,51 @@ +/** + * The editor font's space width, published on the scroller as `--openidea-space` + * for anything laid out in columns of indentation (indent guides, code lens rows, + * rendered doc comments). A space is measured, not `ch`: in a proportional font it + * is narrower than "0". The probe's text is fixed, so the value only changes with + * the font, its size or zoom; `defaultCharacterWidth` is sampled from whichever + * line is in view and drifts while scrolling, and an inherited variable that + * changes restyles every line. + */ +import { EditorView, ViewPlugin, type ViewUpdate } from "@codemirror/view"; + +/** One column of indentation, as a CSS length. */ +export const SPACE = "var(--openidea-space, 1ch)"; + +const SAMPLE = 64; + +/** Shared by every extension that lays out by `SPACE`; CodeMirror installs it once. */ +export const spaceWidth = ViewPlugin.fromClass( + class { + private probe: HTMLElement; + private written = ""; + constructor(readonly view: EditorView) { + // Inherits the editor font from the scroller, outside the content CodeMirror observes. + this.probe = document.createElement("span"); + this.probe.setAttribute("aria-hidden", "true"); + this.probe.style.cssText = "position: absolute; top: 0; left: 0; visibility: hidden; white-space: pre"; + this.probe.textContent = " ".repeat(SAMPLE); + view.scrollDOM.appendChild(this.probe); + this.measure(); + } + measure() { + this.view.requestMeasure({ + key: this, + read: (view) => this.probe.getBoundingClientRect().width / (view.scaleX || 1) / SAMPLE, + write: (width, view) => { + const value = `${+width.toFixed(3)}px`; + if (width <= 0 || value === this.written) return; + this.written = value; + view.scrollDOM.style.setProperty("--openidea-space", value); + }, + }); + } + update(u: ViewUpdate) { + if (u.geometryChanged) this.measure(); + } + destroy() { + this.probe.remove(); + this.view.scrollDOM.style.removeProperty("--openidea-space"); + } + }, +); diff --git a/src/editor/core/model/slot.ts b/src/editor/core/model/slot.ts index 2a2c102a0f..145901acbd 100644 --- a/src/editor/core/model/slot.ts +++ b/src/editor/core/model/slot.ts @@ -61,6 +61,20 @@ export interface Reveal { const KEPT_VIEWS = 8; const keptSlots: EditorSlot[] = []; +/** + * Holds the visible tabs' tooltip layers. A layer added to `document.body` itself on every + * tab switch would change which element is the body's last child, and Chromium then + * restyles the whole workbench (`:last-child` rules); inside this host it restyles nothing else. + */ +let tooltipHost: HTMLElement | null = null; +function tooltipHostElement(): HTMLElement { + if (!tooltipHost?.isConnected) { + tooltipHost = document.createElement("div"); + document.body.appendChild(tooltipHost); + } + return tooltipHost; +} + export class EditorSlot { private stored: EditorState; private historyTarget: WorkspaceHistoryTarget; @@ -70,7 +84,7 @@ export class EditorSlot { /** The view kept, detached from the document, while the tab is hidden. */ private kept: EditorView | null = null; /** - * The tab's tooltips (hints, hover, completion…). They live outside the view, in `document.body`, + * The tab's tooltips (hints, hover, completion…). They live outside the view, under `document.body`, * so they leave the page with the view when the tab is hidden instead of floating over the next tab. */ private readonly tooltipLayer = typeof document === "undefined" ? null : document.createElement("div"); @@ -207,7 +221,7 @@ export class EditorSlot { mount(parent: HTMLElement): EditorView { if (this.view) return this.view; - if (this.tooltipLayer && !this.tooltipLayer.isConnected) document.body.appendChild(this.tooltipLayer); + if (this.tooltipLayer && !this.tooltipLayer.isConnected) tooltipHostElement().appendChild(this.tooltipLayer); const kept = this.kept; let view: EditorView; if (kept) { diff --git a/src/editor/core/view/EditorArea.tsx b/src/editor/core/view/EditorArea.tsx index 5910581154..77e4d0fd9e 100644 --- a/src/editor/core/view/EditorArea.tsx +++ b/src/editor/core/view/EditorArea.tsx @@ -568,7 +568,8 @@ function EditorTabActions({ paneId, tab }: { paneId: string; tab: Tab }) { anchor={moreRef} placement="bottom-end" aria-label="Tab actions" - items={ctrl.tabMenu(paneId, tab)} + // Built when shown: every tab render (each open and switch) would otherwise assemble the whole menu. + items={open ? ctrl.tabMenu(paneId, tab) : []} /> ); diff --git a/src/features/agents/Session.module.css b/src/features/agents/Session.module.css index 20fd58e141..81c714b46a 100644 --- a/src/features/agents/Session.module.css +++ b/src/features/agents/Session.module.css @@ -232,8 +232,10 @@ .conversationRow[data-measured] { content-visibility: auto; } -/* Keep turns distinct and the work within a turn close to its author. */ -.stream > * + * { +/* Keep turns distinct and the work within a turn close to its author. Not `* + *`: a + universal adjacent-sibling rule makes Chromium restyle whole sibling subtrees on every + DOM insertion anywhere in the window, which costs every editor scroll frame. */ +.stream > :where(:not(:first-child)) { margin-top: var(--space-4); } .stream > [data-process] + [data-process] { @@ -336,7 +338,7 @@ .agentAuthor > .role { margin-bottom: 0; } -.agentAuthor + * { +:where(.conversationRow[data-author]) > :nth-child(2) { margin-top: calc(var(--space-2) / 2); } .conversationRow > .process, @@ -1067,16 +1069,6 @@ color: var(--fg-muted); } -/* Announced to screen readers, not shown: the fact behind a playful status. */ -.srOnly { - position: absolute; - width: 1px; - height: 1px; - overflow: hidden; - clip-path: inset(50%); - white-space: nowrap; -} - .retrying { color: var(--warning); } diff --git a/src/features/agents/WorkingStatus.module.css b/src/features/agents/WorkingStatus.module.css deleted file mode 100644 index e717743144..0000000000 --- a/src/features/agents/WorkingStatus.module.css +++ /dev/null @@ -1,73 +0,0 @@ -.body { - display: flex; - flex-direction: column; - gap: 10px; - height: 100%; - min-height: 0; -} - -.notice { - margin: 0; - color: var(--fg-muted); - font-size: var(--fs-small); - overflow-wrap: anywhere; -} - -.activity { - display: flex; - align-items: center; - gap: var(--space-2); -} - -.after { - display: flex; - align-items: center; - gap: var(--space-2); -} - -.seconds { - width: 64px; - font-variant-numeric: tabular-nums; -} - -.items { - flex: 1; - min-height: 120px; - display: flex; - flex-direction: column; - gap: var(--space-1); - padding: 8px; - overflow: auto; - border: 1px solid var(--border-strong); - border-radius: var(--radius-control); -} - -.item { - display: flex; - align-items: center; - justify-content: space-between; - gap: var(--space-1-5); - padding: 4px 8px; - background: var(--bg-hover); - border-radius: var(--radius-control); -} - -.word { - overflow-wrap: anywhere; -} - -.empty { - color: var(--fg-muted); - font-size: var(--fs-small); -} - -.add { - display: flex; - align-items: center; - gap: var(--space-1-5); -} - -.input { - flex: 1; - min-width: 0; -} diff --git a/src/features/agents/WorkingStatusPage.tsx b/src/features/agents/WorkingStatusPage.tsx deleted file mode 100644 index e5e57c3a1e..0000000000 --- a/src/features/agents/WorkingStatusPage.tsx +++ /dev/null @@ -1,147 +0,0 @@ -/** - * Settings › Agents › Working Status: whether the status under a conversation turns playful, after - * how long without news, and the playful words of each activity, the built-in ones until the user - * writes their own. - */ -import { useId, useState } from "react"; -import { useTx } from "@/platform/i18n"; -import { PLAYFUL_AFTER_LIMITS } from "@/platform/agentStatus"; -import { Button, Checkbox, IconButton, Input, Select, T, type SelectOption } from "@/ui"; -import { useSettingsForm } from "@/workbench/contributions"; -import { AGENT_SETTINGS_DEFAULTS } from "./agentSettings"; -import { ACTIVITIES, ACTIVITY_STATUS, PLAYFUL_WORDS, type Activity } from "./workingStatus"; -import styles from "./WorkingStatus.module.css"; - -export function WorkingStatusPage() { - const tx = useTx(); - const form = useSettingsForm(); - const playful = - (form.useValue("agents.playfulStatus") as boolean | undefined) ?? AGENT_SETTINGS_DEFAULTS.playfulStatus; - const own = (form.useValue("agents.playfulWords") ?? {}) as Record; - const [activity, setActivity] = useState("working"); - const [draft, setDraft] = useState(""); - const selectId = useId(); - const custom = own[activity]; - const words = custom ?? PLAYFUL_WORDS[activity].map((w) => tx(w)); - - const options: SelectOption[] = ACTIVITIES.map((a) => ({ - value: a, - label: ACTIVITY_STATUS[a], - detail: own[a] ? "Custom" : undefined, - })); - const setWords = (next: string[] | null) => { - const others = Object.fromEntries(Object.entries(own).filter(([a]) => a !== activity)); - form.set("agents.playfulWords", next ? { ...others, [activity]: next } : others); - }; - const add = () => { - const word = draft.trim(); - if (!word) return; - setDraft(""); - if (!words.includes(word)) setWords([...words, word]); - }; - - return ( -
-

- - While the agent works, the line under the conversation says what it is doing. With playful words on, words for - what it does take turns there instead, from the start or once it reports nothing new for a while; screen - readers still hear the plain status. - -

- form.set("agents.playfulStatus", on)} - label="Playful words while the agent works" - /> - -
- - setDraft(e.target.value)} - onKeyDown={(e) => { - if (e.key !== "Enter") return; - // Enter adds the word; it does not press the dialog's OK. - e.preventDefault(); - add(); - }} - placeholder={tx("e.g. Reticulating splines…")} - aria-label={tx("New playful word")} - /> - - -
-
- ); -} - -/** Seconds without news before the status turns playful; invalid text is flagged and reverted on blur. */ -function PlayfulAfter({ disabled }: { disabled: boolean }) { - const tx = useTx(); - const form = useSettingsForm(); - const value = - (form.useValue("agents.playfulAfterSeconds") as number | undefined) ?? AGENT_SETTINGS_DEFAULTS.playfulAfterSeconds; - const [draft, setDraft] = useState(null); - const id = useId(); - const { min, max } = PLAYFUL_AFTER_LIMITS; - const parse = (text: string) => { - const n = /^\s*\d+\s*$/.test(text) ? Number(text) : NaN; - return n >= min && n <= max ? n : null; - }; - const invalid = draft !== null && parse(draft) === null; - return ( -
- - { - setDraft(e.target.value); - const n = parse(e.target.value); - if (n !== null) form.set("agents.playfulAfterSeconds", n); - }} - onBlur={() => setDraft(null)} - /> - seconds -
- ); -} diff --git a/src/features/agents/agentSettings.ts b/src/features/agents/agentSettings.ts index fa421ccf95..c71fd0d168 100644 --- a/src/features/agents/agentSettings.ts +++ b/src/features/agents/agentSettings.ts @@ -13,9 +13,6 @@ export const AGENT_SETTINGS_DEFAULTS: ResolvedAgentSettings = { foldTurns: true, smoothText: true, fitWindowWidth: false, - playfulStatus: false, - playfulAfterSeconds: 0, - playfulWords: {}, thinking: "auto", toolCalls: "grouped", expandToolOutput: false, diff --git a/src/features/agents/model.ts b/src/features/agents/model.ts index 21bfe36868..48b85b1fa7 100644 --- a/src/features/agents/model.ts +++ b/src/features/agents/model.ts @@ -15,8 +15,6 @@ export const AGENTS_GROUP = "Agents"; export const MCP_PAGE = "agents.mcpServers"; /** Settings › Agents › Command Permissions. */ export const POLICY_PAGE = "agents.policy"; -/** Settings › Agents › Working Status: the playful words under a working conversation. */ -export const WORKING_STATUS_PAGE = "agents.workingStatus"; export const sessionKey = (task: string) => `agent:${task}`; diff --git a/src/features/agents/sampleConversation.ts b/src/features/agents/sampleConversation.ts index b3a0bfa965..7ecdd15eb0 100644 --- a/src/features/agents/sampleConversation.ts +++ b/src/features/agents/sampleConversation.ts @@ -29,7 +29,7 @@ function task(id: string, title: string, cwd: string): AgentTask { } /** A turn as agents work: a request, reasoning, a run of tool calls, then a reply with code. */ -function turn(cwd: string, i: number): AgentEntry[] { +function turn(cwd: string, i: number, title: string): AgentEntry[] { const file = (k: number) => `${cwd}/src/orders/Order${(i + k) % 40}.kt`; const tools: AgentEntry[] = Array.from({ length: 10 }, (_, k) => { // Tool titles as agents report them (commands and paths, not UI text). @@ -49,7 +49,8 @@ function turn(cwd: string, i: number): AgentEntry[] { }; }); // What a user and an agent wrote (conversation content, not UI text). - const request = `Turn ${i}: make the order service retry failed payments and cover it with tests`; + // Ends with the task's title, so each conversation shown can be told apart. + const request = `Turn ${i}: make the order service retry failed payments and cover it with tests (${title})`; const reasoning = `The payment client throws on timeouts; retrying belongs in the service (turn ${i}).`; return [ { @@ -94,14 +95,14 @@ function turn(cwd: string, i: number): AgentEntry[] { /** Opens `count` tasks of `turns` turns each (14 entries a turn), the last one shown. */ export function openSampleConversations(count: number, turns: number) { const cwd = useProject.getState().project?.root ?? "/"; - const entries = Array.from({ length: turns }, (_, i) => turn(cwd, i)).flat(); const s = useAgents.getState(); const tasks = new Map(s.tasks); const all = new Map(s.entries); const ids = Array.from({ length: count }, (_, n) => `sample-${n + 1}`); ids.forEach((id, n) => { - tasks.set(id, task(id, `Sample task ${n + 1}`, cwd)); - all.set(id, entries); + const title = `Sample task ${n + 1}`; + tasks.set(id, task(id, title, cwd)); + all.set(id, Array.from({ length: turns }, (_, i) => turn(cwd, i, title)).flat()); }); useAgents.setState({ tasks, entries: all }); for (const id of ids) openTask(id); diff --git a/src/features/agents/session/Stream.tsx b/src/features/agents/session/Stream.tsx index e3bfb19421..8f7dcd99ff 100644 --- a/src/features/agents/session/Stream.tsx +++ b/src/features/agents/session/Stream.tsx @@ -559,6 +559,7 @@ export function Stream({ (row.kind === "entry" && (row.entry.type === "user" || row.entry.type === "agent")) || undefined } data-process={row.kind !== "entry" || row.entry.type !== "user" || undefined} + data-author={authorHeaders.has(row.index) || undefined} > {authorHeaders.has(row.index) && (
diff --git a/src/features/agents/session/WorkingRow.tsx b/src/features/agents/session/WorkingRow.tsx index 1127028737..42804920c3 100644 --- a/src/features/agents/session/WorkingRow.tsx +++ b/src/features/agents/session/WorkingRow.tsx @@ -1,23 +1,12 @@ import type { AgentEntry, AgentRetry, AgentTask } from "@/bindings"; import { useTx } from "@/platform/i18n"; import { Spinner, T } from "@/ui"; -import { useState } from "react"; import styles from "../Session.module.css"; -import { useAgentSettings } from "../agentSettings"; import { retryParts } from "../composerModel"; import { formatDuration } from "../conversation"; import { subagentWorking, type SubagentEntry } from "../model"; import { asksInCard } from "../permission"; -import { - ACTIVITY_STATUS, - activityOf, - PLAYFUL_MIN_MS, - PLAYFUL_WORD_MS, - PLAYFUL_WORDS, - playfulIndex, - progressKey, - type Activity, -} from "../workingStatus"; +import { ACTIVITY_STATUS, activityOf } from "../workingStatus"; import { useNow, type UserEntry } from "./shared"; /** The agent lost its API connection (or was refused) and retries on its own. */ @@ -57,11 +46,7 @@ export function WorkingRow({ return (
- {subagent.status === "needsInput" ? ( - Waiting for your answer… - ) : ( - - )} + {subagent.status === "needsInput" ? Waiting for your answer… : } {subagent.startedMs != null && }
); @@ -78,56 +63,15 @@ export function WorkingRow({ ) : task.status === "starting" ? ( Starting the agent… ) : ( - + )} {lastUser?.sentMs != null && !lastUser.doneMs && }
); } -/** - * What the agent is doing, said by the activity's playful words in turns (the user's own, else the - * built-in ones) from the start, or once it has reported nothing new for the user's quiet time; - * screen readers hear only the fact. A word stays its full time while it still fits what the agent - * does, and a little while when it no longer does, so the row never flickers. - */ -function WorkingLabel({ turn, seed }: { turn: AgentEntry[]; seed: number }) { +/** What the agent is doing, from the turn's latest output. */ +function WorkingLabel({ turn }: { turn: AgentEntry[] }) { const tx = useTx(); - const { playfulStatus, playfulAfterSeconds, playfulWords } = useAgentSettings(); - const now = useNow(1000); - const key = progressKey(turn); - const [progress, setProgress] = useState({ key, at: now }); - if (progress.key !== key) setProgress({ key, at: now }); - // The word on screen, and how many the turn has shown, so the next one continues the order. - const [playful, setPlayful] = useState<{ shown: number; word: PlayfulWord | null }>({ shown: 0, word: null }); - const activity = activityOf(turn); - const kind = activity ?? "working"; - const fact = tx(ACTIVITY_STATUS[kind]); - const own = playfulWords[kind]; - const words = own ?? PLAYFUL_WORDS[kind]; - const due = words.length > 0 && (!activity || now - progress.at >= playfulAfterSeconds * 1000); - const current = playful.word; - const fits = due && current?.kind === kind; - const stays = current && playfulStatus && now - current.since < (fits ? PLAYFUL_WORD_MS : PLAYFUL_MIN_MS); - let next = playful; - if (!stays && playfulStatus && due) { - const text = words[playfulIndex(words.length, seed, playful.shown)]!; - next = { shown: playful.shown + 1, word: { text, kind, own: !!own, since: now } }; - } else if (!stays && current) next = { shown: playful.shown, word: null }; - if (next !== playful) setPlayful(next); - if (!next.word) return fact; - return ( - <> - {next.word.own ? next.word.text : tx(next.word.text)} - {fact} - - ); -} - -/** A playful word for `kind` on screen since `since`: the user's own as written, else a built-in one to translate. */ -interface PlayfulWord { - text: string; - kind: Activity; - own: boolean; - since: number; + return tx(ACTIVITY_STATUS[activityOf(turn) ?? "working"]); } diff --git a/src/features/agents/sessionState.test.tsx b/src/features/agents/sessionState.test.tsx index 1c1383a226..18809bb707 100644 --- a/src/features/agents/sessionState.test.tsx +++ b/src/features/agents/sessionState.test.tsx @@ -24,7 +24,6 @@ import { useChangesOptions } from "./changesOptions"; import { taskActions } from "./taskActions"; import { replyActions } from "./replyActions"; import { focusedSession } from "./sessionFocus"; -import { PLAYFUL_MIN_MS, PLAYFUL_WORD_MS, PLAYFUL_WORDS } from "./workingStatus"; import styles from "./Session.module.css"; import chipStyles from "./ReferenceChip.module.css"; import { caretOf, textOf, typeIn } from "./composerTesting"; @@ -517,108 +516,18 @@ describe("working status", () => { }), }); }; - const playful = (status: HTMLElement) => status.querySelector("[aria-hidden]")?.textContent ?? null; - const playfulOn = (agents: object = {}) => - useProject.setState({ settings: { agents: { playfulStatus: true, ...agents } } as never }); - it("says plainly what the agent does by default", async () => { - vi.useFakeTimers(); - running([tool("one", { status: "running" })]); - render(); - await act(async () => {}); - await act(() => vi.advanceTimersByTimeAsync(PLAYFUL_WORD_MS * 2)); - const status = stream().querySelector(`.${styles.working}`)!; - expect(playful(status)).toBeNull(); - expect(status).toHaveTextContent("Reading…"); - }); - - it("is playful from the start, holds each word while the work goes on, and turns to the new work's words", async () => { - vi.useFakeTimers(); - playfulOn(); - running([tool("one", { status: "running" })]); - render(); - await act(async () => {}); - const status = stream().querySelector(`.${styles.working}`)!; - const word = playful(status); - expect(PLAYFUL_WORDS.reading).toContain(word); - // Screen readers still hear the fact. - expect(status.querySelector(`.${styles.srOnly}`)).toHaveTextContent("Reading…"); - - // More of the same work keeps the word its full time. - running([tool("one", { status: "running" }), tool("two", { status: "running" })]); - await act(() => vi.advanceTimersByTimeAsync(PLAYFUL_WORD_MS - 1000)); - expect(playful(status)).toBe(word); - await act(() => vi.advanceTimersByTimeAsync(1000)); - const second = playful(status); - expect(PLAYFUL_WORDS.reading.filter((w) => w !== word)).toContain(second); - - // New work leaves the word a moment, then says the new work playfully too. - running([tool("one", { status: "running" }), { type: "agent", text: "Found it" }]); - await act(() => vi.advanceTimersByTimeAsync(1000)); - expect(playful(status)).toBe(second); - await act(() => vi.advanceTimersByTimeAsync(PLAYFUL_MIN_MS - 1000)); - expect(PLAYFUL_WORDS.writing).toContain(playful(status)); - expect(status.querySelector(`.${styles.srOnly}`)).toHaveTextContent("Writing…"); - }); - - it("with a quiet time, is factual until the agent reports nothing new for it, and again on progress", async () => { - vi.useFakeTimers(); - playfulOn({ playfulAfterSeconds: 10 }); + it("says what the agent does", async () => { running([tool("one", { status: "running" })]); render(); await act(async () => {}); const status = stream().querySelector(`.${styles.working}`)!; expect(status).toHaveTextContent("Reading…"); - expect(playful(status)).toBeNull(); - await act(() => vi.advanceTimersByTimeAsync(9000)); - expect(playful(status)).toBeNull(); - await act(() => vi.advanceTimersByTimeAsync(1000)); - const word = playful(status); - expect(PLAYFUL_WORDS.reading).toContain(word); - - // Progress right after a word appeared leaves it a moment before the fact returns. running([tool("one", { status: "running" }), { type: "agent", text: "Found it" }]); - await act(() => vi.advanceTimersByTimeAsync(1000)); - expect(playful(status)).toBe(word); - await act(() => vi.advanceTimersByTimeAsync(PLAYFUL_MIN_MS - 1000)); - expect(playful(status)).toBeNull(); + await act(async () => {}); expect(status).toHaveTextContent("Writing…"); }); - - it("keeps each word its full time however soon the status turns playful", async () => { - vi.useFakeTimers(); - playfulOn({ playfulAfterSeconds: 1 }); - running([tool("one", { status: "running" })]); - render(); - await act(async () => {}); - const status = stream().querySelector(`.${styles.working}`)!; - await act(() => vi.advanceTimersByTimeAsync(1000)); - const word = playful(status); - expect(PLAYFUL_WORDS.reading).toContain(word); - await act(() => vi.advanceTimersByTimeAsync(PLAYFUL_WORD_MS - 1000)); - expect(playful(status)).toBe(word); - await act(() => vi.advanceTimersByTimeAsync(1000)); - expect(PLAYFUL_WORDS.reading.filter((w) => w !== word)).toContain(playful(status)); - }); - - it("shows the user's own words of the activity, and none where they left the list empty", async () => { - vi.useFakeTimers(); - playfulOn({ playfulWords: { reading: ["Squinting really hard…"], working: [] } }); - running([]); - render(); - await act(async () => {}); - const status = stream().querySelector(`.${styles.working}`)!; - // Nothing reported yet is `working`, whose list the user emptied. - expect(playful(status)).toBeNull(); - expect(status).toHaveTextContent("Working…"); - - running([tool("one", { status: "running" })]); - await act(() => vi.advanceTimersByTimeAsync(1000)); - expect(playful(status)).toBe("Squinting really hard…"); - await act(() => vi.advanceTimersByTimeAsync(PLAYFUL_WORD_MS)); - expect(playful(status)).toBe("Squinting really hard…"); - }); }); describe("opened runs", () => { diff --git a/src/features/agents/settingsPages.ts b/src/features/agents/settingsPages.ts index 4fa325c796..d1db647202 100644 --- a/src/features/agents/settingsPages.ts +++ b/src/features/agents/settingsPages.ts @@ -1,6 +1,6 @@ import { lazyComponent } from "@/ui"; import { registerSettingsPages } from "@/workbench/contributions"; -import { AGENTS_GROUP, MCP_PAGE, POLICY_PAGE, REGISTRY_PAGE, WORKING_STATUS_PAGE } from "./model"; +import { AGENTS_GROUP, MCP_PAGE, POLICY_PAGE, REGISTRY_PAGE } from "./model"; /** Settings › Agents › Coding Agents and Settings › Agents › External MCP Servers (also used by the Settings window). */ export function activateSettingsPages(): () => void { @@ -14,15 +14,6 @@ export function activateSettingsPages(): () => void { keywords: ["agent", "acp", "registry", "install", "update", "coding agent"], component: lazyComponent(() => import("./AgentRegistryPage").then((m) => m.AgentRegistryPage)), }, - { - id: WORKING_STATUS_PAGE, - title: "Working Status", - group: AGENTS_GROUP, - // After Chat. - order: 465, - keywords: ["agent", "status", "playful", "words", "working", "spinner", "fun", "delay", "seconds"], - component: lazyComponent(() => import("./WorkingStatusPage").then((m) => m.WorkingStatusPage)), - }, { id: MCP_PAGE, title: "External MCP Servers", diff --git a/src/features/agents/workingStatus.ts b/src/features/agents/workingStatus.ts index d7963b01ca..8e52b0258d 100644 --- a/src/features/agents/workingStatus.ts +++ b/src/features/agents/workingStatus.ts @@ -1,32 +1,22 @@ -/** - * The label of the row under a conversation while the agent works: what the turn's latest - * output says it is doing, and playful words while it reports nothing new (or nothing yet). - */ +/** The label of the row under a conversation while the agent works: what the turn's latest output says it is doing. */ import type { AgentEntry } from "@/bindings"; import { subagentWorking } from "./model"; -/** How long one playful word stays while the agent still reports nothing new. */ -export const PLAYFUL_WORD_MS = 8_000; -/** How long a playful word stays at least, even when the agent reports something new meanwhile. */ -export const PLAYFUL_MIN_MS = 3_000; - /** What the agent can be doing, as the status tells it; `working` covers the rest. */ -export const ACTIVITIES = [ - "working", - "thinking", - "writing", - "reading", - "editing", - "deleting", - "moving", - "searching", - "running", - "fetching", - "subagent", -] as const; -export type Activity = (typeof ACTIVITIES)[number]; +type Activity = + | "working" + | "thinking" + | "writing" + | "reading" + | "editing" + | "deleting" + | "moving" + | "searching" + | "running" + | "fetching" + | "subagent"; -/** The factual status of each activity, also what screen readers hear while it is playful. */ +/** The status of each activity. */ export const ACTIVITY_STATUS: Record = { working: "Working…", thinking: "Thinking…", @@ -41,59 +31,6 @@ export const ACTIVITY_STATUS: Record = { subagent: "Running a subagent…", }; -/** The built-in playful words of each activity, until the user writes their own. */ -export const PLAYFUL_WORDS: Record = { - working: [ - "Untangling imports…", - "Explaining it to the rubber duck…", - "Herding semicolons…", - "Rebasing onto reality…", - "Measuring twice…", - "Sharpening the pencils…", - "Invalidating a cache…", - ], - thinking: [ - "Refactoring a hunch…", - "Garbage-collecting thoughts…", - "Compiling a plan…", - "Caching an insight…", - "Bisecting the problem…", - "Naming things…", - ], - writing: [ - "Counting brackets…", - "Settling tabs versus spaces…", - "Choosing words carefully…", - "Polishing the prose…", - "Drafting, redrafting…", - ], - reading: [ - "Reading the fine manual…", - "Following the breadcrumbs…", - "Walking the call stack…", - "Reading between the lines…", - "Skimming the source…", - ], - editing: [ - "Squinting at the diff…", - "Negotiating with the borrow checker…", - "Asking the linter nicely…", - "Nudging a semicolon…", - "Moving code around gently…", - ], - deleting: ["Tidying up…", "Taking out the trash…", "Pruning dead code…", "Saying goodbye…"], - moving: ["Rearranging the furniture…", "Packing boxes…", "Finding a better home…"], - searching: ["Grepping the void…", "Chasing a null pointer…", "Looking under the couch…", "Searching high and low…"], - running: [ - "Warming up the compiler…", - "Pressing Enter with confidence…", - "Watching the logs scroll…", - "Waiting on the shell…", - ], - fetching: ["Waiting on the network…", "Downloading the internet…", "Following links…"], - subagent: ["Delegating…", "Consulting a colleague…", "Calling in reinforcements…", "Holding a quick stand-up…"], -}; - const TOOL_ACTIVITY: Record = { read: "reading", edit: "editing", @@ -124,35 +61,3 @@ export function activityOf(turn: readonly AgentEntry[]): Activity | null { return "working"; } } - -/** Changes whenever the agent reports something new in the turn: an entry, more text, a tool's progress. */ -export function progressKey(turn: readonly AgentEntry[]): string { - const last = turn.at(-1); - const detail = - last?.type === "agent" || last?.type === "thought" - ? last.text.length - : last?.type === "tool" - ? `${last.status}:${last.output?.length ?? 0}` - : last?.type === "subagent" - ? last.status - : ""; - return `${turn.length}:${last?.type ?? ""}:${detail}`; -} - -/** - * Which of `count` playful words is the `n`th to show in the turn that started at `seed`. Each turn - * goes through every word in an order of its own. - */ -export function playfulIndex(count: number, seed: number, n: number): number { - const order = Array.from({ length: count }, (_, i) => i); - let state = seed >>> 0; - for (let i = order.length - 1; i > 0; i--) { - // mulberry32 - state = (state + 0x6d2b79f5) >>> 0; - let r = Math.imul(state ^ (state >>> 15), state | 1); - r ^= r + Math.imul(r ^ (r >>> 7), r | 61); - const j = ((r ^ (r >>> 14)) >>> 0) % (i + 1); - [order[i], order[j]] = [order[j]!, order[i]!]; - } - return order[n % count]!; -} diff --git a/src/features/agents/workingStatusPage.test.tsx b/src/features/agents/workingStatusPage.test.tsx deleted file mode 100644 index 0144b51446..0000000000 --- a/src/features/agents/workingStatusPage.test.tsx +++ /dev/null @@ -1,83 +0,0 @@ -import { afterEach, beforeEach, describe, expect, it } from "vitest"; -import { fireEvent, render, screen, within } from "@testing-library/react"; -import { SettingsFormContext } from "@/workbench/contributions"; -import { useSettingsFormFor } from "@/features/settings/components/context"; -import { closeSettings, openSettings, stagedValue, useSettingsDialog } from "@/features/settings/model/staging"; -import { WORKING_STATUS_PAGE } from "./model"; -import { WorkingStatusPage as Page } from "./WorkingStatusPage"; -import { PLAYFUL_WORDS } from "./workingStatus"; - -function WorkingStatusPage() { - const form = useSettingsFormFor(WORKING_STATUS_PAGE, "global"); - return ( - - - - ); -} - -const staged = () => stagedValue(useSettingsDialog.getState(), "global", "agents.playfulWords"); -const words = () => - within(screen.getByRole("list", { name: "Playful words" })) - .queryAllByRole("listitem") - .map((item) => item.textContent); -/** The page with playful words turned on, so its word controls are enabled. */ -function renderOn() { - render(); - fireEvent.click(screen.getByRole("checkbox", { name: "Playful words while the agent works" })); -} - -describe("Working Status settings", () => { - beforeEach(() => openSettings(WORKING_STATUS_PAGE)); - afterEach(() => closeSettings()); - - it("is off by default, and turning it on enables the words", () => { - render(); - const toggle = screen.getByRole("checkbox", { name: "Playful words while the agent works" }); - expect(toggle).not.toBeChecked(); - expect(screen.getByRole("textbox", { name: "New playful word" })).toBeDisabled(); - fireEvent.click(toggle); - expect(stagedValue(useSettingsDialog.getState(), "global", "agents.playfulStatus")).toBe(true); - expect(screen.getByRole("textbox", { name: "New playful word" })).toBeEnabled(); - }); - - it("turns the built-in words into the user's own on the first edit, and restores them", () => { - renderOn(); - const builtIn = [...PLAYFUL_WORDS.working]; - expect(words()).toEqual(builtIn); - - fireEvent.click(screen.getByRole("button", { name: `Remove ${builtIn[0]}` })); - const input = screen.getByRole("textbox", { name: "New playful word" }); - fireEvent.change(input, { target: { value: " Reticulating splines… " } }); - // Enter adds the word and is not left to press the Settings dialog's OK. - expect(fireEvent.keyDown(input, { key: "Enter" })).toBe(false); - const own = [...builtIn.slice(1), "Reticulating splines…"]; - expect(words()).toEqual(own); - expect(staged()).toEqual({ working: own }); - - fireEvent.click(screen.getByRole("button", { name: "Restore Built-in Words" })); - expect(staged()).toEqual({}); - expect(words()).toEqual(builtIn); - }); - - it("keeps an emptied list, which leaves the status factual", () => { - renderOn(); - for (const word of PLAYFUL_WORDS.working) fireEvent.click(screen.getByRole("button", { name: `Remove ${word}` })); - expect(staged()).toEqual({ working: [] }); - expect(screen.getByText("No playful words: the status stays factual")).toBeInTheDocument(); - }); - - it("saves the quiet time while the text is a valid number, and drops invalid text on blur", () => { - renderOn(); - const after = () => stagedValue(useSettingsDialog.getState(), "global", "agents.playfulAfterSeconds"); - const seconds = screen.getByRole("textbox", { name: "Start after the agent reports nothing new for" }); - expect(seconds).toHaveValue("0"); - fireEvent.change(seconds, { target: { value: "25" } }); - expect(after()).toBe(25); - fireEvent.change(seconds, { target: { value: "601" } }); - expect(seconds).toHaveAttribute("aria-invalid", "true"); - expect(after()).toBe(25); - fireEvent.blur(seconds); - expect(seconds).toHaveValue("25"); - }); -}); diff --git a/src/features/github/ui/ui.module.css b/src/features/github/ui/ui.module.css index dedaf003d2..96a1205209 100644 --- a/src/features/github/ui/ui.module.css +++ b/src/features/github/ui/ui.module.css @@ -37,7 +37,7 @@ flex: none; align-items: center; } -.stack > * + * { +.stack > :where(:not(:first-child)) { margin-left: calc(var(--overlap) * -1); } .stack > .ringed + .ringed { diff --git a/src/features/plugins/PluginsPage.module.css b/src/features/plugins/PluginsPage.module.css index 1ba5674515..d0fc0cbd28 100644 --- a/src/features/plugins/PluginsPage.module.css +++ b/src/features/plugins/PluginsPage.module.css @@ -3,23 +3,21 @@ flex-direction: column; min-width: 0; height: 100%; - min-height: 420px; + min-height: 0; } .topBar { display: flex; + flex-wrap: wrap; align-items: center; + justify-content: center; gap: var(--space-1-5); + min-width: 0; } -.side { - display: flex; +.page > .topBar { flex: none; - flex-direction: column; - width: clamp(320px, 42%, 480px); - min-height: 0; - border-right: 1px solid var(--border); + padding: 0 var(--space-2) var(--space-1); } .sourceTabs { - flex: none; border-bottom: 0; } .tabCount { @@ -37,13 +35,14 @@ .searchRow { display: flex; flex: none; + flex-wrap: wrap; align-items: center; gap: var(--space-1-5); padding: 8px; border-bottom: 1px solid var(--border); } .searchField { - flex: 1; + flex: 1 1 132px; min-width: 0; } .spacer { @@ -58,8 +57,6 @@ overflow-wrap: anywhere; } .body { - display: flex; - min-width: 640px; flex: 1; min-height: 0; border-top: 1px solid var(--border); @@ -237,11 +234,14 @@ .details { flex: 1; min-width: 0; - padding: 16px 20px 20px; + min-height: 0; + padding: var(--space-4); overflow: auto; } .detailsEmpty { flex: 1; + min-height: 0; + overflow: auto; } /* Tags, name, vendor, then the actions with the version. */ .header { @@ -258,6 +258,7 @@ color: var(--fg); font: inherit; white-space: pre-wrap; + overflow-wrap: anywhere; } .titleLine { display: flex; @@ -273,15 +274,19 @@ .title { margin: 0; color: var(--fg-strong); - font-size: var(--fs-input-large); + font-size: 1.375em; font-weight: 600; + line-height: 1.3; + overflow-wrap: anywhere; } .version { color: var(--fg-muted); + font-size: var(--fs-small); font-variant-numeric: tabular-nums; } .authors { color: var(--fg-secondary); + overflow-wrap: anywhere; } .headerActions { display: flex; @@ -298,6 +303,7 @@ margin: 10px 0 0; max-width: 640px; color: var(--fg); + overflow-wrap: anywhere; } .details .error { margin-top: 10px; @@ -434,6 +440,7 @@ .consentNotice { display: flex; + flex-wrap: wrap; align-items: center; gap: var(--space-3); justify-content: space-between; @@ -444,8 +451,7 @@ } .categorySelect { - flex: none; - width: 150px; + flex: 0 1 150px; } .ownIcon { background: transparent; diff --git a/src/features/plugins/PluginsPage.tsx b/src/features/plugins/PluginsPage.tsx index 9aa36f5760..cd335c3fa9 100644 --- a/src/features/plugins/PluginsPage.tsx +++ b/src/features/plugins/PluginsPage.tsx @@ -6,7 +6,7 @@ * There is no network repository: Available lists the plugin packages * available locally (`plugin_catalog`) and installs them from disk. */ -import { useEffect, useMemo, useState, type MouseEvent, type ReactNode } from "react"; +import { useEffect, useLayoutEffect, useMemo, useRef, useState, type MouseEvent, type ReactNode } from "react"; import clsx from "clsx"; import type { CapabilityInfo, @@ -27,6 +27,9 @@ import { SearchField, Select, Spinner, + SplitGroup, + SplitHandle, + SplitPanel, Tabs, showContextMenu, type MenuItem, @@ -1309,6 +1312,19 @@ export function PluginsPage({ initialTab = "marketplace" }: { initialTab?: Tab } const [query, setQuery] = useState(""); const [selectedId, setSelectedId] = useState(null); const [selectedCatalogId, setSelectedCatalogId] = useState(null); + const pageRef = useRef(null); + const [stacked, setStacked] = useState(false); + + useLayoutEffect(() => { + const page = pageRef.current; + if (!page) return; + const measure = () => setStacked(page.clientWidth < 600); + measure(); + if (typeof ResizeObserver === "undefined") return; + const observer = new ResizeObserver(measure); + observer.observe(page); + return () => observer.disconnect(); + }, []); useEffect(() => { void refreshPlugins(); @@ -1403,7 +1419,7 @@ export function PluginsPage({ initialTab = "marketplace" }: { initialTab?: Tab } const headerSlot = useSettingsHeaderSlot(); const header = ( - <> +
{(loading || installing) && } - +
); return ( -
- {headerSlot ? createPortal(header, headerSlot) :
{header}
} +
+ {headerSlot && !stacked ? createPortal(header, headerSlot) : header} {error && (
@@ -1434,8 +1450,13 @@ export function PluginsPage({ initialTab = "marketplace" }: { initialTab?: Tab }
)} -
-
+ +
{catalogError}} )} -
- - {tab === "installed" ? ( - selected ? ( - +
+ + + {tab === "installed" ? ( + selected ? ( + + ) : ( + + Plugins are folders with a plugin.toml + . Use the gear menu to install one from disk, or put dev plugins in{" "} + .openidea/plugins/ inside your project. + + ) + ) : selectedMarket ? ( + { + setTab("installed"); + setSelectedId(id); + }} + /> + ) : selectedEntry ? ( + + ) : marketUrl ? ( + ) : ( - - Plugins are folders with a plugin.toml - . Use the gear menu to install one from disk, or put dev plugins in .openidea/plugins/{" "} - inside your project. + + Install a plugin folder with plugin.toml{" "} + via the gear menu › Install Plugin from Disk…. - ) - ) : selectedMarket ? ( - { - setTab("installed"); - setSelectedId(id); - }} - /> - ) : selectedEntry ? ( - - ) : marketUrl ? ( - - ) : ( - - Install a plugin folder with plugin.toml{" "} - via the gear menu › Install Plugin from Disk…. - - )} -
+ )} + +
); } diff --git a/src/features/plugins/__tests__/plugins.test.tsx b/src/features/plugins/__tests__/plugins.test.tsx index 977667ed64..dfadb2ec1d 100644 --- a/src/features/plugins/__tests__/plugins.test.tsx +++ b/src/features/plugins/__tests__/plugins.test.tsx @@ -953,7 +953,8 @@ describe("PluginsPage", () => { await user.click(screen.getByRole("button", { name: "Apply theme Harbor Night" })); await waitFor(() => expect(screen.getByRole("button", { name: "Use Default Theme" })).toBeInTheDocument()); - await user.type(screen.getByLabelText("Filter plugins"), "toy"); + screen.getByLabelText("Filter plugins").focus(); + await user.keyboard("toy"); await waitFor(() => expect(within(list).getAllByRole("listitem")).toHaveLength(1)); expect(screen.getByRole("heading", { level: 2 })).toHaveTextContent("Toy Language"); expect(screen.getByText("Toy (.toy)")).toBeInTheDocument(); diff --git a/src/features/plugins/views/ContentMarkdown.module.css b/src/features/plugins/views/ContentMarkdown.module.css index 5e927eb68e..d85a11883e 100644 --- a/src/features/plugins/views/ContentMarkdown.module.css +++ b/src/features/plugins/views/ContentMarkdown.module.css @@ -115,7 +115,7 @@ flex: 1 1 50%; min-width: 0; } -.body > * + * { +.body > :where(:not(:first-child)) { border-left: 1px solid var(--border); } .hidden { diff --git a/src/features/project-tree/fs.ts b/src/features/project-tree/fs.ts index cd539dd1b8..dec2672248 100644 --- a/src/features/project-tree/fs.ts +++ b/src/features/project-tree/fs.ts @@ -107,6 +107,9 @@ type ResolvedNode = Exclude; const err = (kind: "notFound" | "alreadyExists" | "invalidInput", message: string) => new IpcError({ kind, message }); +/** Created once: building a collator costs more than sorting a small folder with it. */ +const naturalOrder = new Intl.Collator(undefined, { numeric: true, sensitivity: "base" }); + /** The tree's own notion (see `isDirEntry`): a folder, or a link to one. */ const isFolder = (e: FileEntry) => e.kind === "dir" || (e.kind === "symlink" && e.size === 0); @@ -161,13 +164,14 @@ export class MemoryFs implements ProjectFs { const { path, node } = this.resolve(at); if (!node) throw err("notFound", `${path} not found`); if (node.kind !== "dir") throw err("invalidInput", `${at} is not a directory`); - const collator = new Intl.Collator(undefined, { numeric: true, sensitivity: "base" }); + // A child is excluded when its folder is, or when it is itself an excluded path. + const inExcluded = [...this.ignored].some((i) => path === i || isInside(path, i)); return ( this.childrenOf(path) .map((p) => { const c = this.nodes.get(p)!; const name = nameOf(p); - const excluded = [...this.ignored].some((i) => p === i || isInside(p, i)); + const excluded = inExcluded || this.ignored.has(p); if (c.kind === "symlink") { const t = this.resolve(p); return { @@ -195,7 +199,7 @@ export class MemoryFs implements ProjectFs { } satisfies FileEntry; }) // Folders first, counting a link to a folder as a folder (the backend's ordering). - .sort((a, b) => Number(isFolder(b)) - Number(isFolder(a)) || collator.compare(a.name, b.name)) + .sort((a, b) => Number(isFolder(b)) - Number(isFolder(a)) || naturalOrder.compare(a.name, b.name)) ); } diff --git a/src/features/settings/__tests__/agents.test.ts b/src/features/settings/__tests__/agents.test.ts index 1ca1cf58ae..a7de5649c5 100644 --- a/src/features/settings/__tests__/agents.test.ts +++ b/src/features/settings/__tests__/agents.test.ts @@ -11,9 +11,6 @@ describe("agent chat settings", () => { foldTurns: true, smoothText: true, fitWindowWidth: false, - playfulStatus: false, - playfulAfterSeconds: 0, - playfulWords: {}, thinking: "auto", toolCalls: "grouped", expandToolOutput: false, @@ -55,20 +52,4 @@ describe("agent chat settings", () => { }); expect(validateSettings({ agents: { newTaskApprovals: "never" } }).agents.newTaskApprovals).toBe("bypass"); }); - - it("keeps the user's playful words by activity, an emptied list included", () => { - const stored = validateSettings({ - agents: { playfulWords: { reading: ["Squinting…", " ", 3], working: [], editing: "nope" } }, - }).agents; - expect(stored.playfulWords).toEqual({ reading: ["Squinting…"], working: [] }); - }); - - it("keeps the playful quiet time in whole seconds within its range", () => { - const after = (v: unknown) => validateSettings({ agents: { playfulAfterSeconds: v } }).agents.playfulAfterSeconds; - expect(after(0)).toBe(0); - expect(after(2.6)).toBe(3); - expect(after(-5)).toBe(0); - expect(after(100_000)).toBe(600); - expect(after("soon")).toBe(0); - }); }); diff --git a/src/features/settings/keymap/Keymap.module.css b/src/features/settings/keymap/Keymap.module.css index f156156138..35621de48e 100644 --- a/src/features/settings/keymap/Keymap.module.css +++ b/src/features/settings/keymap/Keymap.module.css @@ -1,15 +1,26 @@ .page { display: flex; flex-direction: column; + gap: var(--space-2); height: 100%; - min-height: 420px; + min-height: 0; + min-width: 0; } -.presetRow { +.presetRow, +.toolbar { + display: flex; + flex: none; + flex-wrap: wrap; + align-items: center; + justify-content: space-between; + gap: var(--space-1) var(--space-2); +} +.presetGroup { display: flex; align-items: center; - gap: 10px; - min-height: 30px; - margin-bottom: 6px; + flex: 0 1 328px; + min-width: 0; + gap: var(--space-2); } .presetLabel { flex: none; @@ -17,7 +28,7 @@ color: var(--fg); } .presetSelect { - min-width: 220px; + flex: 1; } .spacer { flex: 1; @@ -25,37 +36,44 @@ .modifiedNote { color: var(--fg-subtle); font-size: var(--fs-small); + overflow-wrap: anywhere; } -.toolbar { +.treeActions, +.filterGroup { display: flex; align-items: center; - gap: var(--space-0-5); - margin-bottom: 6px; + gap: var(--space-1); } -.search { - flex: 1; - max-width: 360px; - margin-right: 4px; +.treeActions { + flex: none; } +.filterGroup { + flex: 1 1 300px; + min-width: 0; + max-width: 392px; +} +.search, .shortcutFilter { flex: 1; - max-width: 360px; + min-width: 0; +} +.shortcutFilter { display: flex; align-items: center; - gap: var(--space-0-5); - height: var(--h-control); - margin-right: 4px; - padding: 0 2px 0 8px; - border-radius: var(--radius-small); - box-shadow: inset 0 0 0 1px var(--border-strong); + gap: var(--space-1); + height: var(--h-field); + padding: 0 var(--space-1) 0 var(--space-2); + background: var(--bg-field); + border-radius: var(--radius-control); + box-shadow: inset 0 0 0 1px var(--border-button); } .shortcutFilter:focus-within { - box-shadow: inset 0 0 0 1px var(--accent); + box-shadow: inset 0 0 0 1px var(--focus-ring); } .leading { + flex: none; color: var(--fg-subtle); - margin-right: 4px; } .filterRecorder { flex: 1; @@ -67,6 +85,11 @@ box-shadow: none; outline: none; } +.filterRecorder > span { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} .treeWrap { flex: 1; @@ -75,7 +98,7 @@ flex-direction: column; border-radius: var(--radius-small); box-shadow: inset 0 0 0 1px var(--border); - padding: 2px 0; + padding-block: var(--space-0-5); } .empty { padding: 8px 12px; @@ -97,26 +120,21 @@ } .actionIcon { display: inline-flex; + flex: none; width: 14px; color: var(--fg-subtle); } .actionTitle { - flex: 1; - min-width: 0; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; + flex: 1 0 auto; } .modified { color: var(--accent); } .bindings { display: inline-flex; - gap: var(--space-1); - padding-right: 10px; -} -.kbd { - color: var(--fg-muted); + flex: none; + gap: var(--space-2); + padding-inline: var(--space-2); } /* recorder */ @@ -221,12 +239,6 @@ font-size: var(--fs-small); } -.toolbarSep { - width: 1px; - height: 16px; - margin: 0 4px; - background: var(--border); -} .conflictsLabel { color: var(--fg); padding-top: 4px; diff --git a/src/features/settings/keymap/KeymapPage.tsx b/src/features/settings/keymap/KeymapPage.tsx index 18ffce972c..4b4c56df49 100644 --- a/src/features/settings/keymap/KeymapPage.tsx +++ b/src/features/settings/keymap/KeymapPage.tsx @@ -373,26 +373,27 @@ export function KeymapPage() { return (
- - - - + { + const r = gearRef.current?.getBoundingClientRect(); + showContextMenu(r ? { x: r.left, y: r.bottom + 2 } : { x: 0, y: 0 }, gearMenu()); + }} + /> +
{overrideCount > 0 && ( {overrideCount === 1 ? tx`${overrideCount} modified action` : tx`${overrideCount} modified actions`} @@ -401,68 +402,71 @@ export function KeymapPage() {
- {byShortcut ? ( -
- - - {shortcut && ( - setShortcut("")} /> - )} -
- ) : ( - + setCollapsed(new Set())} /> + setCollapsed(new Set(allGroups))} /> + { + if (!leadAction) return; + setRecordMouse(false); + setRecordFor(leadAction); + }} /> - )} - { - setByShortcut((v) => !v); - setShortcut(""); - }} - /> - { - setQuery(""); - setShortcut(""); - }} - /> - - setCollapsed(new Set())} /> - setCollapsed(new Set(allGroups))} /> - - { - if (!leadAction) return; - setRecordMouse(false); - setRecordFor(leadAction); - }} - /> +
+
+ {byShortcut ? ( +
+ + + {shortcut && ( + setShortcut("")} /> + )} +
+ ) : ( + + )} + { + setByShortcut((v) => !v); + setShortcut(""); + }} + /> + { + setQuery(""); + setShortcut(""); + }} + /> +
aria-label="Actions" + horizontalScroll roots={roots} getKey={(n) => n.key} getLabel={(n) => (n.kind === "group" ? n.name : n.action.title)} @@ -507,7 +511,7 @@ export function KeymapPage() { {n.name} ) : ( - + {n.action.icon && } {n.bindings.map((b) => ( - + ))} diff --git a/src/features/settings/model/schema.ts b/src/features/settings/model/schema.ts index 773daa3381..de4f44506d 100644 --- a/src/features/settings/model/schema.ts +++ b/src/features/settings/model/schema.ts @@ -41,7 +41,6 @@ import { type NotificationsValid, } from "./behaviorSchema"; import { isThemeChoiceId, type ThemeChoiceId } from "@/platform/themes"; -import { PLAYFUL_AFTER_LIMITS } from "@/platform/agentStatus"; /** Agents › IDE MCP Server › Port: its default (`ide-core::settings::DEFAULT_MCP_PORT`) and range. */ export const DEFAULT_MCP_PORT = 26371; @@ -238,9 +237,6 @@ export const DEFAULT_SETTINGS: ValidSettings = { foldTurns: true, smoothText: true, fitWindowWidth: false, - playfulStatus: false, - playfulAfterSeconds: 0, - playfulWords: {}, thinking: "auto", toolCalls: "grouped", expandToolOutput: false, @@ -291,15 +287,6 @@ function agentDefaults(v: unknown): Record> { return Object.fromEntries(Object.entries(obj(v)).map(([agent, options]) => [agent, stringMap(options)])); } -/** Activity → the user's playful words; a list, even an empty one, stands for that activity. */ -function playfulWords(v: unknown): Record { - return Object.fromEntries( - Object.entries(obj(v)) - .filter(([, words]) => Array.isArray(words)) - .map(([activity, words]) => [activity, stringList(words)]), - ); -} - function agentMcpServers(v: unknown): Required["mcpServers"] { const out: Required["mcpServers"] = {}; for (const [name, raw] of Object.entries(obj(v))) { @@ -453,9 +440,6 @@ export function validateSettings(raw: Settings | unknown): ValidSettings { foldTurns: bool(agents.foldTurns, d.agents.foldTurns), smoothText: bool(agents.smoothText, d.agents.smoothText), fitWindowWidth: bool(agents.fitWindowWidth, d.agents.fitWindowWidth), - playfulStatus: bool(agents.playfulStatus, d.agents.playfulStatus), - playfulAfterSeconds: num(agents.playfulAfterSeconds, d.agents.playfulAfterSeconds, PLAYFUL_AFTER_LIMITS, true), - playfulWords: playfulWords(agents.playfulWords), thinking: oneOf(agents.thinking, ["auto", "expanded", "collapsed"] as const, d.agents.thinking), toolCalls: oneOf(agents.toolCalls, ["grouped", "each"] as const, d.agents.toolCalls), expandToolOutput: bool(agents.expandToolOutput, d.agents.expandToolOutput), diff --git a/src/features/vcs/GitLog.tsx b/src/features/vcs/GitLog.tsx index 60e12c9c12..048fc8dd49 100644 --- a/src/features/vcs/GitLog.tsx +++ b/src/features/vcs/GitLog.tsx @@ -1,7 +1,16 @@ import { tx } from "@/platform/i18n"; import { call, commands } from "@/platform/ipc"; import { useWorkflowSettings } from "@/platform/workflowSettings"; -import { EmptyState, IconButton, SplitGroup, SplitHandle, SplitPanel, T, Tabs } from "@/ui"; +import { + EmptyState, + IconButton, + SplitGroup, + SplitHandle, + SplitPanel, + T, + Tabs, + useFrozenWhileWindowResizes, +} from "@/ui"; import { copySelectionOnKeyDown } from "@/ui/selectableText"; import { spanStyle } from "@/ui/ansi"; import clsx from "clsx"; @@ -68,6 +77,10 @@ export function GitToolWindow() { const { shown } = useGitTabs(); const available = useVcs((s) => s.available); const external = useGitLog((s) => s.logTabs.some((t) => t.id === s.tab && t.readOnly)); + // The log's rows, graph and branch tree are too much for WebKit to relayout at every step of a + // window drag; they follow the window once it stops. + const root = useRef(null); + useFrozenWhileWindowResizes(root); if (!available && !external) return ( @@ -76,6 +89,7 @@ export function GitToolWindow() { ); return (
void; }) { const [rows, setRows] = useState(() => initialRows(range.commits)); + const [selectedId, setSelectedId] = useState(() => rows[0]?.commit.id); + const pageRef = useRef(null); + const [stacked, setStacked] = useState(false); + useLayoutEffect(() => { + const page = pageRef.current; + if (!page) return; + const measure = () => setStacked(page.clientWidth < 640); + measure(); + if (typeof ResizeObserver === "undefined") return; + const observer = new ResizeObserver(measure); + observer.observe(page); + return () => observer.disconnect(); + }, []); + + const selectedIndex = rows.findIndex((r) => r.commit.id === selectedId); + const selected = rows[selectedIndex]; const problem = planProblem(rows); const noop = planIsNoop(rows, range.commits); const update = (i: number, patch: Partial) => @@ -440,62 +456,104 @@ function InteractiveRebaseDialog({ open title={rebaseTitle(range.commits.length, range.base && short(range.base))} onClose={onClose} - width={720} - footerStart={problem ? {problem} : undefined} + width={960} + minWidth={360} + minHeight={360} + resizable="both" + className={styles.rebaseDialog} buttons={[ { label: "Start Rebasing", role: "default", disabled: !!problem || noop, onClick: start }, { label: "Cancel", role: "cancel" }, ]} > -
- Commits are applied from top to bottom. -
-
- {rows.map((r, i) => ( -
- - value={r.action} - options={ACTIONS} - aria-label={tx`Action for ${short(r.commit.id)}`} - className={styles.rebaseAction} - onChange={(action) => update(i, { action })} - /> - {r.commit.shortId} - {r.action === "reword" ? ( -