Skip to content

feat(query-editor): Priority Level support#3063

Open
bk201- wants to merge 11 commits into
mainfrom
dev/dshilov/feat-priority-level
Open

feat(query-editor): Priority Level support#3063
bk201- wants to merge 11 commits into
mainfrom
dev/dshilov/feat-priority-level

Conversation

@bk201-
Copy link
Copy Markdown
Contributor

@bk201- bk201- commented May 21, 2026

What's in this PR

1. Query Editor — Priority Level support (main feature)

Adds Cosmos DB Priority-based execution support to the Query Editor.

  • New Priority Level submenu inside the Run button, with High / Low radio options.
  • Submenu is shown only when the connected account has priority-based execution enabled at the ARM resource level (isPriorityLevelEnabled capability) and disabled for the local emulator.
  • The selected level is persisted per account; on first open the picker is seeded from the previously-saved value, with the existing in-session choice preserved against late-arriving capability fetches.
  • The header is wired through tRPC (queryEditorRouter.runQuery) into the SDK's request options, and intentionally not sent for emulator connections (where the header is meaningless).

Touched files:

  • src/panels/trpc/routers/queryEditorRouter.ts
  • src/webviews/cosmosdb/QueryEditor/QueryPanel/RunQueryButton.tsx
  • src/webviews/cosmosdb/QueryEditor/state/QueryEditorContextProvider.tsx

Also fixed a pre-existing UI bug in the Run-button menu: when both Throughput Bucket and Priority Level submenus were visible, two <MenuDivider />s were rendered back-to-back. Now a single divider is shown when at least one of the config submenus is visible.

2. Webview cold-open performance

Opening a webview panel in dev mode previously took ~5 s before content appeared. A DevTools trace pinned the cost to two issues:

  • ~1.6 s — Vite dev server cold-transforming ~230 source modules on demand as separate HTTP requests (waterfall).
  • ~2.4 s — V8 evaluating a single 16.7 MB pre-bundled dep chunk that merged @griffel/core, stylis, rtl-css-js, @emotion/hash, Fluent UI runtime, etc.

