Skip to content

refactor: pass resolved config into createCodeLens to avoid redundant getConfiguration calls#285

Merged
askpt merged 2 commits into
mainfrom
repo-assist/improve-codelens-config-passthrough-20260505-e3c83a9f55762562
May 12, 2026
Merged

refactor: pass resolved config into createCodeLens to avoid redundant getConfiguration calls#285
askpt merged 2 commits into
mainfrom
repo-assist/improve-codelens-config-passthrough-20260505-e3c83a9f55762562

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot commented May 5, 2026

🤖 This PR was created by Repo Assist, an automated AI assistant.

Summary

When rendering CodeLens items for a document with many functions, createCodeLens was calling ConfigurationManager.getComplexityStatus(complexity, document.uri) — which in turn calls vscode.workspace.getConfiguration() — once per function. The configuration was already fully resolved once per document in provideCodeLenses, making each per-function re-fetch redundant.

Changes

File Change
src/configuration.ts getComplexityStatus now accepts vscode.Uri | CodeMetricsConfig — existing callers with a URI are unaffected; callers with a pre-fetched config skip the re-fetch
src/providers/codeLensProvider.ts createCodeLens now receives the already-resolved CodeMetricsConfig from createCodeLenses and passes it directly

Rationale

vscode.workspace.getConfiguration() is synchronous but non-trivial — it performs a workspace lookup on every call. For a file with 20 functions all above the threshold, this PR eliminates 20 redundant lookups per provideCodeLenses call. The improvement is most noticeable on large files or when the user scrolls frequently.

The getComplexityStatus signature change is backward-compatible: the parameter type widens from vscode.Uri | undefined to vscode.Uri | CodeMetricsConfig | undefined, and the runtime check (instanceof vscode.Uri) preserves existing behaviour for all current callers.

Test Status

  • npm run compile — no errors
  • npm run lint — no warnings
  • ⚠️ npm test (vscode-test) — requires VS Code download; not available in this sandboxed environment (known infrastructure limitation)

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • releaseassets.githubusercontent.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "releaseassets.githubusercontent.com"

See Network Configuration for more information.

Generated by 🌈 Repo Assist, see workflow run. Learn more.

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@fc4ab36dedc44e2a1cdc195cecce262f06c81230

… getConfiguration calls

When rendering CodeLens items for a document with many functions, each call
to createCodeLens previously triggered a fresh vscode.workspace.getConfiguration()
lookup via getComplexityStatus(complexity, document.uri). The config was already
resolved once per document in provideCodeLenses, so the per-function re-fetch
was wasteful.

Changes:
- ConfigurationManager.getComplexityStatus now accepts either a vscode.Uri (existing
  callers unchanged) or an already-fetched CodeMetricsConfig, avoiding the re-fetch.
- createCodeLens now receives the resolved CodeMetricsConfig from createCodeLenses
  and passes it directly to getComplexityStatus.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@askpt askpt changed the title [Repo Assist] refactor: pass resolved config into createCodeLens to avoid redundant getConfiguration calls refactor: pass resolved config into createCodeLens to avoid redundant getConfiguration calls May 6, 2026
@askpt askpt marked this pull request as ready for review May 12, 2026 13:20
@askpt askpt self-requested a review as a code owner May 12, 2026 13:20
Copilot AI review requested due to automatic review settings May 12, 2026 13:20
@askpt askpt enabled auto-merge (squash) May 12, 2026 13:20
@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Codecov Report

❌ Patch coverage is 0% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.24%. Comparing base (8c31641) to head (406da88).

Files with missing lines Patch % Lines
src/configuration.ts 0.00% 6 Missing ⚠️
src/providers/codeLensProvider.ts 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #285      +/-   ##
==========================================
- Coverage   66.34%   66.24%   -0.11%     
==========================================
  Files           9        9              
  Lines        2600     2604       +4     
  Branches      224      224              
==========================================
  Hits         1725     1725              
- Misses        874      878       +4     
  Partials        1        1              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@askpt askpt merged commit cbdbe51 into main May 12, 2026
10 of 11 checks passed
@askpt askpt deleted the repo-assist/improve-codelens-config-passthrough-20260505-e3c83a9f55762562 branch May 12, 2026 13:21
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors CodeLens rendering to avoid repeated configuration lookups by passing a document-resolved CodeMetricsConfig down into createCodeLens, eliminating per-function vscode.workspace.getConfiguration() calls during provideCodeLenses.

Changes:

  • Updated ConfigurationManager.getComplexityStatus to accept either a vscode.Uri or an already-resolved CodeMetricsConfig.
  • Passed the resolved CodeMetricsConfig from provideCodeLensescreateCodeLensescreateCodeLens, and used it when determining complexity status.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/configuration.ts Allows getComplexityStatus to reuse a pre-fetched config (or fall back to resolving from a URI).
src/providers/codeLensProvider.ts Threads resolved config through CodeLens creation to avoid redundant configuration fetches per function.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants