дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-06 01:57:13 +02:00
Порівняти коміти
| Автор | SHA1 | Дата | |
|---|---|---|---|
|
|
dc6ee7d0ef | ||
|
|
c0e82f7e2c | ||
|
|
9abe3d7e3c | ||
|
|
4e5ae49aa9 | ||
|
|
9443517d1c | ||
|
|
29f6131f9d | ||
|
|
4027b8341f | ||
|
|
ddc483fd2a | ||
|
|
23d81a2b3d |
No files matched your search
@@ -0,0 +1,129 @@
|
||||
---
|
||||
name: pr
|
||||
description: Prepare and open an OpenIDEA pull request that a maintainer can accept from its description — scope check, the checks CI runs, evidence chosen by the kind of change, UX consistency review, and a filled-in template. Use before opening or updating a PR ("提 pr", "open a PR", "写 PR 描述", "准备验收证据").
|
||||
---
|
||||
|
||||
# Open a pull request with evidence
|
||||
|
||||
A reviewer should be able to accept the PR from its description: what changed, why, and proof
|
||||
that it works and didn't break its neighbours. Evidence is the part people skip; it is required.
|
||||
|
||||
## 1. Scope
|
||||
|
||||
- One problem per PR. If the description needs more than 2–4 sentences, split it.
|
||||
- `Closes #<n>` when it resolves an issue. Read the issue's comments first: a maintainer may
|
||||
already have decided how it should behave.
|
||||
- The diff contains only what the problem needs: no drive-by refactors, formatting of untouched
|
||||
files, generated files you didn't need to regenerate, or local IDE state (`.openidea/`).
|
||||
- A product decision you can't make (layout or navigation restructure, a changed default, an
|
||||
unclear expected behaviour) → ask in the issue, label `needs-decision`, stop.
|
||||
- Title in Conventional Commits, written as the commit you want on `main`:
|
||||
`fix(editor): keep the caret visible after folding`. It describes the change, not the
|
||||
process; no references to screenshots, other products or "parity".
|
||||
|
||||
## 2. Checks
|
||||
|
||||
Run what CI runs for the parts you touched (`AGENTS.md` § Before opening a PR). Run long checks
|
||||
one at a time. Paste the command and its result line (`test result: ok. 412 passed`,
|
||||
`Tests 87 passed`), not "tests pass".
|
||||
|
||||
Easy to miss:
|
||||
|
||||
| You touched | Also run |
|
||||
| --------------------------------------------------------------- | ------------------------------------------------------------------------------------ |
|
||||
| Any `.ts`/`.tsx`, including tests | `pnpm typecheck` |
|
||||
| A feature's UI | every spec under `e2e/` whose name contains the feature |
|
||||
| New regex in frontend code | `pnpm vitest run src/platform/webkitCompatibility.test.ts` |
|
||||
| Text catalog keys | `pnpm vitest run src/platform/locales/textCatalog.test.ts src/platform/i18n.test.ts` |
|
||||
| `tokens.css` | `pnpm gen:theme-docs`, then the full `pnpm test` |
|
||||
| Moved or removed exports | `pnpm knip` |
|
||||
| A `pub fn` signature | `cargo test -p <crate>` (all targets), or workspace clippy |
|
||||
| A new crate dependency, or imports in files the smoke runs load | `pnpm vitest run scripts/smoke-paths.test.ts` |
|
||||
| IPC types | `pnpm gen:bindings`, commit `src/bindings.ts` |
|
||||
| `wit/` or the plugin SDK | `plugins/build.sh`, commit the rebuilt `dist/` |
|
||||
|
||||
## 3. Evidence
|
||||
|
||||
Pick every row that applies. Evidence must come from the final commit of the branch; re-take it
|
||||
after review changes that affect it.
|
||||
|
||||
| Change | Evidence |
|
||||
| ------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Bug fix | A test that fails on `main` and passes on the branch (name it), or exact steps from a fresh start with the before/after result |
|
||||
| Visible UI | `before.png` / `after.png` at the same state and window size. Every theme the change touches (at least Islands Light and Islands Dark when colours, borders or icons change). The narrow case when width matters |
|
||||
| Interaction: multi-step, drag and drop, keyboard, focus, animation | A short recording (GIF/MP4), or numbered screenshots of each step |
|
||||
| Keyboard shortcut or action | Where it appears (Find Action, menu, keymap settings) and that it doesn't clash in the default keymaps |
|
||||
| Code intelligence / language support | Which `fixtures/` project, `cargo test -p ide-host --test language_smoke -- --ignored --exact <language>` output; for Java, `pnpm eval --only <id>` numbers before/after |
|
||||
| Run / debug | `pnpm smoke smoke/run.test.ts -t <language>` or `smoke/debug.test.ts`, plus a screenshot of the Run/Debug tool window |
|
||||
| Performance | Before/after numbers on the same machine and build type (`pnpm perf`, `pnpm perf:rust`, or the exact measurement), and evidence the results are identical: a fast path must return the same results or fall back |
|
||||
| Windows / Linux only | The platform's CI job, and a screenshot or log from a real machine. Say plainly if you couldn't run it on that platform |
|
||||
| Backend / IPC | Test output; logs for behaviour tests can't reach |
|
||||
| Remote development / containers / WSL | The flow against a real `openidea-server` host or container, with a screenshot or log |
|
||||
| Plugin API / `wit/` | A sample plugin exercising the change, and the rebuilt `dist/` |
|
||||
| Settings / persisted data / migrations | Start from data written by the previous release and show it still loads and behaves the same |
|
||||
| Security fix | A test for the attack case. Describe the class of problem only; follow `SECURITY.md` for anything not yet public |
|
||||
| Copy, docs, pure refactor | The commands run, and "No visible change" / "no behaviour change" stated |
|
||||
|
||||
Also state what else the change could affect (other languages, platforms, entry points such as
|
||||
menu / context menu / shortcut, other themes) and how you checked each.
|
||||
|
||||
How to capture:
|
||||
|
||||
- Use the `verify` skill to drive the app and take screenshots. Before: on `main` (or with the
|
||||
fix reverted). After: on the branch, same state and window size.
|
||||
- Crop to the relevant area when the window is large, but keep enough context to locate it.
|
||||
- Drag screenshots and recordings into the PR description on GitHub. Never commit them.
|
||||
- No real credentials, tokens, private repository names or personal paths in screenshots or logs.
|
||||
|
||||
## 4. UX consistency
|
||||
|
||||
For any change users can see, review it against `DESIGN.md`, `PRODUCT.md` and
|
||||
`docs/en/contribute/guidelines/ui.mdx` before taking the "after" screenshots:
|
||||
|
||||
- Tokens only; spacing on the `--space-*` scale; icons from `src/ui/icons.tsx`; no emoji.
|
||||
- Built from `src/ui/` primitives and workbench contributions; it looks like its neighbours
|
||||
(same row height, font size, padding, hover/selection, empty state) rather than new.
|
||||
- Same action, same name, place and shortcut as elsewhere in the IDE.
|
||||
- Keyboard reachable, visible focus, focus returns sensibly; `aria-label` on icon buttons.
|
||||
- Every new string in `en.json` and `zh.json`; long translations don't break the layout.
|
||||
- Light and dark, default and narrow widths all look right.
|
||||
- The Impeccable design skills can help critique and polish; they read `DESIGN.md`,
|
||||
`PRODUCT.md` and `.impeccable/`.
|
||||
|
||||
A layout or navigation restructure needs a maintainer decision first (§ 1).
|
||||
|
||||
## 5. Description
|
||||
|
||||
Fill in `.github/pull_request_template.md`; keep it short and plain:
|
||||
|
||||
```markdown
|
||||
Closes #123
|
||||
|
||||
## What and why
|
||||
|
||||
<The change a user notices, and the root cause. 2–4 sentences.>
|
||||
|
||||
## How it was verified
|
||||
|
||||
- [x] Bug fix: `pnpm vitest run src/features/editor/folding.test.ts` — the new
|
||||
`keeps caret visible after fold` fails on main, passes here (12 passed)
|
||||
- [x] Visible UI: before / after (Islands Light, Islands Dark)
|
||||
<screenshots>
|
||||
- `pnpm typecheck`, `pnpm lint`, `pnpm e2e e2e/editor-folding.spec.ts` — all pass
|
||||
- Also affected: folding from the gutter and from ⌘- — both checked in the app
|
||||
|
||||
## Review focus
|
||||
|
||||
<Optional.>
|
||||
```
|
||||
|
||||
The `PR check` workflow labels the PR `needs-info` when **How it was verified** is empty, or when
|
||||
the PR changes UI files and the section has no screenshot or recording and doesn't say
|
||||
"No visible change".
|
||||
|
||||
## 6. Before you push
|
||||
|
||||
- Re-read the diff as the reviewer: anything unrelated, debug output, commented-out code,
|
||||
leftover TODOs?
|
||||
- Rebased on current `main`; checks re-run if the rebase changed anything they cover.
|
||||
- Open as draft while evidence is missing; mark ready once it's in.
|
||||
@@ -0,0 +1,59 @@
|
||||
---
|
||||
name: verify
|
||||
description: Build, launch and drive the OpenIDEA desktop app through the Tauri MCP bridge to verify a change at runtime.
|
||||
---
|
||||
|
||||
# Verify OpenIDEA in the running app
|
||||
|
||||
## Launch
|
||||
|
||||
- Run the app from the worktree that holds the change: `pnpm tauri dev` in the background, logging
|
||||
into your task's scratch subdirectory. Use `pnpm dev:app` instead when your checks call
|
||||
`window.__TAURI__` from `execute_js`. The wrapper gives each worktree its own app identity, data,
|
||||
settings and Vite port, so other worktrees and the installed app don't interfere. If it reports a
|
||||
session already running for this worktree, reuse that one.
|
||||
- Once the app is up, `pnpm dev:status` lists this worktree's MCP bridges. Pass the reported
|
||||
`appIdentifier` (the port) on every `mcp__tauri__*` call. The MCP server is shared between
|
||||
sessions: never `driver_session stop` without an `appIdentifier`, and re-check `document.title` /
|
||||
`location.href` before acting if anything looks off.
|
||||
- Make sure the binary contains the change: a session already running for this worktree may be an
|
||||
older build. Restart it after Rust changes; frontend changes reload through Vite.
|
||||
- After the app restarts, `driver_session start` again for your port (a stale session says "Already connected").
|
||||
- If the `pnpm tauri dev` process exits while the app window stays open, Vite is gone and any webview
|
||||
reload shows an empty `#root`. Stop that app and start the session again.
|
||||
- Stop everything you started when done and nothing else; never use process-name kills.
|
||||
|
||||
## Driving
|
||||
|
||||
- `manage_window focus` before screenshots / timing-sensitive steps: a background window throttles timers
|
||||
(debounced LSP / VCS refreshes stall, `setTimeout` promises in `execute_js` time out) and native
|
||||
screenshots come back black.
|
||||
- Settings is a separate native window `settings-main`; pass `windowId`, focus it before screenshotting.
|
||||
- CodeMirror / xterm ignore MCP `type`. Focus the element, then `document.execCommand('insertText', false, text)`.
|
||||
For xterm Enter, dispatch a `keydown` (`key: 'Enter', keyCode: 13`) on `.xterm-helper-textarea`.
|
||||
- MCP clicks arrive with `event.detail === 0`; CodeMirror treats them as line-select clicks. Set the caret
|
||||
through the view instead: `document.querySelector('.cm-content').cmTile.view`.
|
||||
- MCP `text` strategy can resolve to a hidden node; prefer coordinates (CSS px = image px × 0.9) or CSS selectors.
|
||||
- CSS-module edits often trigger a full page reload in dev: dialogs close, Run sessions and terminal
|
||||
scrollback reset, and each reload spawns a fresh shell. Re-open what you were testing.
|
||||
|
||||
## Evidence
|
||||
|
||||
- For UI or interaction changes, capture `before.png` (on `main` or with the fix reverted) and
|
||||
`after.png` at the same state and window size, into your task's scratch subdirectory. Multi-step
|
||||
flows: a numbered series (`after-1.png`, `after-2.png`, ...). When colours, borders or icons
|
||||
change, take each in Islands Light and Islands Dark. The `pr` skill lists what evidence each
|
||||
kind of change needs.
|
||||
- Report the absolute paths; they go into the PR's **How it was verified** section and the triage
|
||||
acceptance entry. Never commit screenshots to the feature branch.
|
||||
|
||||
## Fixture
|
||||
|
||||
`fixtures/` has sample projects (go-app, rust-app, ts-app, kotlin-gradle, polyglot). Copy one into
|
||||
your scratch directory before editing it, and don't commit the IDE state it creates (`.openidea/`).
|
||||
|
||||
## Flows worth driving
|
||||
|
||||
⌘⇧O Goto File · ⌘⇧F Find in Files (preview scroll + highlight) · ⌘⇧A Find Action · editor edit/undo/autosave ·
|
||||
Terminal (Unicode, venv) · Commit view at the default narrow width · Problems · Run → Stop · Project view
|
||||
New / Delete (nested `a/b.txt` names) · ⌘, Settings search (+ Keymap filter) · Git Log on a repo without commits.
|
||||
Symlink
@@ -0,0 +1 @@
|
||||
../../.agents/skills/pr
|
||||
Symlink
@@ -0,0 +1 @@
|
||||
../../.agents/skills/verify
|
||||
@@ -7,11 +7,20 @@
|
||||
|
||||
## How it was verified
|
||||
|
||||
<!-- Required. Commands you actually ran and their results; what else this could
|
||||
affect and how you checked it still works.
|
||||
Visible UI changes: before/after screenshots (not for removed UI or copy-only
|
||||
changes). Multi-step interactions: a recording.
|
||||
Backend changes: logs or command output. -->
|
||||
<!-- Required, from the final version of this branch. Commands you actually ran and
|
||||
their results; what else this could affect and how you checked it still works.
|
||||
Then the evidence for each kind of change this PR makes (AGENTS.md § Issues & PRs):
|
||||
|
||||
- Bug fix: a test that fails on main and passes here, or exact repro steps
|
||||
- Visible UI: before/after screenshots, same state and size; each theme touched
|
||||
- Interaction (multi-step, drag, keyboard, focus): a recording
|
||||
- Code intelligence / run / debug: language_smoke or smoke output on a fixture
|
||||
- Performance: before/after numbers on the same machine, and the results unchanged
|
||||
- Windows/Linux only: CI job plus a screenshot or log from a real machine
|
||||
- Settings / persisted data: starting from the previous version's data
|
||||
- Copy, docs, refactor, no UI change: write "No visible change"
|
||||
|
||||
Drag screenshots and recordings in here; don't commit them. -->
|
||||
|
||||
## Review focus
|
||||
|
||||
|
||||
@@ -370,6 +370,9 @@ jobs:
|
||||
node-version: 22
|
||||
cache: ${{ runner.environment != 'self-hosted' && 'pnpm' || '' }}
|
||||
package-manager-cache: ${{ runner.environment != 'self-hosted' }}
|
||||
# src/features/dotnet/edit.test.ts runs the real `dotnet sln` / `dotnet add reference`.
|
||||
- uses: actions/setup-dotnet@v5
|
||||
with: { dotnet-version: 10.0.x }
|
||||
- run: pnpm install --frozen-lockfile
|
||||
- run: pnpm typecheck
|
||||
- run: pnpm lint
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
name: PR check
|
||||
on:
|
||||
# pull_request_target so the check can label PRs from forks. It never checks out
|
||||
# or runs PR code: it only reads the PR title and description.
|
||||
# or runs PR code: it only reads the PR title, description and changed file names.
|
||||
pull_request_target:
|
||||
types: [opened, edited, reopened, ready_for_review]
|
||||
types: [opened, edited, reopened, ready_for_review, synchronize]
|
||||
|
||||
permissions:
|
||||
issues: write
|
||||
@@ -34,6 +34,24 @@ jobs:
|
||||
|
||||
const { owner, repo } = context.repo;
|
||||
const issue_number = pr.number;
|
||||
|
||||
if (verified && verified[1].trim()) {
|
||||
const section = verified[1];
|
||||
const hasMedia =
|
||||
/!\[[^\]]*\]\(|<img\b|<video\b|github\.com\/user-attachments\/|https?:\/\/\S+\.(png|jpe?g|gif|webp|mp4|mov|webm)\b/i.test(section);
|
||||
const optedOut = /no visible change/i.test(section);
|
||||
if (!hasMedia && !optedOut) {
|
||||
const files = await github.paginate(github.rest.pulls.listFiles, { owner, repo, pull_number: issue_number, per_page: 100 });
|
||||
const ui = files
|
||||
.filter(f => f.status !== 'removed')
|
||||
.map(f => f.filename)
|
||||
.filter(name => /^src\/.*\.(tsx|css)$/.test(name) && !/\.(test|spec)\.tsx$/.test(name));
|
||||
if (ui.length) {
|
||||
const shown = ui.slice(0, 3).map(n => `\`${n}\``).join(', ') + (ui.length > 3 ? ', …' : '');
|
||||
problems.push(`This PR changes UI files (${shown}). Add before/after screenshots, or a recording for interactions, to **How it was verified**; if nothing users see changed, write "No visible change" and say what you checked.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
const comments = await github.paginate(github.rest.issues.listComments, { owner, repo, issue_number });
|
||||
const existing = comments.find(c => c.user.type === 'Bot' && c.body.includes(MARKER));
|
||||
const labeled = pr.labels.some(l => l.name === LABEL);
|
||||
|
||||
+6
-5
@@ -33,12 +33,13 @@ target/
|
||||
test-results/
|
||||
playwright-report/
|
||||
|
||||
# Local AI agent files
|
||||
AGENTS.md
|
||||
CLAUDE.md
|
||||
# Local AI agent files. Shared skills live in .agents/skills; .claude/skills links to them.
|
||||
CLAUDE.local.md
|
||||
.agents/
|
||||
.claude/
|
||||
.claude/*
|
||||
!.claude/skills/
|
||||
.claude/skills/*
|
||||
!.claude/skills/pr
|
||||
!.claude/skills/verify
|
||||
|
||||
# Local reference screenshots
|
||||
pycharm-screenshots/
|
||||
@@ -0,0 +1,197 @@
|
||||
# OpenIDEA — contributor guide
|
||||
|
||||
Rust + Tauri 2 desktop IDE with full-featured, multi-language code intelligence.
|
||||
Visual style: rounded content islands on a grey frame, low-contrast greys, one cool accent;
|
||||
Islands Light is the default theme. `src/styles/tokens.css` is the source of truth for colours
|
||||
and metrics; `DESIGN.md` and `PRODUCT.md` describe the design system and who the product is for.
|
||||
|
||||
## Layout
|
||||
|
||||
- `crates/ide-*` — backend crates; one domain each. Depend on `ide-core` for shared
|
||||
types; never reach into another crate's internals.
|
||||
- `src-tauri/` — glue only: `state.rs` (AppState / Project), `commands/<domain>.rs`
|
||||
(desktop-only commands; the adapters of `ide-host` commands are derived), `events.rs`.
|
||||
No domain logic here.
|
||||
- `src/bindings.ts` — generated by tauri-specta (`pnpm gen:bindings`). Never edit.
|
||||
- `src/platform/` — ipc (`call`, `onIdeEvent`, `nextRequestId`), actions registry,
|
||||
keymap + dispatcher, context keys / `when` clauses, project store.
|
||||
- `src/workbench/contributions.ts` — extension points (tool windows, status items,
|
||||
overlays, editor kinds) and cross-feature services (editor, tool windows, notifications).
|
||||
- `src/ui/` — design-system primitives. `src/features/<name>/` — one feature each,
|
||||
exporting `activate()` registered in `src/features/index.ts`.
|
||||
- `languages/<id>.toml` — language definitions (detection, comments, LSP, DAP).
|
||||
- `crates/ide-host` — the `openidea-server` binary for remote development and the
|
||||
`openidea-plugin` CLI (plugin starter templates live in its `templates.rs`).
|
||||
- `wit/` — plugin interface definitions; `plugins/` — sample and bundled plugins.
|
||||
Plugin docs: `plugins/README.md`, `plugins/themes.md`.
|
||||
- `java/` — JDT LS extension bundles (`java-usages`, `kotlin-bridge`) and the patched
|
||||
Lombok agent, embedded into the app by `ide-sdk` / `ide-tools`.
|
||||
- `e2e/` — Playwright UI tests (`pnpm e2e`). `evals/` — code-intelligence evals (`pnpm eval`).
|
||||
`fixtures/` — sample projects per language for manual and automated testing.
|
||||
- `docs/` — the Mintlify documentation site (`docs.json` navigation, `en/` and `zh/` pages);
|
||||
preview with `npx mint dev` in `docs/`.
|
||||
|
||||
## Rules
|
||||
|
||||
- IPC coordinates: 0-based lines, **UTF-16** columns/offsets everywhere (`ide-core::text`).
|
||||
- Every command returns `IdeResult<T>`; convert internal errors at the crate edge.
|
||||
- Declare a command once, on its implementation: `#[command(trust = …)]` in `ide-host::ops`
|
||||
plus its module's `domain!` list (Tauri adapter, server handler and bindings are derived);
|
||||
desktop-only commands use `#[desktop_command(trust = …)]` and `desktop_domain!`.
|
||||
- Streaming → `tauri::ipc::Channel<T>`; cancellable → UI-allocated `RequestId` +
|
||||
`cancel_request`. Backend → UI notifications → `IdeEvent` via `EventSink`.
|
||||
- Long work never blocks the UI thread or a Tauri command thread: use
|
||||
`spawn_blocking`/rayon, honour `CancellationToken`.
|
||||
- Frontend features never import each other; communicate via actions, contributions
|
||||
and services. All user-invocable behaviour is an action with a stable id; default
|
||||
shortcuts live in `src/platform/keymaps/`.
|
||||
- Styling: CSS Modules + tokens only (no hex literals in components). Inline SVG
|
||||
icons from `src/ui/icons.tsx`, never emoji. Real `<button>`/`<input>`; `aria-label` on icon buttons.
|
||||
`gap` uses the `--space-*` scale (`src/styles/tokens.css`, 4px grid) where a value is on it.
|
||||
- User-visible text goes through the text catalog: add every new string to both
|
||||
`src/platform/locales/text/en.json` and `zh.json` (`textCatalog.test.ts` enforces it).
|
||||
Other locales may lack entries; their UI shows the English text until a translator adds it.
|
||||
- Keep comments sparse and purposeful; match surrounding style.
|
||||
- New regular expressions in frontend code must run on WebKit (no lookbehind):
|
||||
`src/platform/webkitCompatibility.test.ts` checks them.
|
||||
- For GUI verification, prefer Tauri MCP; use Computer Use only when Tauri MCP is
|
||||
unavailable or cannot cover the required checks.
|
||||
|
||||
## UX changes
|
||||
|
||||
A change to what users see or how they interact must look and behave like the rest of the IDE.
|
||||
|
||||
- `DESIGN.md` (colours, type, layout, components, Do's and Don'ts) and `PRODUCT.md`
|
||||
(users, principles, accessibility) are the reference; `docs/en/contribute/guidelines/ui.mdx`
|
||||
has the code-level rules. Build from `src/ui/` primitives and workbench contributions;
|
||||
don't create a one-off control, colour or spacing when an existing one fits.
|
||||
- Check every theme the change touches (at least Islands Light and Islands Dark) and narrow
|
||||
sizes (e.g. the Commit tool window at its default width, a small window). Long translated
|
||||
strings must not break the layout.
|
||||
- Everything works from the keyboard; focus is visible and lands somewhere sensible when a
|
||||
popup or dialog closes. Icon-only buttons have an `aria-label` and a tooltip.
|
||||
- Follow the conventions users of this kind of IDE already know: the same action keeps the
|
||||
same name, place and shortcut across views. Don't invent a new pattern for an existing one.
|
||||
- Agent and MCP features follow good agent-tool practice: restrained, predictable, reversible.
|
||||
- Restructuring a page layout or navigation, or changing a default behaviour, needs a
|
||||
maintainer's decision first: ask in the issue and label it `needs-decision`.
|
||||
- The Impeccable design skills may be used for design critique and polish; they read
|
||||
`DESIGN.md`, `PRODUCT.md` and `.impeccable/`. A detector exception goes in
|
||||
`.impeccable/config.json` with a reason.
|
||||
|
||||
## Issues & PRs
|
||||
|
||||
Follow `CONTRIBUTING.md` and `.github/pull_request_template.md`: one problem per PR
|
||||
(`Closes #<n>` when it resolves an issue), reproduce first, keep the diff focused, short plain
|
||||
description. Unclear product decisions → `needs-decision` and stop.
|
||||
|
||||
Every PR carries evidence a reviewer can accept without re-running everything, in
|
||||
**How it was verified**. It must come from the final version of the branch:
|
||||
|
||||
| Change | Evidence |
|
||||
| ----------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Bug fix | A test that fails before the fix and passes after, or exact reproduction steps with before/after result |
|
||||
| Visible UI | Before/after screenshots at the same state and window size; each theme the change touches |
|
||||
| Interaction (multi-step, drag, keyboard, focus) | A short recording or numbered screenshots |
|
||||
| Code intelligence / language support | The fixture used and `language_smoke` output; `pnpm eval` numbers for Java |
|
||||
| Run / debug | `pnpm smoke smoke/run.test.ts` / `smoke/debug.test.ts -t <language>` output |
|
||||
| Performance | Before/after numbers on the same machine (`pnpm perf`, `pnpm perf:rust` or a stated measurement), plus proof the results are unchanged |
|
||||
| Windows / Linux only | The platform's CI job, and a screenshot or log from a real machine |
|
||||
| Backend / IPC | Test output; regenerated `src/bindings.ts` when types changed |
|
||||
| Remote development | The flow against a real `openidea-server` host |
|
||||
| Plugin API / `wit/` | `plugins/build.sh` run and `dist/` committed; a sample plugin using the change |
|
||||
| Settings / persisted data | Behaviour when starting from data written by the previous version |
|
||||
| Copy, docs, refactor | The commands run; "No visible change" when nothing users see changed |
|
||||
|
||||
Attach screenshots and recordings to the PR description; never commit them. The `pr` skill
|
||||
has the full checklist.
|
||||
|
||||
## Skills
|
||||
|
||||
Shared agent skills live in `.agents/skills/` (`.claude/skills/` links to them):
|
||||
`pr` prepares a pull request — checks to run, evidence for the kind of change, description;
|
||||
`verify` drives the running app through Tauri MCP and captures screenshot evidence.
|
||||
|
||||
## Commands
|
||||
|
||||
- Optional: `mise install` provisions the contributor toolchain; `mise tasks` lists the task aliases.
|
||||
See [Development setup](docs/en/contribute/setup.mdx). The direct commands below still work without mise.
|
||||
- `pnpm tauri dev` — run the app with worktree isolation. Use Node 22.22.2 or later on the 22.x line.
|
||||
`pnpm dev:app` also enables the global Tauri API. `pnpm dev:status` reports
|
||||
this worktree's running MCP bridges and actual ports.
|
||||
- `pnpm build` — typecheck + bundle frontend.
|
||||
- `pnpm dogfood:local [--build-only]` (or `mise run dogfood:local`) — build and locally install the grey-icon dogfood desktop app sharing release settings and data.
|
||||
- `pnpm dogfood:remote <remote_name> [--restart | --no-restart] [--clean]` (or `mise run dogfood:remote <remote_name>`) — sync backend sources to a host from **Tools › SSH Configurations**, build `openidea-server`, and stage it for Remote Development.
|
||||
- `pnpm dogfood:all <remote_name> [--restart | --no-restart]` (or `mise run dogfood:all <remote_name>`) — run `dogfood:local` and `dogfood:remote <remote_name>` in parallel.
|
||||
- `cargo nextest run --workspace` (or `cargo test`), `cargo clippy --workspace --all-targets -- -D warnings`, `cargo fmt --all`.
|
||||
- `cargo test -p ide-host --test language_smoke -- --ignored --exact <language>` — code intelligence
|
||||
on `fixtures/` with that language's real server installed (CI: `Language smoke`, pinned versions).
|
||||
- `pnpm smoke smoke/run.test.ts -t <language>` — run and test that language's fixture through the
|
||||
run store and a real `openidea-server` (build it first: `cargo build -p ide-host --bin openidea-server`).
|
||||
- `pnpm smoke smoke/debug.test.ts -t <language>` — debug that fixture's entry point the same way, with
|
||||
the debugger the IDE installs (on macOS, CodeLLDB and Delve may need Developer Mode:
|
||||
`sudo DevToolsSecurity -enable`).
|
||||
- `pnpm test`, `pnpm e2e`, `pnpm lint`, `pnpm format:check`, `pnpm knip`, `pnpm typecheck`,
|
||||
`pnpm gen:bindings`.
|
||||
- `pnpm perf` (UI interaction latency / frames / leaks), `pnpm perf:rust` (criterion
|
||||
benches vs budgets). Budgets: `perf/budgets.json`.
|
||||
- `pnpm eval [--only <id>] [--runs n] [--save-baseline]` — Java code intelligence (navigation,
|
||||
usages, gutter markers) in the production workbench against a release `openidea-server` and
|
||||
jdtls: time to feedback / first result / complete, results vs `evals/<language>/golden/`.
|
||||
Report: `target/eval/report.json`. Goldens and `evals/budgets.json` are changed by people only.
|
||||
Tool versions: `.github/tool-versions.env` (shared with Language smoke).
|
||||
- `pnpm release:prepare <version>` — the release commit's changes: app version everywhere,
|
||||
`Cargo.lock`, and the plugin API snapshot when `wit/` moved to a new version.
|
||||
|
||||
## Before opening a PR
|
||||
|
||||
Run what CI runs for the parts you touched:
|
||||
|
||||
- Rust: `cargo fmt --all --check`, `cargo clippy --workspace --all-targets -- -D warnings`,
|
||||
`cargo nextest run --workspace`. After changing IPC types, run `pnpm gen:bindings` and
|
||||
commit `src/bindings.ts`; CI fails if it differs.
|
||||
- Frontend: `pnpm typecheck` (vitest does not type-check), `pnpm lint`, `pnpm format:check`,
|
||||
`pnpm knip`, `pnpm test`, `pnpm build`, and every `e2e/` spec of the feature you touched.
|
||||
- New text keys: `src/platform/locales/textCatalog.test.ts` and `src/platform/i18n.test.ts`.
|
||||
New or renamed tokens: `pnpm gen:theme-docs`.
|
||||
- Changed a `pub fn` signature in a crate: run that crate's whole `cargo test`, not one test.
|
||||
- UI or runtime behaviour: verify in the running app (`.agents/skills/verify`) and collect
|
||||
the evidence above (`.agents/skills/pr`).
|
||||
|
||||
## Pitfalls
|
||||
|
||||
- Run a subset of frontend tests with `pnpm vitest run <path>`. `pnpm test -- <path>` ignores
|
||||
the filter and runs the whole suite, which takes several minutes.
|
||||
- Don't run clippy while iterating: `pnpm tauri dev` compiles anyway. Run
|
||||
`cargo fmt --all` + `cargo clippy -p <crate> --all-targets -- -D warnings` once, right
|
||||
before committing. A cold build cache can take around 5 minutes. Run long checks one at
|
||||
a time, not chained in one shell call that may hit the 10-minute tool timeout.
|
||||
- `pnpm tauri dev` does a full debug build. Clippy only checks the code, so a passing clippy
|
||||
doesn't make the first launch fast.
|
||||
|
||||
## Parallel worktrees
|
||||
|
||||
Several worktrees can be developed and run side by side.
|
||||
|
||||
- Create one per task: `git worktree add ../<name> -b <branch> origin/main`, then
|
||||
`pnpm install` in it.
|
||||
- Launch with `pnpm tauri dev` / `pnpm dev:app`, not the raw `pnpm exec tauri dev` CLI. The
|
||||
wrapper starts Vite on a worktree-derived port (advancing if occupied), passes its actual
|
||||
URL to Tauri, and reports an existing launcher instead of starting another for the same
|
||||
worktree. HMR uses the Vite port.
|
||||
- Debug app identity, data, settings, logs and single-instance scope follow the canonical
|
||||
worktree path captured at build time, independent of launch cwd. Launching the same debug
|
||||
binary again focuses its existing instance and forwards its path argument. Different
|
||||
worktrees and the installed release can coexist. `--release` uses normal release identity
|
||||
and bypasses the development wrapper.
|
||||
- MCP bridge ports are dynamic (9223–9322). Use `pnpm dev:status`, connect to the reported
|
||||
port, verify identifier/cwd, and pass `appIdentifier: <port>` explicitly. Do not assume the
|
||||
default MCP session belongs to this worktree.
|
||||
- Keep each worktree's Cargo output directory separate; do not point `CARGO_TARGET_DIR` or
|
||||
`target` symlinks at a shared directory.
|
||||
- Each worktree's first build is cold (several minutes) and `cargo build` output takes
|
||||
around 9 GB; tests, clippy and incremental builds add more. Avoid running several heavy builds on one machine at the same time.
|
||||
- Stop only processes started for the current worktree/session. Never use broad
|
||||
process-name kills such as `pkill openidea`.
|
||||
- When done: stop that worktree's app and dev session, delete its build output, then
|
||||
`git worktree remove ../<name>`.
|
||||
Symlink
@@ -0,0 +1 @@
|
||||
AGENTS.md
|
||||
@@ -1,6 +1,7 @@
|
||||
# Contributing to OpenIDEA
|
||||
|
||||
These rules apply to everyone, and to any coding agent working on their behalf.
|
||||
Project layout, coding rules, commands, checks and the evidence a PR needs are in [AGENTS.md](AGENTS.md).
|
||||
|
||||
## Issues
|
||||
|
||||
@@ -26,7 +27,12 @@ These rules apply to everyone, and to any coding agent working on their behalf.
|
||||
- **How it was verified** is required: the commands you ran and their results,
|
||||
and what else the change could affect. Changes to what users see need before/after
|
||||
screenshots; multi-step interactions need a recording. UI that goes away with a removed
|
||||
feature, copy-only and non-visual changes don't; say what you checked instead.
|
||||
feature, copy-only and non-visual changes don't; write "No visible change" and say what
|
||||
you checked instead. [AGENTS.md](AGENTS.md#issues--prs) lists the evidence for each kind of
|
||||
change (tests, smoke output, perf numbers, real-machine logs…).
|
||||
- Changes to what users see follow [DESIGN.md](DESIGN.md) and the existing UI: tokens,
|
||||
`src/ui/` primitives, both themes, keyboard access. Restructuring a layout or navigation
|
||||
needs a maintainer's decision first.
|
||||
- If a change needs a product decision you can't make, ask in the issue and stop
|
||||
rather than guessing.
|
||||
|
||||
@@ -35,4 +41,4 @@ and the plugin API. Community plugins live in their authors' repositories and
|
||||
are listed through [l0ng-ai/openidea-plugins](https://github.com/l0ng-ai/openidea-plugins);
|
||||
see [`plugins/README.md`](plugins/README.md) § 8.1.
|
||||
|
||||
A check on each PR adds `needs-info` when the verification section is missing, and removes it once it's filled in.
|
||||
A check on each PR adds `needs-info` when the verification section is missing, or when the PR changes UI files and the section has neither a screenshot nor a recording nor "No visible change". It removes the label once that's fixed.
|
||||
@@ -66,4 +66,4 @@ pnpm e2e -g "opens a file" # by test name
|
||||
|
||||
## Verifying in the real app
|
||||
|
||||
Unit and E2E tests don't run the Rust backend inside the webview. For UI or runtime behaviour, run `pnpm tauri dev` and check the change in the app. Debug builds include the Tauri MCP bridge, so the check can be scripted; find the port with `pnpm dev:status` (see [Development setup](/en/contribute/setup#mcp-bridge-and-ports)).
|
||||
Unit and E2E tests don't run the Rust backend inside the webview. For UI or runtime behaviour, run `pnpm tauri dev` and check the change in the app. Debug builds include the Tauri MCP bridge, so the check can be scripted; find the port with `pnpm dev:status` (see [Development setup](/en/contribute/setup#mcp-bridge-and-ports)). The repository's agent skill `.agents/skills/verify` describes driving the app that way and capturing screenshots.
|
||||
@@ -3,7 +3,7 @@ title: "Contribution workflow"
|
||||
description: "How issues are triaged, what a pull request needs, how verification is checked, and how changes get merged."
|
||||
---
|
||||
|
||||
These rules come from [`CONTRIBUTING.md`](https://github.com/l0ng-ai/openidea/blob/main/CONTRIBUTING.md) and apply to everyone, including coding agents working on someone's behalf.
|
||||
These rules come from [`CONTRIBUTING.md`](https://github.com/l0ng-ai/openidea/blob/main/CONTRIBUTING.md) and apply to everyone, including coding agents working on someone's behalf. Coding rules, commands, checks and the evidence each kind of change needs are in [`AGENTS.md`](https://github.com/l0ng-ai/openidea/blob/main/AGENTS.md).
|
||||
|
||||
## Issues
|
||||
|
||||
@@ -60,9 +60,9 @@ This section is required. Include:
|
||||
- **visible UI changes:** before/after screenshots; **multi-step interactions:** a recording;
|
||||
- **backend changes:** logs or command output.
|
||||
|
||||
Screenshots are not needed for UI that goes away with a removed feature, copy-only changes or non-visual changes; say what you checked instead.
|
||||
Screenshots are not needed for UI that goes away with a removed feature, copy-only changes or non-visual changes; write "No visible change" and say what you checked instead. [`AGENTS.md`](https://github.com/l0ng-ai/openidea/blob/main/AGENTS.md#issues--prs) lists the evidence for each kind of change: failing-then-passing tests, smoke output, before/after performance numbers, real-machine logs for platform-only changes, and so on.
|
||||
|
||||
A workflow (`.github/workflows/pr-check.yml`) reads each PR's description when it is opened or edited. If **How it was verified** is missing or empty, it comments and adds `needs-info`; once you fill it in, it removes its comment and the label. It only reads the title and description, never your code.
|
||||
A workflow (`.github/workflows/pr-check.yml`) reads each PR's description when it is opened or edited. If **How it was verified** is missing or empty, or the PR changes UI files (`.tsx` or `.css` under `src/`, tests excluded) and the section has no screenshot or recording and doesn't say "No visible change", it comments and adds `needs-info`; once you fix it, it removes its comment and the label. It reads the title, the description and the list of changed file names, never your code.
|
||||
|
||||
### Checks to run
|
||||
|
||||
|
||||
@@ -66,4 +66,4 @@ pnpm e2e -g "opens a file" # 按测试名
|
||||
|
||||
## 在真实应用中验证
|
||||
|
||||
单元测试和 E2E 都不会在 webview 里运行 Rust 后端。UI 或运行时行为的改动,请运行 `pnpm tauri dev` 在应用里检查。debug 构建包含 Tauri MCP bridge,可以用脚本驱动检查;端口用 `pnpm dev:status` 查(见[开发环境](/zh/contribute/setup))。
|
||||
单元测试和 E2E 都不会在 webview 里运行 Rust 后端。UI 或运行时行为的改动,请运行 `pnpm tauri dev` 在应用里检查。debug 构建包含 Tauri MCP bridge,可以用脚本驱动检查;端口用 `pnpm dev:status` 查(见[开发环境](/zh/contribute/setup))。仓库里的 agent skill `.agents/skills/verify` 描述了这种驱动应用并截图的方式。
|
||||
@@ -3,7 +3,7 @@ title: "贡献流程"
|
||||
description: "issue 如何分流、PR 需要包含什么、验证说明如何检查,以及改动如何合并。"
|
||||
---
|
||||
|
||||
以下规则来自 [`CONTRIBUTING.md`](https://github.com/l0ng-ai/openidea/blob/main/CONTRIBUTING.md),对所有人都适用,包括代表某人工作的编码 agent。
|
||||
以下规则来自 [`CONTRIBUTING.md`](https://github.com/l0ng-ai/openidea/blob/main/CONTRIBUTING.md),对所有人都适用,包括代表某人工作的编码 agent。编码规则、命令、检查项以及各类改动需要的验收证据见 [`AGENTS.md`](https://github.com/l0ng-ai/openidea/blob/main/AGENTS.md)。
|
||||
|
||||
## Issue
|
||||
|
||||
@@ -56,9 +56,9 @@ description: "issue 如何分流、PR 需要包含什么、验证说明如何检
|
||||
- **可见的 UI 改动**:前后对比截图;**多步交互**:录屏;
|
||||
- **后端改动**:日志或命令输出。
|
||||
|
||||
随功能一起删除的 UI、只改文案或不涉及界面的改动不需要截图,写明你检查了什么即可。
|
||||
随功能一起删除的 UI、只改文案或不涉及界面的改动不需要截图,写上 "No visible change" 并说明你检查了什么即可。各类改动需要的证据(先失败后通过的测试、冒烟输出、性能前后数据、只涉及某个平台时的实机日志等)见 [`AGENTS.md`](https://github.com/l0ng-ai/openidea/blob/main/AGENTS.md#issues--prs)。
|
||||
|
||||
工作流 `.github/workflows/pr-check.yml` 会在 PR 创建或编辑时读取描述。如果 **How it was verified** 缺失或为空,它会留言并打上 `needs-info`;补全后会删掉自己的留言并移除标签。它只读标题和描述,不会检出或运行你的代码。
|
||||
工作流 `.github/workflows/pr-check.yml` 会在 PR 创建或编辑时读取描述。如果 **How it was verified** 缺失或为空,或者 PR 改了 UI 文件(`src/` 下的 `.tsx` 或 `.css`,测试除外)而这一节既没有截图或录屏、也没写 "No visible change",它会留言并打上 `needs-info`;补全后会删掉自己的留言并移除标签。它只读标题、描述和改动的文件名,不会检出或运行你的代码。
|
||||
|
||||
### 要跑的检查
|
||||
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
import type { AgentPluginCatalog, AgentPluginState } from "../src/bindings";
|
||||
import { expect, stubDesktop, test } from "./fixtures";
|
||||
|
||||
const makePlugin = (name: string, consentRequired: boolean): AgentPluginState => ({
|
||||
plugin: {
|
||||
id: name,
|
||||
name,
|
||||
displayName: name,
|
||||
version: "26.1021.31345",
|
||||
description: "A plugin with a long description explaining what it can do for the agent in this workspace.",
|
||||
marketplace: "context-engineering-marketplace-with-a-long-name",
|
||||
source: "claudeUser",
|
||||
scope: "user",
|
||||
formats: ["claude", "codex", "copilot"],
|
||||
rootPath: "/Users/dev/.claude/plugins/cache/context-engineering-marketplace/agent-plugin",
|
||||
defaultEnabled: false,
|
||||
approxTokens: 2550,
|
||||
capabilities: {
|
||||
skillCount: 17,
|
||||
mcpCount: 1,
|
||||
ruleCount: 2,
|
||||
subagentCount: 3,
|
||||
commandCount: 0,
|
||||
hookFiles: consentRequired ? ["hooks/a-very-long-lifecycle-hook-file-name.json"] : [],
|
||||
requiresConsent: consentRequired,
|
||||
},
|
||||
valid: true,
|
||||
},
|
||||
enabled: !consentRequired,
|
||||
origin: consentRequired ? "consent" : "none",
|
||||
consentRequired,
|
||||
});
|
||||
|
||||
test("agent plugin metadata stays clear of enable and review controls at narrow widths", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
const longName = "Context Engineering with an exceptionally long plugin display name";
|
||||
const catalog: AgentPluginCatalog = {
|
||||
plugins: [makePlugin(longName, true), makePlugin("Frontend Design", false)],
|
||||
marketplaces: [
|
||||
{
|
||||
id: "official",
|
||||
name: "claude-plugins-official",
|
||||
source: "example/official",
|
||||
scope: "user",
|
||||
discovered: true,
|
||||
},
|
||||
{
|
||||
id: "community",
|
||||
name: "context-engineering-marketplace-with-a-long-name",
|
||||
source: "example/community",
|
||||
scope: "user",
|
||||
discovered: true,
|
||||
},
|
||||
],
|
||||
projectedSkills: 17,
|
||||
projectedMcpServers: 1,
|
||||
projectedRules: 2,
|
||||
};
|
||||
await stubDesktop(page);
|
||||
await page.evaluate(async (catalog) => {
|
||||
window.__ipc.handlers.agent_plugins_list = () => structuredClone(catalog);
|
||||
window.__ipc.handlers.window_open_settings = () => {
|
||||
throw { kind: "unavailable", message: "separate settings window disabled in browser test", detail: null };
|
||||
};
|
||||
const actionsModule = "/src/platform/actions.ts";
|
||||
const { executeAction } = await import(/* @vite-ignore */ actionsModule);
|
||||
await executeAction("file.settings", "agents.plugins");
|
||||
}, catalog);
|
||||
const dialog = page.getByRole("dialog", { name: "Settings", exact: true });
|
||||
await expect(dialog).toBeVisible();
|
||||
const group = dialog.getByRole("region", { name: "Claude Code · User" });
|
||||
const rows = group.getByRole("listitem");
|
||||
await expect(rows).toHaveCount(2);
|
||||
const review = rows.first().getByRole("button", { name: "Review & Enable…" });
|
||||
await expect(review).toBeVisible();
|
||||
for (const width of [1120, 780, 580, 520]) {
|
||||
await page.setViewportSize({ width, height: 760 });
|
||||
await expect(async () => {
|
||||
const fit = await rows.evaluateAll((items) =>
|
||||
items.every((row) => {
|
||||
const expand = row.querySelector("button[aria-expanded]")!;
|
||||
const action = expand.nextElementSibling!;
|
||||
const bounds = row.getBoundingClientRect();
|
||||
const a = expand.getBoundingClientRect();
|
||||
const b = action.getBoundingClientRect();
|
||||
const title = expand.querySelector("[title]")!.getBoundingClientRect();
|
||||
return (
|
||||
title.width > 0 &&
|
||||
a.right <= bounds.right + 1 &&
|
||||
b.right <= bounds.right + 1 &&
|
||||
(a.right <= b.left + 1 || a.bottom <= b.top + 1) &&
|
||||
expand.scrollWidth <= expand.clientWidth + 1
|
||||
);
|
||||
}),
|
||||
);
|
||||
expect(fit).toBe(true);
|
||||
}).toPass();
|
||||
if (process.env.SETTINGS_EVIDENCE)
|
||||
await dialog.screenshot({
|
||||
path: `${process.env.SETTINGS_EVIDENCE}/plugins-${width}.png`,
|
||||
animations: "disabled",
|
||||
});
|
||||
}
|
||||
|
||||
await rows
|
||||
.first()
|
||||
.getByRole("button", { name: new RegExp(longName) })
|
||||
.click();
|
||||
await expect(rows.first().getByText(catalog.plugins[0]!.plugin.marketplace!)).toBeVisible();
|
||||
await expect(rows.first().getByText(".claude-plugin · .codex-plugin · .plugin")).toBeVisible();
|
||||
await expect(rows.first().getByText(catalog.plugins[0]!.plugin.description, { exact: true })).toBeVisible();
|
||||
if (process.env.SETTINGS_EVIDENCE) {
|
||||
await page.setViewportSize({ width: 1120, height: 760 });
|
||||
await page.evaluate(async () => {
|
||||
const themePath = "/src/workbench/theme.ts";
|
||||
const { setTheme } = await import(/* @vite-ignore */ themePath);
|
||||
await setTheme("dark");
|
||||
});
|
||||
await dialog.screenshot({
|
||||
path: `${process.env.SETTINGS_EVIDENCE}/plugins-expanded-dark.png`,
|
||||
animations: "disabled",
|
||||
});
|
||||
}
|
||||
await review.click();
|
||||
await expect(page.getByRole("dialog", { name: /Approve Plugin Capabilities/ })).toBeVisible();
|
||||
});
|
||||
@@ -0,0 +1,115 @@
|
||||
/**
|
||||
* Solution and project-reference edits from the Project view (#7421). The host is stubbed at the IPC
|
||||
* layer (no `dotnet` runs; `src/features/dotnet/edit.test.ts` runs the real CLI): the spec checks
|
||||
* the menus and the exact `dotnet` commands they start.
|
||||
*/
|
||||
import type { Page } from "@playwright/test";
|
||||
import { expect, stubDesktop, test } from "./fixtures";
|
||||
|
||||
const SHOTS = process.env.E2E_SHOTS;
|
||||
|
||||
/** Stubs the process host: records the `dotnet` argument lists and answers `sln list` with `listed`. */
|
||||
async function stubHost(page: Page, listed: string[]) {
|
||||
await stubDesktop(page);
|
||||
await page.evaluate(
|
||||
async ({ listed }) => {
|
||||
const h = window.__ipc.handlers;
|
||||
const runs: string[][] = [];
|
||||
(window as unknown as { __runs: string[][] }).__runs = runs;
|
||||
let id = 100;
|
||||
h.run_start = (args) => {
|
||||
const config = args.config as { args: string[] };
|
||||
runs.push(config.args);
|
||||
const run = ++id;
|
||||
setTimeout(() => {
|
||||
const text = config.args[2] === "list" ? `Project(s)\n----------\n${listed.join("\n")}\n` : "ok\n";
|
||||
window.__ipc.send(args.onOutput, { kind: "stdout", text });
|
||||
window.__ipc.emit({ type: "runExited", run, code: 0 });
|
||||
}, 20);
|
||||
return { id: run, configId: "x", name: "dotnet", pid: 1, running: true, pty: false };
|
||||
};
|
||||
h["plugin:dialog|open"] = () => ["/dev/acme-api/Lib/Lib.csproj"];
|
||||
const storeModule = "/src/features/dotnet/store.ts";
|
||||
const { useDotnet } = await import(/* @vite-ignore */ storeModule);
|
||||
const project = (path: string, name: string, references: string[] = []) => ({
|
||||
path,
|
||||
name,
|
||||
frameworks: ["net9.0"],
|
||||
configurations: ["Debug"],
|
||||
references,
|
||||
packages: [],
|
||||
test: false,
|
||||
runner: "vstest",
|
||||
adapter: "mstest",
|
||||
trx: false,
|
||||
});
|
||||
useDotnet.setState({
|
||||
model: {
|
||||
projects: [
|
||||
project("/dev/acme-api/App/App.csproj", "App", ["/dev/acme-api/Core/Core.csproj"]),
|
||||
project("/dev/acme-api/Core/Core.csproj", "Core"),
|
||||
],
|
||||
solutions: [
|
||||
{
|
||||
path: "/dev/acme-api/Acme.sln",
|
||||
projects: ["/dev/acme-api/App/App.csproj", "/dev/acme-api/Core/Core.csproj"],
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
},
|
||||
{ listed },
|
||||
);
|
||||
}
|
||||
|
||||
const runs = (page: Page) => page.evaluate(() => (window as unknown as { __runs: string[][] }).__runs);
|
||||
|
||||
test("the solution node adds an existing project with dotnet sln add", async ({ workbench: page }) => {
|
||||
await stubHost(page, ["Lib/Lib.csproj"]);
|
||||
const solution = page.getByRole("treeitem", { name: /Solution 'Acme'/ });
|
||||
await solution.click({ button: "right" });
|
||||
await expect(page.getByRole("menuitem", { name: "Build .NET Project" })).toBeVisible();
|
||||
if (SHOTS) await page.screenshot({ path: `${SHOTS}/b1-solution-menu.png`, animations: "disabled" });
|
||||
await page.getByRole("menuitem", { name: "Add Existing Project…" }).click();
|
||||
await expect
|
||||
.poll(() => runs(page))
|
||||
.toContainEqual(["sln", "/dev/acme-api/Acme.sln", "add", "/dev/acme-api/Lib/Lib.csproj"]);
|
||||
// The project is listed afterwards, so no warning balloon.
|
||||
await expect(page.getByText("was not added")).toHaveCount(0);
|
||||
});
|
||||
|
||||
test("a same-named project the CLI skipped gets a warning", async ({ workbench: page }) => {
|
||||
await stubHost(page, ["Other/Lib.csproj"]);
|
||||
await page.getByRole("treeitem", { name: /Solution 'Acme'/ }).click({ button: "right" });
|
||||
await page.getByRole("menuitem", { name: "Add Existing Project…" }).click();
|
||||
await expect(page.getByText("The project was not added to the solution")).toBeVisible();
|
||||
if (SHOTS) await page.screenshot({ path: `${SHOTS}/b1-same-name-warning.png`, animations: "disabled" });
|
||||
});
|
||||
|
||||
test("a project node offers reference and solution edits", async ({ workbench: page }) => {
|
||||
await stubHost(page, []);
|
||||
await page.getByRole("treeitem", { name: /Solution 'Acme'/ }).click();
|
||||
await page.keyboard.press("ArrowRight");
|
||||
const app = page.getByRole("treeitem", { name: "App", exact: true });
|
||||
await app.click({ button: "right" });
|
||||
await expect(page.getByRole("menuitem", { name: "Add Project Reference…" })).toBeVisible();
|
||||
await expect(page.getByRole("menuitem", { name: "Remove Project Reference" })).toBeVisible();
|
||||
if (SHOTS) await page.screenshot({ path: `${SHOTS}/b1-project-menu.png`, animations: "disabled" });
|
||||
await page.getByRole("menuitem", { name: "Remove from Solution" }).click();
|
||||
await expect
|
||||
.poll(() => runs(page))
|
||||
.toContainEqual(["sln", "/dev/acme-api/Acme.sln", "remove", "/dev/acme-api/App/App.csproj"]);
|
||||
});
|
||||
|
||||
// The model reloads after each edit (the stubbed workspace has no solution), so each edit gets a test.
|
||||
test("Remove Project Reference removes the chosen reference", async ({ workbench: page }) => {
|
||||
await stubHost(page, []);
|
||||
await page.getByRole("treeitem", { name: /Solution 'Acme'/ }).click();
|
||||
await page.keyboard.press("ArrowRight");
|
||||
await page.getByRole("treeitem", { name: "App", exact: true }).click({ button: "right" });
|
||||
await page.getByRole("menuitem", { name: "Remove Project Reference" }).hover();
|
||||
await page.getByRole("menuitem", { name: "Core.csproj" }).click();
|
||||
await expect
|
||||
.poll(() => runs(page))
|
||||
.toContainEqual(["remove", "/dev/acme-api/App/App.csproj", "reference", "/dev/acme-api/Core/Core.csproj"]);
|
||||
});
|
||||
@@ -297,6 +297,53 @@ test("run configuration fields share a control column including the name", async
|
||||
expect(boxes[0]!.width).toBeGreaterThan(80);
|
||||
});
|
||||
|
||||
test("on Linux, Python configuration fields stay aligned with long arguments when resizing", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
const args = '-c "conf/development settings.conf" -d DEMO_DEVELOPMENT -u demo_module --log-level debug';
|
||||
await page.evaluate(async (args) => {
|
||||
// WebKitGTK's subgrid tracks shift with a scrollbar (#7469): Linux has its own fixed label column.
|
||||
document.documentElement.dataset.os = "linux";
|
||||
const store = "/src/features/run/store.ts";
|
||||
const types = "/src/features/run/types.ts";
|
||||
const { useRun } = await import(/* @vite-ignore */ store);
|
||||
const { newConfigOfType, typeFor, withParams } = await import(/* @vite-ignore */ types);
|
||||
const type = typeFor("python")!;
|
||||
const base = newConfigOfType(type, []);
|
||||
const config = withParams(
|
||||
{ ...base, name: "Python demo", target: "development", env: { APP_ENV: "development" } },
|
||||
{ ...base.params, script: "src/main.py", args },
|
||||
type,
|
||||
);
|
||||
useRun.setState({ configs: [config], selectedId: config.id, loaded: true, editorOpen: true });
|
||||
}, args);
|
||||
|
||||
const dialog = page.getByRole("dialog", { name: "Run/Debug Configurations", exact: true });
|
||||
const content = dialog.locator("#run-config-content");
|
||||
const argumentField = dialog.getByRole("textbox", { name: "Arguments", exact: true });
|
||||
const fields = ["Name", "Arguments", "Working directory", "Environment variables"].map((name) =>
|
||||
dialog.getByRole("textbox", { name, exact: true }),
|
||||
);
|
||||
for (const field of fields) await expect(field).toBeVisible();
|
||||
await expect(argumentField).toHaveValue(args);
|
||||
const initial = (await content.boundingBox())!;
|
||||
const argumentsBeforeResize = (await argumentField.boundingBox())!;
|
||||
const offset = argumentsBeforeResize.x - initial.x;
|
||||
|
||||
const grip = (await dialog.getByRole("separator", { name: "Resize", exact: true }).boundingBox())!;
|
||||
await page.mouse.move(grip.x + grip.width / 2, grip.y + grip.height / 2);
|
||||
await page.mouse.down();
|
||||
await page.mouse.move(grip.x - 160, grip.y - 180, { steps: 5 });
|
||||
await page.mouse.up();
|
||||
|
||||
const resized = (await content.boundingBox())!;
|
||||
expect(resized.width).toBeLessThan(initial.width);
|
||||
expect((await argumentField.boundingBox())!.width).toBeLessThan(argumentsBeforeResize.width);
|
||||
const boxes = await Promise.all(fields.map((field) => field.boundingBox()));
|
||||
for (const box of boxes) expect(box!.x - resized.x).toBeCloseTo(offset, 0);
|
||||
await expect(argumentField).toHaveValue(args);
|
||||
});
|
||||
|
||||
test("resizing the configuration dialog grows its panes and keeps the footer visible", async ({ workbench: page }) => {
|
||||
await openConfigurations(page);
|
||||
const dialog = page.getByRole("dialog", { name: "Run/Debug Configurations", exact: true });
|
||||
|
||||
@@ -308,6 +308,45 @@ describe("applying completions", () => {
|
||||
expect(view.state.selection.main.head).toBe(expected.indexOf("|"));
|
||||
});
|
||||
|
||||
it.each([
|
||||
{
|
||||
name: "break in a switch case",
|
||||
doc: "switch (c) {\n case A:\n bre|\n default:\n}",
|
||||
label: "break",
|
||||
expected: "switch (c) {\n case A:\n break;|\n default:\n}",
|
||||
},
|
||||
{
|
||||
name: "continue in a loop",
|
||||
doc: "for (var e : list) {\n if (e == null) cont|\n}",
|
||||
label: "continue",
|
||||
expected: "for (var e : list) {\n if (e == null) continue;|\n}",
|
||||
},
|
||||
{
|
||||
name: "break inside a labeled loop, which can name the label",
|
||||
doc: "outer:\nfor (int i = 0; i < n; i++) {\n while (true) {\n bre|\n }\n}",
|
||||
label: "break",
|
||||
expected: "outer:\nfor (int i = 0; i < n; i++) {\n while (true) {\n break |\n }\n}",
|
||||
},
|
||||
{ name: "break before its semicolon", doc: "bre|;", label: "break", expected: "break|;" },
|
||||
{ name: "break before a label", doc: "bre| outer;", label: "break", expected: "break| outer;" },
|
||||
])("completes a Java $name as IDEA does (#7358)", ({ doc, label, expected }) => {
|
||||
const { view, req, pos } = setup(doc);
|
||||
const typed = doc.slice(0, doc.indexOf("|")).match(/\w+$/)![0];
|
||||
apply(
|
||||
view,
|
||||
makeCompletion(item({ label, kind: "keyword", insertText: label }), { ...req, language: "java" }),
|
||||
pos - typed.length,
|
||||
);
|
||||
expect(view.state.doc.toString()).toBe(expected.replace("|", ""));
|
||||
expect(view.state.selection.main.head).toBe(expected.indexOf("|"));
|
||||
});
|
||||
|
||||
it("leaves other languages' break alone", () => {
|
||||
const { view, req, pos } = setup("bre|");
|
||||
apply(view, makeCompletion(item({ label: "break", kind: "keyword", insertText: "break" }), req), pos - 3);
|
||||
expect(view.state.doc.toString()).toBe("break");
|
||||
});
|
||||
|
||||
it("replaces a Java annotation name before its existing arguments with Tab", () => {
|
||||
const { view, req, pos } = setup('@Sup|pressWarnings("unused")');
|
||||
const suggestion = item({
|
||||
|
||||
@@ -253,6 +253,8 @@ function completionInsertText(
|
||||
to: number,
|
||||
): string {
|
||||
const { insertText } = item;
|
||||
if (language === "java" && item.kind === "keyword" && JUMP_KEYWORDS.has(insertText))
|
||||
return insertText + javaJumpTail(doc, from, to);
|
||||
// JDT LS can append a space to a bare annotation name. It is useful only as a separator.
|
||||
if (language !== "java" || item.kind !== "interface" || insertText !== `${item.label} `) return insertText;
|
||||
const line = doc.lineAt(from);
|
||||
@@ -262,6 +264,38 @@ function completionInsertText(
|
||||
return item.label;
|
||||
}
|
||||
|
||||
const JUMP_KEYWORDS = new Set(["break", "continue"]);
|
||||
const LABEL =
|
||||
/[\n;{}]\s*(?!case\b|default\b)[\p{L}_$][\p{L}\p{N}_$]*\s*:\s*(?:for|while|do|switch)?\s*(?:\([^]*\))?\s*$/u;
|
||||
/** How far back the enclosing statements are looked for. */
|
||||
const LABEL_SCAN = 20_000;
|
||||
|
||||
/**
|
||||
* What follows a completed `break` / `continue` in Java (#7358), as in IDEA: `;`, or a space for
|
||||
* the label inside a labeled statement; nothing when the line already goes on (`break;`, `break outer`).
|
||||
*/
|
||||
function javaJumpTail(doc: Text, from: number, to: number): string {
|
||||
const after = doc.sliceString(to, doc.lineAt(to).to);
|
||||
if (/^\s*[;\p{L}\p{N}_$]/u.test(after)) return "";
|
||||
return insideLabeledStatement(doc, from) ? " " : ";";
|
||||
}
|
||||
|
||||
/** Whether a block enclosing `pos` is a labeled statement's (`outer: for (…) {`); comments and strings are not skipped. */
|
||||
function insideLabeledStatement(doc: Text, pos: number): boolean {
|
||||
const start = Math.max(0, pos - LABEL_SCAN);
|
||||
const text = doc.sliceString(start, pos);
|
||||
let depth = 0;
|
||||
for (let i = text.length - 1; i >= 0; i--) {
|
||||
const ch = text[i];
|
||||
if (ch === "}") depth++;
|
||||
else if (ch === "{") {
|
||||
if (depth > 0) depth--;
|
||||
else if (LABEL.test("\n" + text.slice(Math.max(0, i - 400), i))) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** ↵ (`insert`) or ⇥ (`replace`: also overwrites the rest of the identifier). */
|
||||
export function applyLspCompletion(
|
||||
view: EditorView,
|
||||
|
||||
@@ -82,7 +82,7 @@ const markdown = {
|
||||
".tok-string, .tok-string2": { color: "var(--syn-string)" },
|
||||
".tok-number, .tok-bool, .tok-atom": { color: "var(--syn-number)" },
|
||||
".tok-typeName, .tok-className, .tok-namespace": { color: "var(--syn-type)" },
|
||||
".tok-comment": { color: "var(--syn-comment)", fontStyle: "italic" },
|
||||
".tok-comment": { color: "var(--syn-comment)", fontStyle: "var(--syn-comment-italic, var(--syn-comment-style))" },
|
||||
".tok-meta, .tok-macroName": { color: "var(--syn-annotation)" },
|
||||
".tok-propertyName": { color: "var(--syn-property)" },
|
||||
".tok-variableName.tok-definition": { color: "var(--syn-function)" },
|
||||
|
||||
@@ -1,17 +1,49 @@
|
||||
/* Keep technical metadata from competing with the row's name and action. */
|
||||
.row {
|
||||
min-height: var(--h-row);
|
||||
padding-block: 2px;
|
||||
padding: var(--space-1-5) var(--space-2);
|
||||
}
|
||||
|
||||
.expand {
|
||||
align-items: flex-start;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.expand > svg {
|
||||
margin-top: var(--space-0-5);
|
||||
}
|
||||
|
||||
.titleRow {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: var(--space-1-5);
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.entryTitle {
|
||||
flex-shrink: 0;
|
||||
min-width: 0;
|
||||
color: var(--fg-strong);
|
||||
font-weight: 500;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.titleRow .entryTitle {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.version {
|
||||
flex: none;
|
||||
max-width: 40%;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
color: var(--fg-muted);
|
||||
font-size: var(--fs-small);
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
color: var(--fg-muted);
|
||||
font-size: var(--fs-small);
|
||||
@@ -20,8 +52,81 @@
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.scopeSelect {
|
||||
min-width: 120px;
|
||||
.statusRow {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--space-0-5) var(--space-2);
|
||||
color: var(--warning);
|
||||
font-size: var(--fs-small);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.nativeHint {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-1);
|
||||
}
|
||||
|
||||
.nativeHint > svg,
|
||||
.nativeHint > img {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.description {
|
||||
color: var(--fg);
|
||||
line-height: 1.45;
|
||||
white-space: pre-wrap;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.groupTitle {
|
||||
flex-shrink: 0;
|
||||
max-width: calc(100% - 48px);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.groupPath {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.rowControls {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
@container settings-content (max-width: 360px) {
|
||||
.reviewRow {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.reviewRow .expand {
|
||||
flex-basis: 100%;
|
||||
}
|
||||
|
||||
.version {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.groupToggle {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.groupPath {
|
||||
flex-basis: 100%;
|
||||
padding-left: var(--space-4);
|
||||
}
|
||||
|
||||
.searchRow {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.searchRow > :first-child {
|
||||
flex-basis: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.controls {
|
||||
@@ -36,7 +141,7 @@
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-2);
|
||||
padding: 10px 12px;
|
||||
padding: var(--space-2) var(--space-3);
|
||||
border-radius: var(--radius-control);
|
||||
background: var(--bg-elev);
|
||||
box-shadow: inset 0 0 0 1px var(--border);
|
||||
@@ -54,7 +159,8 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--space-1-5);
|
||||
gap: var(--space-1) var(--space-3);
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.summaryTitle {
|
||||
@@ -66,12 +172,15 @@
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: var(--space-1);
|
||||
padding: 2px 8px;
|
||||
border-radius: var(--radius-small);
|
||||
border: 1px solid var(--border);
|
||||
background: var(--bg-app);
|
||||
padding: 0;
|
||||
border: 0;
|
||||
background: none;
|
||||
color: var(--link);
|
||||
font-size: var(--fs-tiny);
|
||||
font-size: var(--fs-small);
|
||||
text-align: left;
|
||||
min-width: 0;
|
||||
max-width: 100%;
|
||||
overflow-wrap: anywhere;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
@@ -98,14 +207,17 @@
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: var(--space-1);
|
||||
padding: 2px 7px;
|
||||
border-radius: var(--radius-small);
|
||||
background: var(--bg-app);
|
||||
box-shadow: inset 0 0 0 1px var(--border);
|
||||
font-size: var(--fs-tiny);
|
||||
min-width: 0;
|
||||
max-width: 100%;
|
||||
font-size: var(--fs-small);
|
||||
color: var(--fg-secondary);
|
||||
}
|
||||
|
||||
.marketplaceChip > span:not(:first-child) {
|
||||
overflow-wrap: anywhere;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.dialogBody {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
@@ -213,38 +213,38 @@ export function AgentPluginsPage({ backend = defaultPluginsBackend }: { backend?
|
||||
|
||||
<div className={styles.summaryBox}>
|
||||
<div className={styles.summaryHeader}>
|
||||
<div className={styles.summaryPills}>
|
||||
<span className={styles.summaryTitle}>
|
||||
<T>Active Bundle Projection</T>
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
className={styles.projectionLink}
|
||||
onClick={() => void executeAction("file.settings", SKILLS_PAGE)}
|
||||
>
|
||||
{formatMessage(tx("{count} skills → Skills"), { count: catalog.projectedSkills })}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className={styles.projectionLink}
|
||||
onClick={() => void executeAction("file.settings", MCP_PAGE)}
|
||||
>
|
||||
{formatMessage(tx("{count} MCP servers → MCP Connections"), { count: catalog.projectedMcpServers })}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className={styles.projectionLink}
|
||||
onClick={() => void executeAction("file.settings", MEMORY_PAGE)}
|
||||
>
|
||||
{formatMessage(tx("{count} rules → Memory"), { count: catalog.projectedRules })}
|
||||
</button>
|
||||
</div>
|
||||
<span className={styles.summaryTitle}>
|
||||
<T>Active Bundle Projection</T>
|
||||
</span>
|
||||
{backend.addMarketplace && (
|
||||
<Button size="small" onClick={() => setMarketplacesOpen(true)}>
|
||||
{formatMessage(tx("Marketplaces ({count})…"), { count: catalog.marketplaces.length })}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
<div className={styles.summaryPills}>
|
||||
<button
|
||||
type="button"
|
||||
className={styles.projectionLink}
|
||||
onClick={() => void executeAction("file.settings", SKILLS_PAGE)}
|
||||
>
|
||||
{formatMessage(tx("{count} skills → Skills"), { count: catalog.projectedSkills })}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className={styles.projectionLink}
|
||||
onClick={() => void executeAction("file.settings", MCP_PAGE)}
|
||||
>
|
||||
{formatMessage(tx("{count} MCP servers → MCP Connections"), { count: catalog.projectedMcpServers })}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className={styles.projectionLink}
|
||||
onClick={() => void executeAction("file.settings", MEMORY_PAGE)}
|
||||
>
|
||||
{formatMessage(tx("{count} rules → Memory"), { count: catalog.projectedRules })}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{catalog.marketplaces.length > 0 && (
|
||||
<div className={styles.marketplaceRow}>
|
||||
@@ -289,7 +289,7 @@ export function AgentPluginsPage({ backend = defaultPluginsBackend }: { backend?
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className={page.searchRow}>
|
||||
<div className={clsx(page.searchRow, styles.searchRow)}>
|
||||
<SearchField
|
||||
className={page.search}
|
||||
value={query}
|
||||
@@ -322,14 +322,16 @@ export function AgentPluginsPage({ backend = defaultPluginsBackend }: { backend?
|
||||
<div className={page.sectionBar}>
|
||||
<button
|
||||
type="button"
|
||||
className={page.sectionToggle}
|
||||
className={clsx(page.sectionToggle, styles.groupToggle)}
|
||||
aria-expanded={!isCollapsed}
|
||||
onClick={() => setCollapsed((prev) => ({ ...prev, [key]: !prev[key] }))}
|
||||
>
|
||||
<Icon name={isCollapsed ? "chevron-right" : "chevron-down"} size={14} className={page.chevron} />
|
||||
<span className={page.sectionTitle}>{title}</span>
|
||||
<span className={clsx(page.sectionTitle, styles.groupTitle)}>{title}</span>
|
||||
<span className={page.badge}>{items.length}</span>
|
||||
<span className={page.sectionHint}>{pluginGroupPath(source, scope)}</span>
|
||||
<span className={clsx(page.sectionHint, styles.groupPath)} title={pluginGroupPath(source, scope)}>
|
||||
{pluginGroupPath(source, scope)}
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -438,41 +440,55 @@ function PluginCard({
|
||||
const { plugin } = state;
|
||||
const summary = componentSummary(state, tx);
|
||||
const group = PLUGIN_SOURCE_GROUPS[plugin.source];
|
||||
const details = [summary, plugin.approxTokens > 0 ? `~${plugin.approxTokens}t` : ""].filter(Boolean).join(" · ");
|
||||
const subtitle = [details, plugin.description].filter(Boolean).join(" · ");
|
||||
const needsReview = state.consentRequired && !state.enabled;
|
||||
|
||||
return (
|
||||
<div role="listitem" className={page.card}>
|
||||
<div className={clsx(page.cardHeader, styles.row)}>
|
||||
<button type="button" className={page.cardExpandBtn} aria-expanded={isExpanded} onClick={onToggleExpand}>
|
||||
<div className={clsx(page.cardHeader, styles.row, needsReview && styles.reviewRow)}>
|
||||
<button
|
||||
type="button"
|
||||
className={clsx(page.cardExpandBtn, styles.expand)}
|
||||
aria-expanded={isExpanded}
|
||||
onClick={onToggleExpand}
|
||||
>
|
||||
<Icon name={isExpanded ? "chevron-down" : "chevron-right"} size={13} className={page.chevron} />
|
||||
<span className={styles.entryTitle}>{plugin.displayName}</span>
|
||||
{plugin.version && <span className={page.tag}>v{plugin.version}</span>}
|
||||
{plugin.marketplace && <span className={page.tag}>{plugin.marketplace}</span>}
|
||||
{plugin.formats.map((f) => (
|
||||
<span key={f} className={page.tag}>
|
||||
{pluginFormatLabel(f)}
|
||||
<span className={page.cardMain}>
|
||||
<span className={styles.titleRow}>
|
||||
<span className={styles.entryTitle} title={plugin.displayName}>
|
||||
{plugin.displayName}
|
||||
</span>
|
||||
{plugin.version && (
|
||||
<span className={styles.version} title={plugin.version}>
|
||||
v{plugin.version}
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
))}
|
||||
{summary && <span className={page.tag}>{summary}</span>}
|
||||
{plugin.approxTokens > 0 && <span className={page.tag}>~{plugin.approxTokens}t</span>}
|
||||
{plugin.description && (
|
||||
<span className={styles.subtitle} title={plugin.description}>
|
||||
{plugin.description}
|
||||
</span>
|
||||
)}
|
||||
{state.origin === "trust" && (
|
||||
<span className={clsx(page.tag, page.tagWarning)}>
|
||||
<T>Untrusted workspace</T>
|
||||
</span>
|
||||
)}
|
||||
{state.consentRequired && (
|
||||
<span className={clsx(page.tag, page.tagWarning)}>
|
||||
<T>Approval required</T>
|
||||
</span>
|
||||
)}
|
||||
{subtitle && (
|
||||
<span className={styles.subtitle} title={subtitle}>
|
||||
{subtitle}
|
||||
</span>
|
||||
)}
|
||||
{(state.origin === "trust" || state.consentRequired) && (
|
||||
<span className={styles.statusRow}>
|
||||
{state.origin === "trust" && (
|
||||
<span>
|
||||
<T>Untrusted workspace</T>
|
||||
</span>
|
||||
)}
|
||||
{state.consentRequired && (
|
||||
<span>
|
||||
<T>Approval required</T>
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
</button>
|
||||
|
||||
<div className={styles.controls}>
|
||||
{state.consentRequired && !state.enabled ? (
|
||||
<div className={clsx(styles.controls, styles.rowControls)}>
|
||||
{needsReview ? (
|
||||
<Button
|
||||
size="small"
|
||||
disabled={busy || (state.origin === "trust" && !hasTrustedProject)}
|
||||
@@ -493,7 +509,34 @@ function PluginCard({
|
||||
|
||||
{isExpanded && (
|
||||
<div className={page.cardDrawer}>
|
||||
{plugin.description && <span className={styles.description}>{plugin.description}</span>}
|
||||
{details && <span className={styles.hint}>{details}</span>}
|
||||
<div className={page.metaGrid}>
|
||||
{plugin.version && (
|
||||
<>
|
||||
<span className={page.metaLabel}>
|
||||
<T>Version</T>
|
||||
</span>
|
||||
<span className={page.metaValue}>{plugin.version}</span>
|
||||
</>
|
||||
)}
|
||||
{plugin.marketplace && (
|
||||
<>
|
||||
<span className={page.metaLabel}>
|
||||
<T>Marketplace</T>
|
||||
</span>
|
||||
<span className={page.metaValue}>{plugin.marketplace}</span>
|
||||
</>
|
||||
)}
|
||||
{plugin.formats.length > 0 && (
|
||||
<>
|
||||
<span className={page.metaLabel}>
|
||||
<T>Format</T>
|
||||
</span>
|
||||
<span className={page.metaValue}>{plugin.formats.map(pluginFormatLabel).join(" · ")}</span>
|
||||
</>
|
||||
)}
|
||||
|
||||
<span className={page.metaLabel}>
|
||||
<T>Scope</T>
|
||||
</span>
|
||||
@@ -558,7 +601,7 @@ function PluginCard({
|
||||
</button>
|
||||
)}
|
||||
{(plugin.capabilities.hookFiles?.length ?? 0) > 0 && (
|
||||
<span className={page.tag}>{(plugin.capabilities.hookFiles ?? []).join(", ")}</span>
|
||||
<span className={page.metaValue}>{(plugin.capabilities.hookFiles ?? []).join(", ")}</span>
|
||||
)}
|
||||
</span>
|
||||
|
||||
@@ -573,8 +616,9 @@ function PluginCard({
|
||||
</div>
|
||||
|
||||
{group.agent && (
|
||||
<span className={styles.hint}>
|
||||
<Icon name={providerIcon(group.agent)} size={12} /> {tx(group.label)} reads this bundle natively.
|
||||
<span className={clsx(styles.hint, styles.nativeHint)}>
|
||||
<Icon name={providerIcon(group.agent)} size={12} />
|
||||
<span>{tx(group.label)} reads this bundle natively.</span>
|
||||
</span>
|
||||
)}
|
||||
|
||||
|
||||
@@ -83,3 +83,9 @@
|
||||
-webkit-user-select: text;
|
||||
user-select: text;
|
||||
}
|
||||
|
||||
/* Some server has a newer version (Update in its row). */
|
||||
.updateBadge {
|
||||
margin-left: 4px;
|
||||
color: var(--accent);
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import { fireEvent, render, screen } from "@testing-library/react";
|
||||
import { registerAction } from "@/platform/actions";
|
||||
import { ServerStatus } from "./ServerStatus";
|
||||
import { useServers, type ServerEntry } from "./servers";
|
||||
import { useToolUpdates } from "@/workbench/contributions";
|
||||
|
||||
const ISSUE_49 =
|
||||
"jdtls needs JDK 25 or newer to run (found JDK 8, 17, 21). Download JDK 25, or pick an installed one in Settings › Languages & Frameworks › Java › Language Server › JDK (it restarts automatically); the project can still target an older Java version.";
|
||||
@@ -10,9 +11,35 @@ const ISSUE_49 =
|
||||
const server = (status: ServerEntry["status"], message: string | null): ServerEntry =>
|
||||
({ id: 1, name: "jdtls", status, message, languages: ["Java"], root: null }) as unknown as ServerEntry;
|
||||
|
||||
afterEach(() => useServers.setState({ servers: new Map() }));
|
||||
afterEach(() => {
|
||||
useServers.setState({ servers: new Map() });
|
||||
useToolUpdates.setState({ latest: {} });
|
||||
});
|
||||
|
||||
describe("Language server status popup", () => {
|
||||
it("marks a server with a newer version and updates it from its row (#7365)", () => {
|
||||
const install = vi.fn();
|
||||
const off = registerAction({ id: "tools.install", title: "Install", run: ({ arg }) => install(arg) });
|
||||
useServers.setState({ servers: new Map([[1 as never, server("ready", null)]]) });
|
||||
useToolUpdates.setState({ latest: { jdtls: "1.64.0" } });
|
||||
render(<ServerStatus />);
|
||||
expect(screen.getByLabelText("Language server updates are available")).toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole("button", { name: /Language servers/ }));
|
||||
fireEvent.click(screen.getByRole("button", { name: "Update jdtls" }));
|
||||
expect(install).toHaveBeenCalledWith("jdtls");
|
||||
off();
|
||||
});
|
||||
|
||||
it("shows no update mark without one", () => {
|
||||
const off = registerAction({ id: "tools.install", title: "Install", run: () => {} });
|
||||
useServers.setState({ servers: new Map([[1 as never, server("ready", null)]]) });
|
||||
render(<ServerStatus />);
|
||||
expect(screen.queryByLabelText("Language server updates are available")).toBeNull();
|
||||
fireEvent.click(screen.getByRole("button", { name: /Language servers/ }));
|
||||
expect(screen.queryByRole("button", { name: "Update jdtls" })).toBeNull();
|
||||
off();
|
||||
});
|
||||
|
||||
it("offers Download JDK N when jdtls can't start for want of a JDK", () => {
|
||||
const run = vi.fn();
|
||||
const off = registerAction({ id: "java.downloadJdk", title: "Download JDK…", run: ({ arg }) => run(arg) });
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import { useMemo, useRef, useState } from "react";
|
||||
import clsx from "clsx";
|
||||
import { getAction, executeAction } from "@/platform/actions";
|
||||
import { BarButton, Button, IconButton, Popup, T } from "@/ui";
|
||||
import { BarButton, Button, Icon, IconButton, Popup, T } from "@/ui";
|
||||
import { downloadJdkActions } from "@/platform/jdk";
|
||||
import { relativePath, useProject } from "@/platform/project";
|
||||
import {
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
} from "./servers";
|
||||
import styles from "./ServerStatus.module.css";
|
||||
import { tx } from "@/platform/i18n";
|
||||
import { useToolUpdates } from "@/workbench/contributions";
|
||||
|
||||
export function ServerStatus() {
|
||||
const map = useServers((s) => s.servers);
|
||||
@@ -28,6 +29,9 @@ export function ServerStatus() {
|
||||
// features/tools owns installing; without it, fall back to the manual hint text.
|
||||
const canInstall = !!getAction("tools.install");
|
||||
const canConfigure = !!getAction("tools.languageServers");
|
||||
const latestVersions = useToolUpdates((s) => s.latest);
|
||||
// Installed servers with a newer version; the same tool can back several servers.
|
||||
const updatable = canInstall ? servers.filter((s) => latestVersions[s.name]) : [];
|
||||
if (!summary) return null;
|
||||
return (
|
||||
<>
|
||||
@@ -40,6 +44,14 @@ export function ServerStatus() {
|
||||
>
|
||||
<span className={clsx(styles.dot, styles[summary.tone])} aria-hidden />
|
||||
{summary.text}
|
||||
{updatable.length > 0 && (
|
||||
<Icon
|
||||
name="arrow-up"
|
||||
size={12}
|
||||
className={styles.updateBadge}
|
||||
label={tx("Language server updates are available")}
|
||||
/>
|
||||
)}
|
||||
</BarButton>
|
||||
<Popup
|
||||
open={open}
|
||||
@@ -56,6 +68,7 @@ export function ServerStatus() {
|
||||
{servers.map((s) => {
|
||||
// jdtls without a JDK new enough to run it: "Download JDK 25".
|
||||
const [jdkFix] = s.status === "misconfigured" ? downloadJdkActions(s.message) : [];
|
||||
const latest = latestVersions[s.name];
|
||||
return (
|
||||
<div key={s.id} className={styles.server}>
|
||||
<div className={styles.line}>
|
||||
@@ -81,6 +94,19 @@ export function ServerStatus() {
|
||||
</Button>
|
||||
) : (
|
||||
<>
|
||||
{latest && updatable.includes(s) && (
|
||||
<Button
|
||||
size="small"
|
||||
aria-label={tx`Update ${s.name}`}
|
||||
title={tx`Version ${latest} is available.`}
|
||||
onClick={() => {
|
||||
setOpen(false);
|
||||
void executeAction("tools.install", s.name);
|
||||
}}
|
||||
>
|
||||
<T>Update</T>
|
||||
</Button>
|
||||
)}
|
||||
{s.status === "missing" && canInstall && (
|
||||
<Button
|
||||
size="small"
|
||||
|
||||
@@ -0,0 +1,300 @@
|
||||
import { execFile, execFileSync } from "node:child_process";
|
||||
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
vi.setConfig({ testTimeout: 90_000, hookTimeout: 90_000 });
|
||||
|
||||
const mocks = vi.hoisted(() => ({ reload: vi.fn(async () => {}), pick: vi.fn(), notify: vi.fn() }));
|
||||
vi.mock("./store", async (orig) => ({ ...(await orig<typeof import("./store")>()), reloadDotnet: mocks.reload }));
|
||||
vi.mock("@/platform/choosePath", () => ({ choosePaths: mocks.pick }));
|
||||
// The real `dotnet` CLI stands in for the Tauri process host: the arguments under test run unchanged.
|
||||
vi.mock("@/platform/dotnet", async (orig) => ({
|
||||
...(await orig<typeof import("@/platform/dotnet")>()),
|
||||
dotnet: (args: string[], cwd: string, signal?: AbortSignal) =>
|
||||
new Promise<string>((resolve, reject) => {
|
||||
const child = execFile(
|
||||
"dotnet",
|
||||
args,
|
||||
{ cwd, signal, env: { ...process.env, DOTNET_CLI_UI_LANGUAGE: "en" } },
|
||||
(err, out, errOut) => (err ? reject(new Error(`${out}${errOut}`.trim() || err.message)) : resolve(out)),
|
||||
);
|
||||
child.on("error", reject);
|
||||
}),
|
||||
}));
|
||||
|
||||
import { useProject } from "@/platform/project";
|
||||
import { provideNotificationService } from "@/workbench/contributions";
|
||||
import { useDotnet } from "./store";
|
||||
import {
|
||||
addProjectReference,
|
||||
addProjectsToSolution,
|
||||
cancelDotnetEdit,
|
||||
editItems,
|
||||
referenceArgs,
|
||||
removeProjectFromSolution,
|
||||
removeProjectReference,
|
||||
slnArgs,
|
||||
} from "./edit";
|
||||
|
||||
const hasDotnet = (() => {
|
||||
try {
|
||||
execFileSync("dotnet", ["--version"], { stdio: "ignore" });
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
})();
|
||||
// CI installs the SDK (setup-dotnet), so a missing one there must fail, not skip.
|
||||
const real = it.skipIf(!hasDotnet && !process.env.CI);
|
||||
|
||||
const csproj = (extra = "") =>
|
||||
`<Project Sdk="Microsoft.NET.Sdk"><PropertyGroup><TargetFramework>net9.0</TargetFramework></PropertyGroup>${extra}</Project>`;
|
||||
|
||||
let dir = "";
|
||||
const file = (rel: string, text = csproj()) => {
|
||||
const path = join(dir, rel);
|
||||
mkdirSync(join(path, ".."), { recursive: true });
|
||||
writeFileSync(path, text);
|
||||
return path;
|
||||
};
|
||||
const solution = (format: "sln" | "slnx", name = "App") => {
|
||||
mkdirSync(join(dir, "sln"), { recursive: true });
|
||||
execFileSync("dotnet", ["new", "sln", "-n", name, "--format", format, "-o", join(dir, "sln")], { stdio: "ignore" });
|
||||
return join(dir, "sln", `${name}.${format}`);
|
||||
};
|
||||
const read = (path: string) => readFileSync(path, "utf8");
|
||||
|
||||
beforeEach(() => {
|
||||
dir = mkdtempSync(join(tmpdir(), "dotnet-edit-"));
|
||||
mocks.reload.mockClear();
|
||||
mocks.notify.mockClear();
|
||||
provideNotificationService({ notify: mocks.notify });
|
||||
});
|
||||
afterEach(() => rmSync(dir, { recursive: true, force: true }));
|
||||
|
||||
describe("CLI arguments", () => {
|
||||
it("builds solution and reference commands", () => {
|
||||
expect(slnArgs("add", "/a/App.sln", ["/a/B.csproj"])).toEqual(["sln", "/a/App.sln", "add", "/a/B.csproj"]);
|
||||
expect(referenceArgs("remove", "/a/A.csproj", ["/b/B.csproj"])).toEqual([
|
||||
"remove",
|
||||
"/a/A.csproj",
|
||||
"reference",
|
||||
"/b/B.csproj",
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
it("does not run an edit queued for the previous project", async () => {
|
||||
const previous = useProject.getState().project;
|
||||
const projectAt = (root: string) => ({ root }) as NonNullable<typeof previous>;
|
||||
useProject.setState({ project: projectAt("/first") });
|
||||
try {
|
||||
const queued = removeProjectFromSolution("/first/App.sln", "/first/App.csproj");
|
||||
useProject.setState({ project: projectAt("/second") });
|
||||
await queued;
|
||||
expect(mocks.notify).not.toHaveBeenCalled();
|
||||
expect(mocks.reload).not.toHaveBeenCalled();
|
||||
} finally {
|
||||
useProject.setState({ project: previous });
|
||||
}
|
||||
});
|
||||
|
||||
describe.each(["sln", "slnx"] as const)("solution edits on .%s (real dotnet CLI)", (format) => {
|
||||
real("adds a project, then removes it, reloading after each", async () => {
|
||||
const sln = solution(format);
|
||||
const project = file("src/Lib/Lib.csproj");
|
||||
await addProjectsToSolution(sln, [project]);
|
||||
expect(read(sln)).toContain("Lib.csproj");
|
||||
expect(mocks.reload).toHaveBeenCalledTimes(1);
|
||||
await removeProjectFromSolution(sln, project);
|
||||
expect(read(sln)).not.toContain("Lib.csproj");
|
||||
expect(mocks.reload).toHaveBeenCalledTimes(2);
|
||||
expect(mocks.notify).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
real("an empty solution gains its first project", async () => {
|
||||
const sln = solution(format);
|
||||
expect(read(sln)).not.toContain("proj");
|
||||
await addProjectsToSolution(sln, [file("A/A.csproj")]);
|
||||
expect(read(sln)).toContain("A.csproj");
|
||||
});
|
||||
|
||||
real("adds a project outside the solution folder (relative .. path)", async () => {
|
||||
const sln = solution(format);
|
||||
await addProjectsToSolution(sln, [file("elsewhere/Out/Out.csproj")]);
|
||||
expect(read(sln).replace(/\\/g, "/")).toContain("../elsewhere/Out/Out.csproj");
|
||||
});
|
||||
|
||||
real("handles spaces and non-ASCII (中文) in paths", async () => {
|
||||
const sln = solution(format);
|
||||
const project = file("my 项目/测试 App/测试 App.csproj");
|
||||
await addProjectsToSolution(sln, [project]);
|
||||
expect(read(sln)).toContain("测试 App.csproj");
|
||||
await removeProjectFromSolution(sln, project);
|
||||
expect(read(sln)).not.toContain("测试 App.csproj");
|
||||
});
|
||||
|
||||
real("a project that was added raises no warning (relative .. path resolved against the list)", async () => {
|
||||
const sln = solution(format);
|
||||
await addProjectsToSolution(sln, [file("out/Out/Out.csproj"), file("in/In.csproj")]);
|
||||
expect(mocks.notify).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
real("adds several picked projects in one command", async () => {
|
||||
const sln = solution(format);
|
||||
await addProjectsToSolution(sln, [file("A/A.csproj"), file("B/B.csproj")]);
|
||||
expect(read(sln)).toContain("A.csproj");
|
||||
expect(read(sln)).toContain("B.csproj");
|
||||
});
|
||||
|
||||
real("same-named projects from two folders: the CLI keeps the first and a warning names the other", async () => {
|
||||
const sln = solution(format);
|
||||
await addProjectsToSolution(sln, [file("one/Core/Core.csproj"), file("two/Core/Core.csproj")]);
|
||||
// `dotnet sln add` matches by file name and exits 0 with "already contains project".
|
||||
expect(read(sln).match(/Core\.csproj/g)).toHaveLength(1);
|
||||
expect(mocks.notify).toHaveBeenCalledTimes(1);
|
||||
expect(mocks.notify.mock.calls[0]![0]).toMatchObject({
|
||||
level: "warning",
|
||||
body: expect.stringContaining("Core.csproj"),
|
||||
});
|
||||
expect(mocks.reload).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
real("removes a project whose file was deleted from disk", async () => {
|
||||
const sln = solution(format);
|
||||
const project = file("Gone/Gone.csproj");
|
||||
await addProjectsToSolution(sln, [project]);
|
||||
rmSync(join(dir, "Gone"), { recursive: true });
|
||||
await removeProjectFromSolution(sln, project);
|
||||
// The CLI refuses a missing file on some SDKs: either it is gone from the file, or an error was reported.
|
||||
expect(read(sln).includes("Gone.csproj") ? mocks.notify.mock.calls.length : 1).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
real("a project in two solutions is edited in one only", async () => {
|
||||
const a = solution(format, "A");
|
||||
const b = solution(format, "B");
|
||||
const project = file("Shared/Shared.csproj");
|
||||
await addProjectsToSolution(a, [project]);
|
||||
await addProjectsToSolution(b, [project]);
|
||||
await removeProjectFromSolution(a, project);
|
||||
expect(read(a)).not.toContain("Shared.csproj");
|
||||
expect(read(b)).toContain("Shared.csproj");
|
||||
});
|
||||
|
||||
real("reports a CLI failure and refreshes the model after the process exits", async () => {
|
||||
const sln = solution(format);
|
||||
await addProjectsToSolution(sln, [join(dir, "missing/Nope.csproj")]);
|
||||
expect(mocks.notify).toHaveBeenCalledTimes(1);
|
||||
expect(mocks.notify.mock.calls[0]![0]).toMatchObject({
|
||||
level: "error",
|
||||
title: expect.stringContaining("solution"),
|
||||
});
|
||||
expect(mocks.reload).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
real("a read-only solution file fails with a notification", async () => {
|
||||
if (process.platform === "win32" || process.getuid?.() === 0) return;
|
||||
const sln = solution(format);
|
||||
execFileSync("chmod", ["444", sln]);
|
||||
await addProjectsToSolution(sln, [file("A/A.csproj")]);
|
||||
expect(mocks.notify).toHaveBeenCalledTimes(1);
|
||||
expect(mocks.reload).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
real("concurrent edits run one after another and both land", async () => {
|
||||
const sln = solution(format);
|
||||
await Promise.all([
|
||||
addProjectsToSolution(sln, [file("A/A.csproj")]),
|
||||
addProjectsToSolution(sln, [file("B/B.csproj")]),
|
||||
]);
|
||||
expect(read(sln)).toContain("A.csproj");
|
||||
expect(read(sln)).toContain("B.csproj");
|
||||
expect(mocks.reload).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it("no pick means no command", async () => {
|
||||
mocks.pick.mockResolvedValue([]);
|
||||
await addProjectsToSolution("/nowhere/App.sln");
|
||||
expect(mocks.notify).not.toHaveBeenCalled();
|
||||
expect(mocks.reload).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe("project reference edits (real dotnet CLI)", () => {
|
||||
real("adds and removes a reference, also for a multi-targeted project", async () => {
|
||||
const lib = file("Lib/Lib.csproj", csproj().replace("net9.0", "net8.0"));
|
||||
const app = file(
|
||||
"App/App.csproj",
|
||||
csproj().replace(
|
||||
"<TargetFramework>net9.0</TargetFramework>",
|
||||
"<TargetFrameworks>net8.0;net9.0</TargetFrameworks>",
|
||||
),
|
||||
);
|
||||
await addProjectReference(app, lib);
|
||||
expect(read(app)).toContain("ProjectReference");
|
||||
await removeProjectReference(app, lib);
|
||||
expect(read(app)).not.toContain("ProjectReference");
|
||||
expect(mocks.reload).toHaveBeenCalledTimes(2);
|
||||
expect(mocks.notify).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
real("handles spaces and non-ASCII in the referenced path", async () => {
|
||||
const lib = file("库 文件/库 Lib/库 Lib.csproj");
|
||||
const app = file("App/App.csproj");
|
||||
await addProjectReference(app, lib);
|
||||
expect(read(app)).toContain("库 Lib.csproj");
|
||||
});
|
||||
|
||||
real("reports a reference to a missing project", async () => {
|
||||
const app = file("App/App.csproj");
|
||||
await addProjectReference(app, join(dir, "nope/Nope.csproj"));
|
||||
expect(mocks.notify).toHaveBeenCalledTimes(1);
|
||||
expect(mocks.reload).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
real("cancelling a queued edit reports nothing and skips the reload", async () => {
|
||||
const sln = solution("sln");
|
||||
const running = addProjectsToSolution(sln, [file("A/A.csproj")]);
|
||||
cancelDotnetEdit();
|
||||
await running;
|
||||
expect(mocks.notify).not.toHaveBeenCalled();
|
||||
expect(mocks.reload).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe("Project view menu items", () => {
|
||||
const project = (path: string, references: string[] = []) => ({ path, name: path, references }) as never;
|
||||
beforeEach(() => {
|
||||
useDotnet.setState({
|
||||
model: {
|
||||
projects: [project("/s/A/A.csproj", ["/s/B/B.csproj"]), project("/s/B/B.csproj")],
|
||||
solutions: [
|
||||
{ path: "/s/One.sln", projects: ["/s/A/A.csproj"] },
|
||||
{ path: "/s/Two.slnx", projects: ["/s/A/A.csproj"] },
|
||||
],
|
||||
},
|
||||
});
|
||||
});
|
||||
afterEach(() => useDotnet.setState({ model: { projects: [], solutions: [] } }));
|
||||
|
||||
it("a solution offers Add Existing Project", () => {
|
||||
expect(editItems("/s/One.sln")).toContainEqual(
|
||||
expect.objectContaining({ action: "dotnet.solution.addProject", arg: { solution: "/s/One.sln" } }),
|
||||
);
|
||||
});
|
||||
|
||||
it("a project offers add / remove reference and one removal per owning solution", () => {
|
||||
const items = editItems("/s/A/A.csproj");
|
||||
expect(items.filter((i) => "action" in i && i.action === "dotnet.solution.removeProject")).toHaveLength(2);
|
||||
expect(items.some((i) => "submenu" in i)).toBe(true);
|
||||
expect(items).toContainEqual(expect.objectContaining({ action: "dotnet.project.addReference" }));
|
||||
});
|
||||
|
||||
it("a project without references or solutions offers only Add Project Reference", () => {
|
||||
const items = editItems("/s/B/B.csproj");
|
||||
expect(items.some((i) => "submenu" in i)).toBe(false);
|
||||
expect(items.filter((i) => "action" in i)).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,195 @@
|
||||
/**
|
||||
* Solution and project-reference edits from the Project view (#7421): `dotnet sln add|remove`
|
||||
* and `dotnet add|remove reference` through the same trusted, cancellable process host as
|
||||
* Build / Restore / Clean. Edits run one at a time (two writers on one `.sln` would race);
|
||||
* afterwards the workspace reloads so the tree shows the new state, and a CLI failure
|
||||
* surfaces as a notification.
|
||||
*/
|
||||
import { dotnet, dotnetAbsolutePath } from "@/platform/dotnet";
|
||||
import { IpcError } from "@/platform/ipc";
|
||||
import { tx } from "@/platform/i18n";
|
||||
import { choosePaths } from "@/platform/choosePath";
|
||||
import { basename, dirname, useProject } from "@/platform/project";
|
||||
import type { MenuItem } from "@/ui/Menu";
|
||||
import { notifications } from "@/workbench/contributions";
|
||||
import { reloadDotnet, useDotnet } from "./store";
|
||||
import { isDotnetSolutionPath } from "./target";
|
||||
|
||||
let queue: Promise<unknown> = Promise.resolve();
|
||||
/** Edits that are queued or running: Cancel aborts all of them. */
|
||||
const pending = new Set<AbortController>();
|
||||
|
||||
export const cancelDotnetEdit = () => pending.forEach((c) => c.abort());
|
||||
|
||||
/** The CLI arguments of an edit; `solution` and `project` are absolute paths. */
|
||||
export const slnArgs = (op: "add" | "remove", solution: string, projects: string[]) => [
|
||||
"sln",
|
||||
solution,
|
||||
op,
|
||||
...projects,
|
||||
];
|
||||
export const referenceArgs = (op: "add" | "remove", project: string, references: string[]) => [
|
||||
op,
|
||||
project,
|
||||
"reference",
|
||||
...references,
|
||||
];
|
||||
|
||||
/**
|
||||
* `dotnet sln add` exits 0 without adding a project whose file name another project of the
|
||||
* solution already has ("already contains project"); the projects missing from `dotnet sln list`
|
||||
* afterwards are warned about instead of passing as added.
|
||||
*/
|
||||
async function warnIfNotAdded(solution: string, projects: string[], signal: AbortSignal) {
|
||||
let output: string;
|
||||
try {
|
||||
output = await dotnet(["sln", solution, "list"], dirname(solution), signal);
|
||||
} catch {
|
||||
return; // The add itself succeeded; a failing list is not worth a false alarm.
|
||||
}
|
||||
const listed = output
|
||||
.split(/\r?\n/)
|
||||
.filter((line) => /\.(?:cs|fs|vb)proj$/i.test(line.trim()))
|
||||
.map((line) => dotnetAbsolutePath(dirname(solution), line.trim()));
|
||||
const missing = projects.filter((path) => !listed.includes(dotnetAbsolutePath(dirname(solution), path)));
|
||||
const names = missing.map(basename).join(", ");
|
||||
if (missing.length)
|
||||
notifications().notify({
|
||||
level: "warning",
|
||||
title: tx("The project was not added to the solution"),
|
||||
body: tx`The solution already contains a project with the same name as ${names}.`,
|
||||
group: "tools",
|
||||
});
|
||||
}
|
||||
|
||||
/** Runs `args` after the edits queued before it, then reloads the model. */
|
||||
function run(
|
||||
title: string,
|
||||
args: string[],
|
||||
cwd: string,
|
||||
check?: (signal: AbortSignal) => Promise<void>,
|
||||
): Promise<void> {
|
||||
const root = useProject.getState().project?.root;
|
||||
const stillInProject = () => useProject.getState().project?.root === root;
|
||||
const abort = new AbortController();
|
||||
const unsubscribe = useProject.subscribe(() => {
|
||||
if (!stillInProject()) abort.abort();
|
||||
});
|
||||
pending.add(abort);
|
||||
const next = queue
|
||||
.catch(() => {})
|
||||
.then(async () => {
|
||||
try {
|
||||
if (abort.signal.aborted) return;
|
||||
let refresh = false;
|
||||
try {
|
||||
await dotnet(args, cwd, abort.signal);
|
||||
refresh = true;
|
||||
await check?.(abort.signal);
|
||||
} catch (e) {
|
||||
// A CLI process can have written part of a multi-entry edit before failing.
|
||||
// An IPC rejection means the process could not be started.
|
||||
refresh ||= !(e instanceof IpcError);
|
||||
if (!abort.signal.aborted)
|
||||
notifications().notify({ level: "error", title, body: String(e).trim(), group: "tools" });
|
||||
}
|
||||
if (refresh && stillInProject()) await reloadDotnet();
|
||||
} finally {
|
||||
unsubscribe();
|
||||
pending.delete(abort);
|
||||
}
|
||||
});
|
||||
queue = next;
|
||||
return next;
|
||||
}
|
||||
|
||||
const PROJECT_FILTER = [{ name: ".NET project", extensions: ["csproj", "fsproj", "vbproj"] }];
|
||||
|
||||
export async function addProjectsToSolution(solution: string, projects?: string[]) {
|
||||
const root = useProject.getState().project?.root;
|
||||
const picked =
|
||||
projects ??
|
||||
(await choosePaths({
|
||||
directory: false,
|
||||
title: tx("Add Existing Project"),
|
||||
defaultPath: dirname(solution),
|
||||
filters: PROJECT_FILTER,
|
||||
}));
|
||||
if (!picked.length || useProject.getState().project?.root !== root) return;
|
||||
return run(
|
||||
tx("Could not add the project to the solution"),
|
||||
slnArgs("add", solution, picked),
|
||||
dirname(solution),
|
||||
(signal) => warnIfNotAdded(solution, picked, signal),
|
||||
);
|
||||
}
|
||||
|
||||
export function removeProjectFromSolution(solution: string, project: string) {
|
||||
return run(
|
||||
tx("Could not remove the project from the solution"),
|
||||
slnArgs("remove", solution, [project]),
|
||||
dirname(solution),
|
||||
);
|
||||
}
|
||||
|
||||
export async function addProjectReference(project: string, reference?: string) {
|
||||
const root = useProject.getState().project?.root;
|
||||
const picked =
|
||||
reference ??
|
||||
(await choosePaths({
|
||||
directory: false,
|
||||
title: tx("Add Project Reference"),
|
||||
defaultPath: dirname(project),
|
||||
filters: PROJECT_FILTER,
|
||||
}));
|
||||
const list = typeof picked === "string" ? [picked] : picked;
|
||||
if (!list.length || useProject.getState().project?.root !== root) return;
|
||||
return run(tx("Could not add the project reference"), referenceArgs("add", project, list), dirname(project));
|
||||
}
|
||||
|
||||
export function removeProjectReference(project: string, reference: string) {
|
||||
return run(
|
||||
tx("Could not remove the project reference"),
|
||||
referenceArgs("remove", project, [reference]),
|
||||
dirname(project),
|
||||
);
|
||||
}
|
||||
|
||||
/** #7421: the solution / reference edits of a solution or project node. */
|
||||
const solutionName = (path: string) => basename(path).replace(/\.slnx?$/i, "");
|
||||
|
||||
export function editItems(path: string): MenuItem[] {
|
||||
const { model } = useDotnet.getState();
|
||||
if (isDotnetSolutionPath(path))
|
||||
return [
|
||||
{ kind: "separator" },
|
||||
{ kind: "action", action: "dotnet.solution.addProject", arg: { solution: path }, label: "Add Existing Project…" },
|
||||
];
|
||||
const solutions = model.solutions.filter((s) => s.projects.includes(path));
|
||||
const references = model.projects.find((p) => p.path === path)?.references ?? [];
|
||||
return [
|
||||
{ kind: "separator" },
|
||||
{ kind: "action", action: "dotnet.project.addReference", arg: { project: path }, label: "Add Project Reference…" },
|
||||
...(references.length
|
||||
? [
|
||||
{
|
||||
label: "Remove Project Reference",
|
||||
submenu: references.map((reference): MenuItem => ({
|
||||
kind: "action",
|
||||
action: "dotnet.project.removeReference",
|
||||
arg: { project: path, reference },
|
||||
label: basename(reference),
|
||||
verbatim: true,
|
||||
})),
|
||||
} satisfies MenuItem,
|
||||
]
|
||||
: []),
|
||||
...solutions.map((s): MenuItem => ({
|
||||
kind: "action",
|
||||
action: "dotnet.solution.removeProject",
|
||||
arg: { solution: s.path, project: path },
|
||||
label: solutions.length > 1 ? tx`Remove from Solution '${solutionName(s.path)}'` : "Remove from Solution",
|
||||
verbatim: solutions.length > 1,
|
||||
})),
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* Restricted Mode: every edit goes through `dotnet()` → `run_start`, which the backend refuses in an
|
||||
* untrusted project (`crates/ide-host/tests/rpc.rs` asserts that for `run_start`). Here the real
|
||||
* `dotnet()` wrapper meets that refusal: nothing is reloaded, the user gets the error, and no
|
||||
* process or file is involved.
|
||||
*/
|
||||
import { beforeEach, expect, it, vi } from "vitest";
|
||||
|
||||
const mocks = vi.hoisted(() => ({
|
||||
runStart: vi.fn(async () => ({
|
||||
status: "error" as const,
|
||||
error: { kind: "unavailable", message: "Restricted Mode: trust this project to run it" },
|
||||
})),
|
||||
notify: vi.fn(),
|
||||
reload: vi.fn(async () => {}),
|
||||
}));
|
||||
vi.mock("@/platform/ipc", async (original) => {
|
||||
const real = await original<typeof import("@/platform/ipc")>();
|
||||
return {
|
||||
...real,
|
||||
commands: { ...real.commands, runStart: mocks.runStart },
|
||||
ideEventsReady: async () => {},
|
||||
onIdeEvent: () => () => {},
|
||||
};
|
||||
});
|
||||
vi.mock("@tauri-apps/api/core", async (original) => ({
|
||||
...(await original<typeof import("@tauri-apps/api/core")>()),
|
||||
Channel: class {
|
||||
onmessage: unknown;
|
||||
},
|
||||
}));
|
||||
vi.mock("./store", async (orig) => ({ ...(await orig<typeof import("./store")>()), reloadDotnet: mocks.reload }));
|
||||
|
||||
import { provideNotificationService } from "@/workbench/contributions";
|
||||
import { addProjectReference, addProjectsToSolution, removeProjectFromSolution, removeProjectReference } from "./edit";
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
provideNotificationService({ notify: mocks.notify });
|
||||
});
|
||||
|
||||
it.each([
|
||||
["add project to solution", () => addProjectsToSolution("/s/App.sln", ["/s/A/A.csproj"])],
|
||||
["remove project from solution", () => removeProjectFromSolution("/s/App.sln", "/s/A/A.csproj")],
|
||||
["add project reference", () => addProjectReference("/s/A/A.csproj", "/s/B/B.csproj")],
|
||||
["remove project reference", () => removeProjectReference("/s/A/A.csproj", "/s/B/B.csproj")],
|
||||
])("%s is refused in an untrusted project", async (_name, edit) => {
|
||||
await edit();
|
||||
expect(mocks.runStart).toHaveBeenCalledTimes(1);
|
||||
expect(mocks.notify).toHaveBeenCalledTimes(1);
|
||||
expect(mocks.notify.mock.calls[0]![0]).toMatchObject({
|
||||
level: "error",
|
||||
body: expect.stringContaining("Restricted Mode"),
|
||||
});
|
||||
expect(mocks.reload).not.toHaveBeenCalled();
|
||||
});
|
||||
@@ -15,6 +15,14 @@ import {
|
||||
searchPackages,
|
||||
selectDotnet,
|
||||
} from "./store";
|
||||
import {
|
||||
addProjectReference,
|
||||
addProjectsToSolution,
|
||||
cancelDotnetEdit,
|
||||
editItems,
|
||||
removeProjectFromSolution,
|
||||
removeProjectReference,
|
||||
} from "./edit";
|
||||
import { isDotnetProjectPath, isDotnetSolutionPath } from "./target";
|
||||
import { activateTree } from "./tree";
|
||||
|
||||
@@ -40,7 +48,56 @@ export function activate() {
|
||||
when: "projectOpen",
|
||||
run: () => reloadDotnet(),
|
||||
},
|
||||
{ id: "dotnet.cancel", title: "Cancel .NET Operation", category: "Build", run: () => cancelDotnet() },
|
||||
{
|
||||
id: "dotnet.cancel",
|
||||
title: "Cancel .NET Operation",
|
||||
category: "Build",
|
||||
run: () => {
|
||||
cancelDotnet();
|
||||
cancelDotnetEdit();
|
||||
},
|
||||
},
|
||||
// #7421: solution and project-reference edits; the Project view menu passes the paths.
|
||||
{
|
||||
id: "dotnet.solution.addProject",
|
||||
title: "Add Existing Project to Solution",
|
||||
category: "Build",
|
||||
hidden: true,
|
||||
run: ({ arg }) => {
|
||||
const a = arg as { solution: string; projects?: string[] };
|
||||
return addProjectsToSolution(a.solution, a.projects);
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "dotnet.solution.removeProject",
|
||||
title: "Remove Project from Solution",
|
||||
category: "Build",
|
||||
hidden: true,
|
||||
run: ({ arg }) => {
|
||||
const a = arg as { solution: string; project: string };
|
||||
return removeProjectFromSolution(a.solution, a.project);
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "dotnet.project.addReference",
|
||||
title: "Add Project Reference",
|
||||
category: "Build",
|
||||
hidden: true,
|
||||
run: ({ arg }) => {
|
||||
const a = arg as { project: string; reference?: string };
|
||||
return addProjectReference(a.project, a.reference);
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "dotnet.project.removeReference",
|
||||
title: "Remove Project Reference",
|
||||
category: "Build",
|
||||
hidden: true,
|
||||
run: ({ arg }) => {
|
||||
const a = arg as { project: string; reference: string };
|
||||
return removeProjectReference(a.project, a.reference);
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "dotnet.select",
|
||||
title: "Select .NET Project",
|
||||
@@ -127,6 +184,7 @@ export function activate() {
|
||||
{ kind: "action", action: "dotnet.build", arg: path },
|
||||
{ kind: "action", action: "dotnet.restore", arg: path },
|
||||
{ kind: "action", action: "dotnet.clean", arg: path },
|
||||
...editItems(path),
|
||||
];
|
||||
},
|
||||
}),
|
||||
|
||||
@@ -99,6 +99,8 @@ describe("the .NET solution tree", () => {
|
||||
["App", "/repo/src/App/App.csproj", true],
|
||||
["App.Tests", "/repo/tests/App.Tests/App.Tests.csproj", true],
|
||||
]);
|
||||
// The group node's context menu is its `.sln`'s (#7421).
|
||||
expect(solution.menuPath).toBe("/repo/App.sln");
|
||||
});
|
||||
|
||||
it("shows the solution label through the tx template", async () => {
|
||||
|
||||
@@ -104,6 +104,7 @@ export function treeRoots(
|
||||
id: solutionId(solution.path),
|
||||
label: tx`Solution '${solutionName(solution.path)}'`,
|
||||
icon: ICON,
|
||||
menuPath: solution.path,
|
||||
beforeProject: true,
|
||||
children: solution.projects.map(leaf),
|
||||
});
|
||||
|
||||
@@ -72,12 +72,16 @@ describe("standalone .NET tool window removal", () => {
|
||||
"dotnet.restore /repo/src/App/App.csproj",
|
||||
"dotnet.clean /repo/src/App/App.csproj",
|
||||
"separator",
|
||||
"dotnet.project.addReference [object Object]",
|
||||
"separator",
|
||||
]);
|
||||
expect(actions("/repo/Demo.sln")).toEqual([
|
||||
"dotnet.build /repo/Demo.sln",
|
||||
"dotnet.restore /repo/Demo.sln",
|
||||
"dotnet.clean /repo/Demo.sln",
|
||||
"separator",
|
||||
"dotnet.solution.addProject [object Object]",
|
||||
"separator",
|
||||
]);
|
||||
expect(actions("/repo/src/App/Program.cs")).toEqual([]);
|
||||
});
|
||||
|
||||
@@ -73,6 +73,24 @@ it("keeps markers on their lines while typing and hides them when the entry goes
|
||||
await vi.waitFor(() => expect(button()).toBeNull());
|
||||
});
|
||||
|
||||
it("leaves a kept entry's markers where the edits moved them when the store notifies again", async () => {
|
||||
const { entry } = setup();
|
||||
await vi.waitFor(() => expect(button()).not.toBeNull());
|
||||
view!.dispatch({ changes: { from: 0, insert: "\n" } });
|
||||
const dispatch = vi.spyOn(view!, "dispatch");
|
||||
// The changed file is reindexing: the store keeps its entry and notifies for other paths (#7422).
|
||||
// Placing that entry again would put its markers back on their old lines.
|
||||
usePluginMarkers.setState({
|
||||
entries: new Map([
|
||||
[entry.path, entry],
|
||||
["/p/Other.xml", { ...entry, path: "/p/Other.xml" }],
|
||||
]),
|
||||
});
|
||||
await new Promise((r) => setTimeout(r, 0));
|
||||
expect(dispatch).not.toHaveBeenCalled();
|
||||
expect(button()).not.toBeNull();
|
||||
});
|
||||
|
||||
it("merges a line's targets and offers a chooser for several", async () => {
|
||||
const { entry, target } = setup();
|
||||
const other = { ...target, path: "/p/Other.java" };
|
||||
|
||||
@@ -110,7 +110,9 @@ export function indexedMarkers(path: string): Extension {
|
||||
INDEXED_MARKERS_THEME,
|
||||
ViewPlugin.fromClass(
|
||||
class {
|
||||
last: FileMarkers | undefined;
|
||||
/** The entry the field shows (null: none yet, or icons or settings changed). The field maps
|
||||
* its markers through edits, so the same entry is never placed again on an edited text. */
|
||||
applied: FileMarkers | undefined | null = null;
|
||||
queued = false;
|
||||
disposed = false;
|
||||
generation = 0;
|
||||
@@ -121,13 +123,13 @@ export function indexedMarkers(path: string): Extension {
|
||||
constructor(readonly view: EditorView) {
|
||||
this.off = usePluginMarkers.subscribe(() => this.schedule());
|
||||
this.offIcons = onMarkerIconsChanged(() => {
|
||||
this.last = undefined;
|
||||
this.applied = null;
|
||||
this.schedule();
|
||||
});
|
||||
this.unwatch = watchPluginMarkers(path);
|
||||
this.prefs = useProject.subscribe((s, prev) => {
|
||||
if (s.settings !== prev.settings) {
|
||||
this.last = undefined;
|
||||
this.applied = null;
|
||||
this.schedule();
|
||||
}
|
||||
});
|
||||
@@ -136,8 +138,10 @@ export function indexedMarkers(path: string): Extension {
|
||||
update(update: ViewUpdate) {
|
||||
const appearanceChanged =
|
||||
update.startState.field(localAppearanceField, false) !== update.state.field(localAppearanceField, false);
|
||||
if (appearanceChanged) this.schedule();
|
||||
if (update.docChanged || appearanceChanged) this.last = undefined;
|
||||
if (appearanceChanged) {
|
||||
this.applied = null;
|
||||
this.schedule();
|
||||
}
|
||||
}
|
||||
schedule() {
|
||||
if (this.queued || this.disposed) return;
|
||||
@@ -149,12 +153,12 @@ export function indexedMarkers(path: string): Extension {
|
||||
}
|
||||
refresh() {
|
||||
const entry = usePluginMarkers.getState().entries.get(path);
|
||||
if (entry && entry === this.last) return;
|
||||
this.last = entry;
|
||||
if (entry === this.applied) return;
|
||||
const doc = this.view.state.doc;
|
||||
const generation = ++this.generation;
|
||||
void resolveIcons(entry).then((icons) => {
|
||||
if (this.disposed || generation !== this.generation || this.view.state.doc !== doc) return;
|
||||
this.applied = entry;
|
||||
this.view.dispatch({ effects: setMarkers.of(markersOf(this.view, entry, icons)) });
|
||||
});
|
||||
}
|
||||
|
||||
@@ -55,7 +55,8 @@ it("withdraws old interactive markers on reload and does not refresh on idle sta
|
||||
expect(mock.markers).toHaveBeenCalledTimes(calls);
|
||||
mock.markers.mockResolvedValue({ status: "ok", data: [] });
|
||||
mock.event!({ type: "documentIndexesChanged" });
|
||||
expect(view.dom.querySelector(".cm-openidea-iconArea .cm-plugin-mapping-button")).toBeNull();
|
||||
// Shown until the new markers arrive: an empty area would collapse and shift the code (#7422).
|
||||
expect(view.dom.querySelector(".cm-openidea-iconArea .cm-plugin-mapping-button")).not.toBeNull();
|
||||
await vi.advanceTimersByTimeAsync(450);
|
||||
expect(view.dom.querySelector(".cm-openidea-iconArea .cm-plugin-mapping-button")).toBeNull();
|
||||
view.destroy();
|
||||
|
||||
@@ -128,8 +128,9 @@ class MarkersPlugin {
|
||||
) {
|
||||
const offBackend = pluginsBackend().onEvent((event) => {
|
||||
if (event.type !== "documentIndexesChanged") return;
|
||||
// The shown markers stay (mapped through edits) until the new ones arrive: clearing them
|
||||
// collapsed the icon area after every edit and shifted the code sideways (#7422).
|
||||
this.generation++;
|
||||
this.view.dispatch({ effects: setMarkers.of([]) });
|
||||
this.schedule();
|
||||
});
|
||||
const offIcons = onMarkerIconsChanged(() => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { afterEach, expect, it, vi } from "vitest";
|
||||
import { watchPluginMarkers, usePluginMarkers, invalidatePluginMarkers } from "./markerStore";
|
||||
import { watchPluginMarkers, usePluginMarkers, invalidatePluginMarkers, settlePluginMarkers } from "./markerStore";
|
||||
import { invalidateNavigationProviders } from "@/editor/api";
|
||||
const mock = vi.hoisted(() => vi.fn());
|
||||
vi.mock("@/platform/ipc", async (original) => ({
|
||||
@@ -34,20 +34,39 @@ it("discards in-flight results after the project/provider epoch changes", async
|
||||
await vi.advanceTimersByTimeAsync(250);
|
||||
expect(usePluginMarkers.getState().entries.size).toBe(0);
|
||||
});
|
||||
it("invalidates both changed files and markers targeting them", () => {
|
||||
it("keeps the markers of changed files, and markers targeting them, until their reindex settles", async () => {
|
||||
vi.useFakeTimers();
|
||||
const range = { start: { line: 0, col: 0 }, end: { line: 0, col: 1 } };
|
||||
const entry = {
|
||||
path: "/p/A.xml",
|
||||
version: 1,
|
||||
markers: [{ range, targets: [{ path: "/p/A.java", range }], pluginId: "p", icon: null }],
|
||||
};
|
||||
mock.mockResolvedValue({ status: "ok", data: [entry] });
|
||||
off.push(watchPluginMarkers("/p/A.xml"));
|
||||
await vi.advanceTimersByTimeAsync(250);
|
||||
expect(usePluginMarkers.getState().entries.get("/p/A.xml")).toEqual(entry);
|
||||
|
||||
invalidatePluginMarkers(["/p/A.java"]);
|
||||
// While reindexing, the host has no current markers for it (#7422).
|
||||
mock.mockResolvedValue({ status: "ok", data: [] });
|
||||
invalidateNavigationProviders();
|
||||
await vi.advanceTimersByTimeAsync(250);
|
||||
expect(usePluginMarkers.getState().entries.get("/p/A.xml")).toEqual(entry);
|
||||
|
||||
settlePluginMarkers(["/p/A.java"]);
|
||||
invalidateNavigationProviders();
|
||||
await vi.advanceTimersByTimeAsync(250);
|
||||
expect(usePluginMarkers.getState().entries.size).toBe(0);
|
||||
});
|
||||
|
||||
it("drops every marker at once when the providers are reset", () => {
|
||||
const range = { start: { line: 0, col: 0 }, end: { line: 0, col: 1 } };
|
||||
usePluginMarkers.setState({
|
||||
entries: new Map([
|
||||
[
|
||||
"/p/A.xml",
|
||||
{
|
||||
path: "/p/A.xml",
|
||||
version: 1,
|
||||
markers: [{ range, targets: [{ path: "/p/A.java", range }], pluginId: "p", icon: null }],
|
||||
},
|
||||
],
|
||||
["/p/A.xml", { path: "/p/A.xml", version: 1, markers: [{ range, targets: [], pluginId: "p", icon: null }] }],
|
||||
]),
|
||||
});
|
||||
invalidatePluginMarkers(["/p/A.java"]);
|
||||
invalidatePluginMarkers();
|
||||
expect(usePluginMarkers.getState().entries.size).toBe(0);
|
||||
});
|
||||
@@ -12,6 +12,8 @@ let running = false;
|
||||
let session = 0;
|
||||
let again = false;
|
||||
let off: (() => void) | undefined;
|
||||
/** Paths whose markers are kept, mapped through edits, until their reindex settles. */
|
||||
const stale = new Set<string>();
|
||||
function schedule() {
|
||||
again = true;
|
||||
if (!timer && !running)
|
||||
@@ -34,6 +36,7 @@ async function refresh() {
|
||||
if (epoch !== navigationEpoch() || current !== session) return;
|
||||
for (const result of results) {
|
||||
if (!visible.has(result.path)) continue;
|
||||
stale.delete(result.path);
|
||||
const previous = entries.get(result.path);
|
||||
entries.set(
|
||||
result.path,
|
||||
@@ -41,6 +44,13 @@ async function refresh() {
|
||||
);
|
||||
}
|
||||
}
|
||||
// A changed file has no markers until it is indexed again: keep showing the ones it had,
|
||||
// so the icon area doesn't collapse and shift the code after every edit (#7422).
|
||||
const shown = usePluginMarkers.getState().entries;
|
||||
for (const path of stale) {
|
||||
const kept = shown.get(path);
|
||||
if (kept && visible.has(path) && !entries.has(path)) entries.set(path, kept);
|
||||
}
|
||||
if (epoch === navigationEpoch() && current === session) usePluginMarkers.setState({ entries });
|
||||
} catch {
|
||||
// Plugin navigation may be unavailable during project close or reload.
|
||||
@@ -69,15 +79,35 @@ export function watchPluginMarkers(path: string): () => void {
|
||||
clearTimeout(timer);
|
||||
timer = undefined;
|
||||
again = false;
|
||||
stale.clear();
|
||||
usePluginMarkers.setState({ entries: new Map() });
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Changed `paths` are being indexed again: their markers, and markers targeting them, stay until
|
||||
* the next results replace them or {@link settlePluginMarkers} drops them. No `paths`: the
|
||||
* providers changed, so every marker goes now.
|
||||
*/
|
||||
export function invalidatePluginMarkers(paths?: readonly string[]) {
|
||||
const entries = new Map(usePluginMarkers.getState().entries);
|
||||
const entries = usePluginMarkers.getState().entries;
|
||||
if (!paths) {
|
||||
stale.clear();
|
||||
if (entries.size) usePluginMarkers.setState({ entries: new Map() });
|
||||
return;
|
||||
}
|
||||
for (const [path, entry] of entries) {
|
||||
if (!paths || paths.includes(path) || entry.markers.some((m) => m.targets.some((t) => paths.includes(t.path))))
|
||||
entries.delete(path);
|
||||
if (paths.includes(path) || entry.markers.some((m) => m.targets.some((t) => paths.includes(t.path))))
|
||||
stale.add(path);
|
||||
}
|
||||
}
|
||||
|
||||
/** The reindex of `paths` finished (or failed): the next results say which of their markers remain. */
|
||||
export function settlePluginMarkers(paths: readonly string[]) {
|
||||
const entries = usePluginMarkers.getState().entries;
|
||||
for (const path of [...stale]) {
|
||||
const entry = entries.get(path);
|
||||
if (paths.includes(path) || !entry || entry.markers.some((m) => m.targets.some((t) => paths.includes(t.path))))
|
||||
stale.delete(path);
|
||||
}
|
||||
usePluginMarkers.setState({ entries });
|
||||
}
|
||||
@@ -15,7 +15,7 @@ import { useProject } from "@/platform/project";
|
||||
import { notifications, registerDocumentIndexSync } from "@/workbench/contributions";
|
||||
import { tx } from "@/platform/i18n";
|
||||
import { pluginsBackend } from "./backend";
|
||||
import { invalidatePluginMarkers } from "./markerStore";
|
||||
import { invalidatePluginMarkers, settlePluginMarkers } from "./markerStore";
|
||||
import { usePlugins } from "./store";
|
||||
|
||||
export function startPluginNavigation(): () => void {
|
||||
@@ -103,6 +103,7 @@ export function startPluginNavigation(): () => void {
|
||||
failed.delete(p);
|
||||
if (!pending.has(p)) dirty.delete(p);
|
||||
});
|
||||
settlePluginMarkers(paths.filter((p) => !pending.has(p)));
|
||||
notify();
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -114,6 +115,7 @@ export function startPluginNavigation(): () => void {
|
||||
dirty.delete(p);
|
||||
failed.add(p);
|
||||
});
|
||||
settlePluginMarkers(paths);
|
||||
report(error);
|
||||
}
|
||||
} finally {
|
||||
|
||||
@@ -35,6 +35,7 @@ import {
|
||||
OWNS_FILE_DROP,
|
||||
getFileDecoration,
|
||||
opensExternally,
|
||||
menuGroupItems,
|
||||
prepareMenuGroups,
|
||||
useFileDecoration,
|
||||
useFileDecorations,
|
||||
@@ -750,6 +751,13 @@ export function ProjectView() {
|
||||
}
|
||||
const nodes = [...sel].map((k) => m.byKey.get(k)).filter((n): n is ProjectNode => !!n && !n.placeholder);
|
||||
const target = nodes.length ? nodes : [node];
|
||||
const menuPath = target.length === 1 ? target[0]!.menuPath : undefined;
|
||||
if (menuPath) {
|
||||
// A solution group: only the contributed items of its `.sln` (Build, Add Existing Project…).
|
||||
const items = menuGroupItems("projectView", { paths: [menuPath], dirs: [false] });
|
||||
if (items.length) showContextMenu(e, items);
|
||||
return;
|
||||
}
|
||||
if (target.every((n) => n.group) || target.some((n) => n.member)) return;
|
||||
// Contributed groups and collapsed library folders may read the filesystem first (bounded wait).
|
||||
const at = { x: e.clientX, y: e.clientY };
|
||||
|
||||
@@ -61,6 +61,8 @@ export interface ProjectNode {
|
||||
detail?: string;
|
||||
/** A node grouping other nodes, without a folder of its own ("External Libraries"). */
|
||||
group?: boolean;
|
||||
/** A group node: the file whose context-menu groups its menu shows (a solution's `.sln`). */
|
||||
menuPath?: string;
|
||||
/** Library sources: no new / rename / move / delete. */
|
||||
readOnly?: boolean;
|
||||
/** A declaration of the file itself ("Show Members"); navigating lands on its `selection_range`. */
|
||||
@@ -293,6 +295,8 @@ export interface ExtraRoot {
|
||||
file?: boolean;
|
||||
children?: readonly ExtraRoot[];
|
||||
detail?: string;
|
||||
/** A group node: the file whose context-menu groups the node shows. */
|
||||
menuPath?: string;
|
||||
readOnly?: boolean;
|
||||
/** Listed above the project folder (IDEA's module group of the build). */
|
||||
beforeProject?: boolean;
|
||||
@@ -456,6 +460,7 @@ export function withExtraRoots(
|
||||
icon: extra.icon,
|
||||
detail: extra.detail,
|
||||
group: true,
|
||||
menuPath: extra.menuPath,
|
||||
readOnly: true,
|
||||
};
|
||||
out.byKey.set(key, node);
|
||||
|
||||
@@ -735,6 +735,16 @@
|
||||
.formHeader > .field {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
/* WebKitGTK shifts the tracks of a scrolling subgrid as the dialog resizes (#7469): on Linux the
|
||||
header and the options share a fixed label column instead. */
|
||||
html[data-os="linux"] .configFields {
|
||||
--run-config-columns: 150px minmax(0, 1fr);
|
||||
grid-template-columns: var(--run-config-columns);
|
||||
}
|
||||
html[data-os="linux"] .formSettings {
|
||||
grid-template-columns: var(--run-config-columns);
|
||||
column-gap: var(--space-3);
|
||||
}
|
||||
.editFormTomcat {
|
||||
overflow: hidden;
|
||||
}
|
||||
@@ -1174,6 +1184,9 @@
|
||||
}
|
||||
|
||||
@container run-config-content (max-width: 360px) {
|
||||
html[data-os="linux"] .configFields {
|
||||
--run-config-columns: minmax(0, 1fr);
|
||||
}
|
||||
.configFields,
|
||||
.editForm > .field {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
|
||||
@@ -6,6 +6,7 @@ import { executeAction } from "@/platform/actions";
|
||||
import { CLEAR_COLOR, _setSchemeSource, resolvedAttribute } from "@/platform/colorScheme";
|
||||
import { setLocale } from "@/platform/i18n";
|
||||
import { useProject } from "@/platform/project";
|
||||
import { usePlugins } from "@/features/plugins/store";
|
||||
import { DEFAULT_SETTINGS } from "../model/schema";
|
||||
import { languagePageId } from "../pages/editor/colorSchemeMeta";
|
||||
import { openSettings, stage, stagedValue, useSettingsDialog } from "../model/staging";
|
||||
@@ -308,6 +309,39 @@ describe("scheme attribute state", () => {
|
||||
expect(value("colorOverrides")).toEqual({ dark: { staticSymbol: { italic: false } } });
|
||||
});
|
||||
|
||||
it("shows a followed plugin theme's comment style and saves clearing it (#7453)", () => {
|
||||
_setSchemeSource(readFileSync("src/styles/tokens.css", "utf8"));
|
||||
const theme = {
|
||||
id: "one",
|
||||
name: "Plugin One",
|
||||
kind: "dark" as const,
|
||||
tokens: { "--syn-comment": "#5c6370", "--syn-comment-style": "italic" },
|
||||
};
|
||||
try {
|
||||
act(() => {
|
||||
usePlugins.setState({ activeTheme: { pluginId: "p", theme } });
|
||||
stage("editor.colorScheme", "global", "editor.colorScheme", "theme-default");
|
||||
});
|
||||
expect(screen.getByText("Follows the IDE theme: currently Plugin One.")).toBeInTheDocument();
|
||||
const preview = screen.getByLabelText("Color scheme preview");
|
||||
expect(preview.style.getPropertyValue("--syn-comment-style")).toBe("italic");
|
||||
act(() => fireEvent.click(preview.querySelector('span[style*="--syn-comment-italic"]')!));
|
||||
expect(screen.getByRole("textbox", { name: "Foreground hex" })).toHaveValue("#5c6370");
|
||||
const italic = screen.getByRole("checkbox", { name: "Italic" });
|
||||
expect(italic).toBeChecked();
|
||||
act(() => fireEvent.click(italic));
|
||||
expect(value("colorOverrides")).toEqual({ dark: { lineComment: { italic: false } } });
|
||||
expect(preview.style.getPropertyValue("--syn-comment-style")).toBe("normal");
|
||||
|
||||
// An explicitly chosen scheme replaces the plugin theme's colours, in the editor and here.
|
||||
act(() => stage("editor.colorScheme", "global", "editor.colorScheme", "dark"));
|
||||
expect(preview.style.getPropertyValue("--syn-comment")).not.toBe("#5c6370");
|
||||
} finally {
|
||||
usePlugins.setState({ activeTheme: null });
|
||||
_setSchemeSource("");
|
||||
}
|
||||
});
|
||||
|
||||
it("shows the red-green colours the editor uses and the setting behind them (#3851)", () => {
|
||||
_setSchemeSource(readFileSync("src/styles/tokens.css", "utf8"));
|
||||
try {
|
||||
|
||||
@@ -52,6 +52,7 @@ import { useContributions } from "@/workbench/contributions";
|
||||
import { parseIcls, SchemeParseError, importScheme, deleteScheme, exportIcls } from "@/platform/icls";
|
||||
import { tx, txPart, useTx } from "@/platform/i18n";
|
||||
import { selectPage } from "../../model/staging";
|
||||
import { usePlugins } from "@/features/plugins/store";
|
||||
|
||||
type Overrides = Record<string, Record<string, TextAttributesOverride>>;
|
||||
|
||||
@@ -134,9 +135,10 @@ function previewVars(
|
||||
customs: CustomColorSchemes,
|
||||
language?: string,
|
||||
redGreen = false,
|
||||
themeTokens?: Record<string, string>,
|
||||
): CSSProperties {
|
||||
const vars: Record<string, string> = {};
|
||||
const tokens = resolvedSchemeTokens(id, customs, redGreen, o);
|
||||
const tokens = resolvedSchemeTokens(id, customs, redGreen, o, themeTokens);
|
||||
for (const [k, v] of tokens)
|
||||
if (
|
||||
k.startsWith("--syn-") ||
|
||||
@@ -1779,6 +1781,10 @@ export function ColorSchemePage({
|
||||
crossPageReveal = null;
|
||||
});
|
||||
const id = effectiveScheme(scheme, undefined, customs);
|
||||
// A scheme that follows the IDE theme shows a plugin theme's colours, as the editor does (`schemeCss`).
|
||||
const pluginTheme = usePlugins((s) => s.activeTheme);
|
||||
const followed = pluginTheme && id !== scheme ? pluginTheme.theme : undefined;
|
||||
const themeTokens = followed?.tokens;
|
||||
const mine = overrides?.[id];
|
||||
/** Keys of every group containing an overridden attribute, so the blue marks the path to the root. */
|
||||
const modifiedKeys = useMemo(() => {
|
||||
@@ -1797,25 +1803,25 @@ export function ColorSchemePage({
|
||||
const attr = ATTRIBUTES.find((a) => a.id === selected);
|
||||
const language = attr?.language;
|
||||
const inherited = useMemo(
|
||||
() => (attr ? resolvedAttribute(id, attr.id, customs, redGreen) : {}),
|
||||
[id, attr, customs, redGreen],
|
||||
() => (attr ? resolvedAttribute(id, attr.id, customs, redGreen, themeTokens) : {}),
|
||||
[id, attr, customs, redGreen, themeTokens],
|
||||
);
|
||||
const vars = useMemo(() => {
|
||||
const next = {
|
||||
...previewVars(id, mine, customs, language, redGreen),
|
||||
...previewVars(id, mine, customs, language, redGreen, themeTokens),
|
||||
...fontWeightVars(weight, boldFontWeight),
|
||||
} as CSSProperties & Record<string, string>;
|
||||
// Console preview sits on the console background, not the editor surface.
|
||||
if (scopes[0] === "Console Colors" && next["--bg-console"]) next["--bg-editor"] = next["--bg-console"];
|
||||
return next;
|
||||
}, [id, mine, customs, language, weight, boldFontWeight, scopes, redGreen]);
|
||||
}, [id, mine, customs, language, weight, boldFontWeight, scopes, redGreen, themeTokens]);
|
||||
const baseVars = useMemo(
|
||||
() =>
|
||||
({
|
||||
...previewVars(id, mine, customs, undefined, redGreen),
|
||||
...previewVars(id, mine, customs, undefined, redGreen, themeTokens),
|
||||
...fontWeightVars(weight, boldFontWeight),
|
||||
}) as CSSProperties,
|
||||
[id, mine, customs, weight, boldFontWeight, redGreen],
|
||||
[id, mine, customs, weight, boldFontWeight, redGreen, themeTokens],
|
||||
);
|
||||
const update = (attrId: string, v: TextAttributesOverride | undefined) => {
|
||||
const next: Overrides = { ...(overrides ?? {}) };
|
||||
@@ -1967,7 +1973,9 @@ export function ColorSchemePage({
|
||||
</div>
|
||||
)}
|
||||
{scheme === "theme-default" && (
|
||||
<div className={styles.note}>{tx`Follows the IDE theme: currently ${txPart(schemeName)}.`}</div>
|
||||
<div
|
||||
className={styles.note}
|
||||
>{tx`Follows the IDE theme: currently ${txPart(followed?.name ?? schemeName)}.`}</div>
|
||||
)}
|
||||
{redGreen && (id === "dark" || id === "light") && (
|
||||
<div className={styles.note}>
|
||||
|
||||
@@ -9,7 +9,17 @@ import {
|
||||
} from "@/workbench/contributions";
|
||||
import { useTasks } from "@/workbench/tasks";
|
||||
import { MemoryToolsBackend, sampleTools, setToolsBackend } from "../backend";
|
||||
import { cancelInstall, installTool, refreshTools, uninstallTool, useTools } from "../store";
|
||||
import {
|
||||
cancelInstall,
|
||||
installTool,
|
||||
loadToolUpdates,
|
||||
publishToolUpdates,
|
||||
refreshTools,
|
||||
uninstallTool,
|
||||
UPDATES_EVERY_MS,
|
||||
useTools,
|
||||
} from "../store";
|
||||
import { useToolUpdates } from "@/workbench/contributions";
|
||||
import { filterLanguages, groupByLanguage, LanguageServersPage } from "../LanguageServersPage";
|
||||
import { installMissingServerPrompts, installServerWarningPrompts, missingKey, promptInstall } from "../missing";
|
||||
import { resetTestForm, stagedFor, TestSettingsForm } from "./settingsForm";
|
||||
@@ -41,6 +51,39 @@ beforeEach(() => {
|
||||
|
||||
afterEach(() => setToolsBackend(null));
|
||||
|
||||
describe("tool updates (#7365)", () => {
|
||||
afterEach(() => localStorage.removeItem("openidea.tools.updates.v1"));
|
||||
|
||||
it("looks once a day, shows the last lookup meanwhile, and publishes it to the workbench", async () => {
|
||||
let stop = publishToolUpdates();
|
||||
backend.available = [{ name: "rust-analyzer", current: "1.0", latest: "1.1" }];
|
||||
const updates = vi.spyOn(backend, "updates");
|
||||
await loadToolUpdates(1_000);
|
||||
expect(updates).toHaveBeenCalledTimes(1);
|
||||
expect(useToolUpdates.getState().latest).toEqual({ "rust-analyzer": "1.1" });
|
||||
|
||||
// Another window starting within the day: the stored result, no lookup.
|
||||
stop();
|
||||
useTools.setState({ updates: {} });
|
||||
useToolUpdates.setState({ latest: {} });
|
||||
stop = publishToolUpdates();
|
||||
const at = JSON.parse(localStorage.getItem("openidea.tools.updates.v1")!).at as number;
|
||||
await loadToolUpdates(at + UPDATES_EVERY_MS - 1);
|
||||
expect(updates).toHaveBeenCalledTimes(1);
|
||||
expect(useToolUpdates.getState().latest).toEqual({ "rust-analyzer": "1.1" });
|
||||
|
||||
// Installing the update drops it, from the stored copy too.
|
||||
await refreshTools();
|
||||
await installTool("rust-analyzer");
|
||||
expect(useToolUpdates.getState().latest).toEqual({});
|
||||
expect(JSON.parse(localStorage.getItem("openidea.tools.updates.v1")!).updates).toEqual([]);
|
||||
|
||||
await loadToolUpdates(at + UPDATES_EVERY_MS);
|
||||
expect(updates).toHaveBeenCalledTimes(2);
|
||||
stop();
|
||||
});
|
||||
});
|
||||
|
||||
describe("tools store", () => {
|
||||
it("installs, streams progress, restarts servers and notifies", async () => {
|
||||
await refreshTools();
|
||||
|
||||
@@ -19,7 +19,23 @@ import { installCssModulesHint } from "./cssModules";
|
||||
import { installXcodeBspHint } from "./xcodeBsp";
|
||||
import { installStyledTemplatesHint } from "./styledTemplates";
|
||||
import { activateSettingsPages } from "./settingsPages";
|
||||
import { installTool, refreshTools, SETTINGS_PAGE_ID, toolByName, useTools } from "./store";
|
||||
import {
|
||||
installTool,
|
||||
loadToolUpdates,
|
||||
publishToolUpdates,
|
||||
refreshTools,
|
||||
SETTINGS_PAGE_ID,
|
||||
toolByName,
|
||||
useTools,
|
||||
} from "./store";
|
||||
|
||||
/** After startup has settled: a lookup goes to every tool's registry. */
|
||||
const UPDATES_DELAY_MS = 60_000;
|
||||
|
||||
function lookForToolUpdatesLater(): () => void {
|
||||
const timer = setTimeout(() => void loadToolUpdates(), UPDATES_DELAY_MS);
|
||||
return () => clearTimeout(timer);
|
||||
}
|
||||
|
||||
export function activate(): () => void {
|
||||
const disposers = [
|
||||
@@ -80,6 +96,8 @@ export function activate(): () => void {
|
||||
},
|
||||
},
|
||||
]),
|
||||
publishToolUpdates(),
|
||||
lookForToolUpdatesLater(),
|
||||
installMissingServerPrompts(),
|
||||
installServerReadyExpiry(),
|
||||
installServerWarningPrompts(),
|
||||
|
||||
@@ -3,7 +3,7 @@ import { create } from "zustand";
|
||||
import type { RequestId, ToolInfo, ToolUpdate } from "@/bindings";
|
||||
import { executeAction } from "@/platform/actions";
|
||||
import { isCancelled, nextRequestId } from "@/platform/ipc";
|
||||
import { notifications } from "@/workbench/contributions";
|
||||
import { notifications, useToolUpdates } from "@/workbench/contributions";
|
||||
import { cancelTask, queueTask, upsertTask, useTasks } from "@/workbench/tasks";
|
||||
import { toolsBackend } from "./backend";
|
||||
import { tx } from "@/platform/i18n";
|
||||
@@ -69,13 +69,67 @@ export function refreshTools(): Promise<void> {
|
||||
|
||||
let checkingUpdates: Promise<void> | null = null;
|
||||
|
||||
/** The last lookup's result, shared by the windows: `{ at, updates }`. */
|
||||
const UPDATES_KEY = "openidea.tools.updates.v1";
|
||||
/** How long a lookup stands before the next window start looks again (#7365). */
|
||||
export const UPDATES_EVERY_MS = 24 * 60 * 60 * 1000;
|
||||
|
||||
interface CachedUpdates {
|
||||
at: number;
|
||||
updates: ToolUpdate[];
|
||||
}
|
||||
|
||||
function cachedUpdates(): CachedUpdates | null {
|
||||
try {
|
||||
const cached = JSON.parse(localStorage.getItem(UPDATES_KEY) ?? "null") as CachedUpdates | null;
|
||||
return cached && typeof cached.at === "number" && Array.isArray(cached.updates) ? cached : null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function saveUpdates(at: number, updates: Readonly<Record<string, ToolUpdate>>) {
|
||||
try {
|
||||
localStorage.setItem(UPDATES_KEY, JSON.stringify({ at, updates: Object.values(updates) }));
|
||||
} catch {
|
||||
// Storage full or unavailable: the next start looks again.
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the updates the last lookup found, and looks again when it is older than a day: the
|
||||
* status bar's Language Servers says which servers have one without opening Settings.
|
||||
*/
|
||||
export function loadToolUpdates(now = Date.now()): Promise<void> {
|
||||
const cached = cachedUpdates();
|
||||
if (cached) useTools.setState({ updates: Object.fromEntries(cached.updates.map((u) => [u.name, u])) });
|
||||
return cached && now - cached.at < UPDATES_EVERY_MS ? Promise.resolve() : checkToolUpdates();
|
||||
}
|
||||
|
||||
/** Publishes the found updates to the workbench, and keeps the shared copy without installed ones. */
|
||||
export function publishToolUpdates(): () => void {
|
||||
const publish = (updates: Readonly<Record<string, ToolUpdate>>) =>
|
||||
useToolUpdates.setState({
|
||||
latest: Object.fromEntries(Object.values(updates).map((u) => [u.name, u.latest])),
|
||||
});
|
||||
publish(useTools.getState().updates);
|
||||
return useTools.subscribe((s, prev) => {
|
||||
if (s.updates === prev.updates) return;
|
||||
publish(s.updates);
|
||||
const cached = cachedUpdates();
|
||||
if (cached) saveUpdates(cached.at, s.updates);
|
||||
});
|
||||
}
|
||||
|
||||
/** Looks for newer versions of the tools the IDE installed; offline, none are shown. */
|
||||
export function checkToolUpdates(): Promise<void> {
|
||||
checkingUpdates ??= (async () => {
|
||||
useTools.setState({ checkingUpdates: true });
|
||||
try {
|
||||
const found = await toolsBackend().updates(nextRequestId());
|
||||
useTools.setState({ updates: Object.fromEntries(found.map((u) => [u.name, u])) });
|
||||
const updates = Object.fromEntries(found.map((u) => [u.name, u]));
|
||||
saveUpdates(Date.now(), updates);
|
||||
useTools.setState({ updates });
|
||||
} catch {
|
||||
// A failed lookup leaves the last result.
|
||||
} finally {
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
_setSchemeSource,
|
||||
overrideDeclarations,
|
||||
resolvedAttribute,
|
||||
resolvedSchemeTokens,
|
||||
schemeAfterThemeChange,
|
||||
schemeCss,
|
||||
schemeTokens,
|
||||
@@ -394,6 +395,21 @@ describe("color schemes", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("resolves a followed plugin theme's tokens under the user's overrides", () => {
|
||||
// A plugin theme with italic comments: the attribute shows italic, so clearing it saves an override.
|
||||
const theme = { "--syn-comment": "#5c6370", "--syn-comment-style": "italic", "--syn-doc-comment": "#98c379" };
|
||||
expect(resolvedAttribute("dark", "lineComment", {}, false, theme)).toMatchObject({
|
||||
foreground: "#5c6370",
|
||||
italic: true,
|
||||
});
|
||||
expect(resolvedAttribute("dark", "go.lineComment", {}, false, theme)).toMatchObject({ italic: true });
|
||||
expect(resolvedAttribute("dark", "docComment", {}, false, theme).foreground).toBe("#98c379");
|
||||
const tokens = resolvedSchemeTokens("dark", {}, false, { lineComment: { italic: false } }, theme);
|
||||
expect(tokens.get("--syn-comment")).toBe("#5c6370");
|
||||
expect(tokens.get("--syn-comment-style")).toBe("normal");
|
||||
expect(tokens.get("--syn-comment-italic")).toBe("normal");
|
||||
});
|
||||
|
||||
it("resolves package references from the editor foreground and emits their overrides", () => {
|
||||
for (const theme of ["light", "dark", "dark-hc"] as const) {
|
||||
expect(resolvedAttribute(theme, "packageReference").foreground).toBe(schemeTokens(theme).get("--fg-editor"));
|
||||
|
||||
@@ -879,17 +879,24 @@ export function listSchemes(customs: CustomColorSchemes = {}) {
|
||||
* A scheme's tokens with a custom scheme's attributes and then `overrides` applied; tokens that
|
||||
* tokens.css derives from an overridden one follow it unless they are overridden themselves. With
|
||||
* `redGreen`, a built-in scheme's red-green variant; a custom scheme keeps its parent's own colours.
|
||||
* `themeTokens` are those of a plugin theme the scheme follows, over the scheme's and under overrides.
|
||||
*/
|
||||
export function resolvedSchemeTokens(
|
||||
id: string,
|
||||
customs: CustomColorSchemes = {},
|
||||
redGreen = false,
|
||||
overrides?: Record<string, TextAttributesOverride>,
|
||||
themeTokens?: Record<string, string>,
|
||||
): Vars {
|
||||
const custom = customSchemes(customs)[id];
|
||||
const builtin = isBuiltinTheme(id);
|
||||
const base = builtin ? id : (custom?.parent ?? "light");
|
||||
const fixed: Vars = new Map([...overrideDeclarations(custom?.attributes), ...overrideDeclarations(overrides)]);
|
||||
// A plugin theme the scheme follows paints over the built-in one, as its stylesheet does in the editor.
|
||||
const fixed: Vars = new Map([
|
||||
...Object.entries(themeTokens ?? {}),
|
||||
...overrideDeclarations(custom?.attributes),
|
||||
...overrideDeclarations(overrides),
|
||||
]);
|
||||
return new Map(schemeTokens(base, source, redGreen && builtin, fixed));
|
||||
}
|
||||
|
||||
@@ -929,12 +936,13 @@ export function resolvedAttribute(
|
||||
attrId: string,
|
||||
customs: CustomColorSchemes = {},
|
||||
redGreen = false,
|
||||
themeTokens?: Record<string, string>,
|
||||
): TextAttributesOverride {
|
||||
const attr = ATTRIBUTES.find((a) => a.id === attrId);
|
||||
if (!attr) return {};
|
||||
const custom = customSchemes(customs)[id];
|
||||
const own = custom?.attributes[attr.id];
|
||||
const vars = resolvedSchemeTokens(id, customs, redGreen);
|
||||
const vars = resolvedSchemeTokens(id, customs, redGreen, undefined, themeTokens);
|
||||
if (attr.language) {
|
||||
const scoped = overrideDeclarations(custom?.attributes, attr.language);
|
||||
for (const [key, value] of scoped) vars.set(key, value);
|
||||
|
||||
@@ -92,7 +92,7 @@ export function jsonOutput<T = Record<string, unknown>>(text: string): T {
|
||||
return JSON.parse(text.slice(start, end + 1));
|
||||
}
|
||||
|
||||
function absolute(base: string, relative: string): string {
|
||||
export function dotnetAbsolutePath(base: string, relative: string): string {
|
||||
const path = relative.replace(/\\/g, "/");
|
||||
if (/^(?:[A-Za-z]:\/|\/)/.test(path)) return path;
|
||||
const parts = base.replace(/\\/g, "/").split("/");
|
||||
@@ -109,7 +109,7 @@ export function solutionPaths(text: string, xml: boolean, dir: string): string[]
|
||||
(p) => p.getAttribute("Path") || "",
|
||||
)
|
||||
: Array.from(text.matchAll(/^Project\([^\r\n]+?=\s*"[^"]*",\s*"([^"]+)"/gm), (m) => m[1]!);
|
||||
return [...new Set(names.filter((p) => /\.(?:cs|fs|vb)proj$/i.test(p)).map((p) => absolute(dir, p)))];
|
||||
return [...new Set(names.filter((p) => /\.(?:cs|fs|vb)proj$/i.test(p)).map((p) => dotnetAbsolutePath(dir, p)))];
|
||||
}
|
||||
|
||||
export function globalRunner(text: string): DotnetRunner {
|
||||
@@ -185,7 +185,7 @@ export async function evaluateProject(
|
||||
name: p.MSBuildProjectName || path.split("/").at(-1) || path,
|
||||
frameworks: (p.TargetFrameworks || p.TargetFramework || "").split(";").filter(Boolean),
|
||||
configurations: (p.Configurations || "Debug;Release").split(";"),
|
||||
references: (data.Items?.ProjectReference ?? []).map((x) => absolute(dirname(path), x.Identity!)),
|
||||
references: (data.Items?.ProjectReference ?? []).map((x) => dotnetAbsolutePath(dirname(path), x.Identity!)),
|
||||
packages,
|
||||
test:
|
||||
p.IsTestProject === "true" ||
|
||||
@@ -274,7 +274,7 @@ export async function prepareDotnetTest(config: RunConfig): Promise<RunConfig> {
|
||||
const root = useProject.getState().project?.root;
|
||||
if (!root || !config.params?.project) return config;
|
||||
let project = await evaluateProject(
|
||||
absolute(root, config.params.project),
|
||||
dotnetAbsolutePath(root, config.params.project),
|
||||
config.params.configuration,
|
||||
config.params.framework,
|
||||
);
|
||||
|
||||
@@ -5084,6 +5084,7 @@
|
||||
"Stdio MCP Process": "Stdio MCP Process",
|
||||
"Lifecycle Hook File": "Lifecycle Hook File",
|
||||
"Plugin Marketplaces": "Plugin Marketplaces",
|
||||
"Marketplace": "Marketplace",
|
||||
"Marketplace scope": "Marketplace scope",
|
||||
"Marketplace source": "Marketplace source",
|
||||
"No marketplaces registered yet. Add a GitHub owner/repo or local marketplace folder above.": "No marketplaces registered yet. Add a GitHub owner/repo or local marketplace folder above.",
|
||||
|
||||
@@ -9663,5 +9663,20 @@
|
||||
"unsupported manifest": "不支援的清單格式",
|
||||
"Plugins installed by each agent harness, grouped by harness and scope. Changes update the harness's own configuration without staging or converting plugin files.": "依代理與作用域顯示各代理原生安裝的外掛。變更會寫入目標代理自己的設定,不會暫存或轉換外掛檔案。",
|
||||
"Replace the existing plugin directory": "取代既有的外掛目錄",
|
||||
"Copilot enables plugins for one repository only when they come from a marketplace.": "Copilot 僅能為單一儲存庫啟用來自外掛市場的外掛。"
|
||||
"Copilot enables plugins for one repository only when they come from a marketplace.": "Copilot 僅能為單一儲存庫啟用來自外掛市場的外掛。",
|
||||
"Add Existing Project": "加入現有專案",
|
||||
"Could not add the project to the solution": "無法將專案加入方案",
|
||||
"Could not remove the project from the solution": "無法從方案中移除專案",
|
||||
"Add Project Reference": "加入專案參考",
|
||||
"Could not add the project reference": "無法加入專案參考",
|
||||
"Could not remove the project reference": "無法移除專案參考",
|
||||
"Add Existing Project…": "加入現有專案…",
|
||||
"Add Project Reference…": "加入專案參考…",
|
||||
"Remove Project Reference": "移除專案參考",
|
||||
"Remove from Solution": "從方案中移除",
|
||||
"Add Existing Project to Solution": "將現有專案加入方案",
|
||||
"Remove Project from Solution": "從方案中移除專案",
|
||||
"Remove from Solution '{name}'": "從方案 '{name}' 中移除",
|
||||
"The project was not added to the solution": "專案未加入方案",
|
||||
"The solution already contains a project with the same name as {names}.": "方案中已有與 {names} 同名的專案。"
|
||||
}
|
||||
@@ -11985,5 +11985,21 @@
|
||||
"Product Name:": "产品名称:",
|
||||
"Use letters, digits, spaces, hyphens and underscores, starting with a letter, digit or underscore": "只能使用字母、数字、空格、连字符和下划线,并以字母、数字或下划线开头",
|
||||
"iOS": "iOS",
|
||||
"macOS": "macOS"
|
||||
"macOS": "macOS",
|
||||
"Add Existing Project": "添加现有项目",
|
||||
"Could not add the project to the solution": "无法将项目添加到解决方案",
|
||||
"Could not remove the project from the solution": "无法从解决方案中移除项目",
|
||||
"Add Project Reference": "添加项目引用",
|
||||
"Could not add the project reference": "无法添加项目引用",
|
||||
"Could not remove the project reference": "无法移除项目引用",
|
||||
"Add Existing Project…": "添加现有项目…",
|
||||
"Add Project Reference…": "添加项目引用…",
|
||||
"Remove Project Reference": "移除项目引用",
|
||||
"Remove from Solution": "从解决方案中移除",
|
||||
"Add Existing Project to Solution": "将现有项目添加到解决方案",
|
||||
"Remove Project from Solution": "从解决方案中移除项目",
|
||||
"Remove from Solution '{name}'": "从解决方案 '{name}' 中移除",
|
||||
"The project was not added to the solution": "项目未添加到解决方案",
|
||||
"The solution already contains a project with the same name as {names}.": "解决方案中已有与 {names} 同名的项目。",
|
||||
"Language server updates are available": "语言服务器有可用更新"
|
||||
}
|
||||
@@ -242,6 +242,12 @@ export interface EditorDocumentLifecycle {
|
||||
/** Bumped by `notifyTabTitlesChanged`; tab labels whose `title(input)` changed re-render. */
|
||||
export const useEditorTabTitles = create<{ revision: number }>(() => ({ revision: 0 }));
|
||||
|
||||
/**
|
||||
* The newer version of each installed language server or debugger that has one, by tool name:
|
||||
* published by features/tools, shown where servers are listed (the status bar's Language Servers).
|
||||
*/
|
||||
export const useToolUpdates = create<{ latest: Readonly<Record<string, string>> }>(() => ({ latest: {} }));
|
||||
|
||||
/** An editor kind's tab title may have changed outside the tab state (e.g. a renamed agent task). */
|
||||
export function notifyTabTitlesChanged() {
|
||||
useEditorTabTitles.setState((s) => ({ revision: s.revision + 1 }));
|
||||
@@ -1530,6 +1536,8 @@ export interface ProjectViewRootEntry {
|
||||
children?: readonly ProjectViewRootEntry[];
|
||||
/** Grey text after the label ("library root"). */
|
||||
detail?: string;
|
||||
/** A group node: the file whose Project view context-menu groups the node shows (a solution's `.sln`). */
|
||||
menuPath?: string;
|
||||
/** Library sources: shown read-only (no new / rename / move / delete). */
|
||||
readOnly?: boolean;
|
||||
}
|
||||
|
||||
Reference in new issue
Заблокувати користувача