Skip to content

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

Draft
github-actions[bot] wants to merge 1 commit intomainfrom
repo-assist/improve-codelens-config-passthrough-20260505-e3c83a9f55762562
Draft

refactor: pass resolved config into createCodeLens to avoid redundant getConfiguration calls#285
github-actions[bot] wants to merge 1 commit intomainfrom
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
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.

0 participants