perf(oxlint/lsp): avoid computing diagnostics for non invoked code actions requests#20080
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
There was a problem hiding this comment.
Pull request overview
This PR optimizes the oxlint LSP server by avoiding unnecessary linting when code action requests are triggered automatically (e.g., on cursor move or file open) rather than explicitly invoked by the user. Previously, get_code_actions_for_uri would always run the linter if no cached actions existed; now it only does so when trigger_kind is INVOKED.
Changes:
- Modified
get_code_actions_for_urito accept atrigger_kindparameter, only running linting on cache miss when the action is explicitly invoked. - Updated both callers (
execute_commandandget_code_actions_or_commands) to pass the appropriate trigger kind. - Added two new tests and a fixture file to cover the default and invoked trigger kind behaviors.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
apps/oxlint/src/lsp/server_linter.rs |
Adds trigger_kind parameter to get_code_actions_for_uri, gates linting on INVOKED, updates callers, renames existing test, and adds new tests. |
apps/oxlint/fixtures/lsp/code_action/trigger-kind-invoked.js |
New fixture with debugger; content for testing invoked trigger kind code actions. |
Merge activity
|
…tions requests (#20080) https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#codeActionTriggerKind > /** * Code actions were explicitly requested by the user or by an extension. */ export const Invoked: 1 = 1; /** * Code actions were requested automatically. * * This typically happens when current selection in a file changes, but can * also be triggered when file content changes. */ export const Automatic: 2 = 2; --- > ## Pull request overview > This PR optimizes the oxlint LSP server by avoiding unnecessary linting when code action requests are triggered automatically (e.g., on cursor move or file open) rather than explicitly invoked by the user. Previously, `get_code_actions_for_uri` would always run the linter if no cached actions existed; now it only does so when `trigger_kind` is `INVOKED`. @nrayburn-tech When your code action from file explorer does not work anymore, you can blame this PR 😅 VSCode sends "automatic" for most of the time, only when opening the code action pop over it will send "invoked". At this time we already should have diagnostics because. Most triggers of code actions are diagnostics.
2704405 to
42aff15
Compare
# Oxlint ### 🚀 Features - 04a5ce0 oxlint: Support `vite.config.ts` `.lint` field (#20214) (leaysgur) - 1735215 linter: Implement `react/no-clone-element` rule. (#20129) (connorshea) - 68e6f6f linter: Implement `react/no-react-children` rule. (#20104) (connorshea) - fe3b32e linter/plugins: Add `oxlint-plugin-eslint` package (#20009) (overlookmotel) ### 🐛 Bug Fixes - 05f6a09 linter/no-inline-comments: Deserialize rule options with serde (#20207) (camc314) - c7eb09d linter/default-case: Deserialize rule options with serde (#20206) (camc314) - f85e16c linter/plugins: Fix types for visitor compilation (#20203) (overlookmotel) - 44e24e0 linter/exhaustive-deps: Ignore type-only typeof deps (#20201) (camc314) - 0b04998 linter/no-fallthrough: Deserialize rule options with serde (#20192) (camc314) - a1031cb linter/new-cap: Deserialize rule options with serde (#20161) (camc314) - ad27fd6 linter: Add help messages to import plugin diagnostics (#20158) (John Costa) - 1340307 linter/plugins: Ensure `after` hooks always run (#20167) (overlookmotel) - c4812ec linter/plugins: Reset visitor compilation state if error during compilation (#20166) (overlookmotel) - 887eecc linter/plugins: Add license notice to `oxlint-plugin-eslint` package (#20164) (overlookmotel) - e1713a4 linter/plugins: Include common chunks in `oxlint-plugin-eslint` package (#20163) (overlookmotel) - a9acb2b linter: Check `globals` entry for `no-undef`, only check es2026 globals for `no-extend-native` and `no-constant-binary-expression` (#20089) (Sysix) - 5559f0d linter/no-unused-vars: `reportUsedIgnorePattern` should not report used rest siblings (#20108) (Don Isaac) - de7c0e2 linter/plugins: Correct error message for `markVariableAsUsed` (#20152) (overlookmotel) ### ⚡ Performance - 3a86427 linter/plugins: Pre-populate cache of `EnterExit` objects at startup (#20194) (overlookmotel) - d243391 linter/plugins: Replace arrays with `Uint8Array`s (#20190) (overlookmotel) - 8742f8b linter/plugins: Pre-populate cache of `VisitProp` objects (#20189) (overlookmotel) - 3061acb linter/plugins: Pre-populate cache of `EnterExit` objects (#20187) (overlookmotel) - c73912b linter/plugins: Free visit functions earlier (#20186) (overlookmotel) - d9f8ff4 linter/plugins: Faster reset of visitor state (#20185) (overlookmotel) - 42aff15 oxlint/lsp: Avoid computing diagnostics for non invoked code actions requests (#20080) (Sysix) ### 📚 Documentation - a080650 linter/plugins: Fix documentation of visitor compilation (#20202) (overlookmotel) - 542a04a linter: Add a link to the cyclomatic complexity Wikipedia article in `eslint/complexity` (#20174) (connorshea) # Oxfmt ### 🚀 Features - 95943aa oxfmt: Support `vite.config.*` `.fmt` field (#20197) (leaysgur) - 172fc07 oxfmt: .js/.ts config file support (#20135) (leaysgur) ### 🐛 Bug Fixes - e483569 oxfmt: Avoid double-escaping in css-in-js (#20211) (leaysgur) Co-authored-by: leaysgur <6259812+leaysgur@users.noreply.github.com>

https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#codeActionTriggerKind
@nrayburn-tech When your code action from file explorer does not work anymore, you can blame this PR 😅
VSCode sends "automatic" for most of the time, only when opening the code action pop over it will send "invoked". At this time we already should have diagnostics because. Most triggers of code actions are diagnostics.