Fixes applied:

  • src/webviews/WebviewRegistry.ts — entries are now () => import(...) factories. Each view (Document, MigrationAssistant, QueryEditor) is dynamically imported, so opening one panel no longer pays the cost of loading the other two. In prod each view becomes its own Rollup chunk — e.g. opening the Document panel no longer downloads Monaco.
  • src/webviews/index.tsxrender() awaits the dynamic import before mounting React.
  • vite.config.views.mjs — added server.warmup for src/webviews/** and packages/*/src/** so the dev server pre-transforms files at startup instead of on first request.
  • vite.config.views.mjs — added optimizeDeps.include for @griffel/core, @griffel/react, stylis, rtl-css-js, @emotion/hash, @fluentui/react-components, @fluentui/react-icons so Rolldown emits a separate dep pre-bundle entry for each instead of merging them into one monolithic shared chunk that V8 has to parse sequentially on the main thread.

3. Initial loader spinner

src/panels/BaseTab.ts — added a CSS-only loader (spinner + localized "Loading…" label) rendered inside #root directly in the HTML template. It appears instantly when the panel opens — before any module is fetched or React hydrates — and is automatically replaced when createRoot().render() mounts the React tree.

Accessibility:

  • role="status" + aria-live="polite" on the container so screen readers announce it.
  • aria-hidden="true" on the rotating ring (decorative).
  • Uses VS Code theme variables (--vscode-foreground, --vscode-progressBar-background, --vscode-font-family, …) so it matches the active theme.
  • Honors prefers-reduced-motion.

4. Maintenance

npm run lint-fix autofix pass on 5 unrelated files (dropped redundant return await and unused eslint-disable directives), followed by npm run prettier-fix.

Fixes: #3007

bk201- added 5 commits May 21, 2026 10:06
Introduces request PriorityLevel selection in the Query Editor's Run button menu and propagates it through the tRPC layer down to the Cosmos client. Adds AzureResourceMetadata to centralize Azure control-plane metadata access (subscription, resource group, database account) with deep-readonly typing. Disables Throughput Bucket and Priority Level submenus when connected to the Cosmos DB emulator.
- Add resolveEffectivePriorityLevel helper that picks the per-request priority: user choice wins; otherwise fall back to Low for non-Azure connections (workspace-attached / connection-string), undefined for Azure-backed (SDK uses High default).
- QuerySession passes the resolved priority via FeedOptions so the header travels only with the data-plane query, not with metadata calls.
- DocumentSession applies the same fallback to all five item operations (create, replace, delete, read with _rid query fallback, bulk delete).
- queryEditorRouter exposes getCapabilities { isEmulator, isPriorityLevelEnabled, defaultPriorityLevel } gated on databaseAccount.enablePriorityBasedExecution; removes the dedicated isEmulator mutation.
- RunQueryButton hides the Priority Level submenu unless the account has the ARM flag set, disables it on the emulator, seeds the picker from defaultPriorityLevel or Low, and forwards the choice in runQuery payload.
- Drop-in fixes from working tree: a11y role/output cleanups in MigrationAssistant and GenerateQueryInput, await/void cleanups in extension.ts.
@bk201- bk201- requested a review from a team as a code owner May 21, 2026 15:05
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 21, 2026

🎉 Build Summary

🔗 Source

📦 Package Information

🧪 Test Results

  • Unit Tests: ✅ success
  • Integration Tests: ✅ success

✅ Build Status

All checks completed successfully!

bk201- added 5 commits May 22, 2026 09:39
Views bundle:
- Explicit manualChunks splits node_modules into stable named chunks
  (fluentui, griffel, react, monaco-editor, react-data-grid, vendor).
  Before, Rolldown used arbitrary source filenames like
  'ToolbarOverflowButton-*.js' for shared chunks, which made caching
  unreliable across releases and bundle reports unreadable.
- MigrationAssistant no longer pulls react-data-grid or the Fluent UI
  shared chunk; Document and QueryEditor get cacheable vendor chunks
  across releases.

Extension bundle:
- manualChunks names pure-static vendor groups: azure-cosmos,
  azure-identity (+msal), vscode-azext, tslib. main.mjs shrinks from
  2.53 MB to 1.58 MB and the bundle report is now readable.
- @azure/arm-cosmosdb is now eagerly imported (used by virtually every
  Cosmos DB code path); marked as named static chunk 'azure-arm-cosmosdb'.
- @azure/arm-postgresql{,-flexible} stay dynamic (PG-only). Three
  ineffective `await import('../utils/azureClients')` wrappers were
  converted to static imports because azureClients.ts is already
  statically imported by 5 other files; the actual lazy boundary is
  the inner `await import('@azure/arm-postgresql*')` inside the
  factory functions.
- Deliberately NO manualChunks rule for @azure/arm-postgresql* or
  @azure/core-*: they share code with the static graph through a lazy
  boundary, and forcing names there folds shared core code into a
  dynamic chunk that main.mjs then must import statically, defeating
  the lazy load.
…selection

- Remove `;` from autosuggest trigger characters in both Monaco and
  VSCode completion providers. The widget popping up while the user is
  still finishing the current statement was distracting; the widget
  still opens on the subsequent newline (`\n`) which is the start of
  the next query in multi-query documents.
- Align VSCode provider trigger set with Monaco: add `\n` so users see
  SELECT proposed on a fresh line without needing Ctrl+Space.
- QueryMonaco editor: set suggest.selectionMode: 'whenQuickSuggestion'
  so the suggest widget no longer auto-highlights its first item when
  opened by a trigger character (most notably `\n`) or by manual
  invoke. A second Enter on an empty line now inserts a newline
  instead of accidentally committing the first suggestion (e.g. AND).
  Auto-highlight still works when the widget is opened by typing
  letters (quick suggestion), where the highlighted match is the
  expected UX.
- Update the Monaco provider trigger-character unit test accordingly.
# Conflicts:
#	l10n/bundle.l10n.json
#	src/panels/trpc/routers/queryEditorRouter.ts
#	src/webviews/cosmosdb/QueryEditor/QueryPanel/GenerateQueryInput.tsx
#	src/webviews/cosmosdb/QueryEditor/state/QueryEditorContextProvider.tsx
armClient?: CosmosDBManagementClient;
resourceGroup?: string;
databaseAccount?: DatabaseAccountGetResults;
arm?: AzureResourceMetadata;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I would choose a more explicit name like azureResourceMetadata to avoid confusion with ARM (Azure resource manager)

>
{state.assessmentProgress}
</Text>
<output aria-live="polite">
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's great to fix it, but next time, let's keep the change separate.

Comment on lines +18 to +20
cosmosDbDocument: () => import('./cosmosdb/Document/Document').then((m) => m.Document),
cosmosDbMigration: () => import('./cosmosdb/Migration/MigrationAssistant').then((m) => m.MigrationAssistant),
cosmosDbQuery: () => import('./cosmosdb/QueryEditor/QueryEditor').then((m) => m.QueryEditor),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable Priority-based execution for queries run from the VS Code extension when the account feature is enabled

2 participants