Skip to content

refactor: extract PanelBase for webview panels#64

Open
CompN3rd wants to merge 5 commits into
mainfrom
perf/panel-base
Open

refactor: extract PanelBase for webview panels#64
CompN3rd wants to merge 5 commits into
mainfrom
perf/panel-base

Conversation

@CompN3rd
Copy link
Copy Markdown
Owner

Changes

PanelBase (new)

  • Abstract base class in \src/views/panelBase.ts\ handling webview panel creation, \onDidDispose, message listener registration via \onMessage(), and \dispose()\
  • Removes duplicate lifecycle boilerplate across all three details panels

Migrated panels

  • PrDetailsPanel — ~25 lines removed
  • WorkItemDetailsPanel — ~30 lines removed
  • PipelineRunDetailsPanel — ~25 lines removed

Not migrated

  • PlanningPanel left as-is (different lifecycle pattern — map keyed by kind, not composite ID)

Verification


  • pm run compile\ — all TypeScript checks pass

Marc Kassubeck and others added 2 commits May 20, 2026 22:18
Extract reusable TtlCache<T> class to src/utils/ttlCache.ts. Add 5-minute TTL cache to AdoClient.getWorkItemTypes to avoid redundant API calls when querying work item types for the same project within the cache window.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Create forEachScope<T>() in async.ts that combines resolveProjectScopes + mapWithConcurrencyLimit into a single reusable pattern returning { scopes, items }.

Migrate workItemProvider, pipelinesProvider, pullRequestProvider, and planningProviders to use the helper, removing the duplicate resolveProjectScopes + mapParallelLimit boilerplate and the MAX_CONCURRENT_SCOPE_REQUESTS constants from each file.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Copy link
Copy Markdown

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

Refactors VS Code webview “details” panels to share common lifecycle/setup logic via a new PanelBase, and reduces duplicated multi-scope loading boilerplate in several tree providers. Also adds a small TTL cache to avoid repeatedly fetching work item types for the same org/project.

Changes:

  • Introduced PanelBase to centralize webview panel creation, message wiring, and disposal for details panels.
  • Migrated PR / Work Item / Pipeline Run details panels to extend PanelBase.
  • Added forEachScope() helper for concurrent per-scope fetching and introduced a TTL cache for work item types in AdoClient.

Reviewed changes

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

Show a summary per file
File Description
src/views/panelBase.ts Adds a shared base class for webview panel lifecycle (create, onDidDispose, message handling, dispose).
src/views/prDetailsPanel.ts Migrates PR details panel to PanelBase, removing duplicated panel lifecycle boilerplate.
src/views/workItemDetailsPanel.ts Migrates work item details panel to PanelBase, simplifying lifecycle and disposal.
src/views/pipelineRunDetailsPanel.ts Migrates pipeline run details panel to PanelBase, simplifying lifecycle and disposal.
src/utils/async.ts Adds forEachScope() to standardize scope resolution + concurrent fetch + flattening.
src/providers/workItemProvider.ts Switches to forEachScope() for multi-scope work item loading and removes the local helper.
src/providers/pullRequestProvider.ts Switches to forEachScope() for multi-scope PR loading and removes the local helper.
src/providers/planningProviders.ts Switches planning item loading to forEachScope() to reduce duplication.
src/providers/pipelinesProvider.ts Switches pipeline runs loading to forEachScope() and removes the local helper.
src/utils/ttlCache.ts Introduces a generic in-memory TTL cache utility.
src/api/adoClient.ts Uses TtlCache to cache getWorkItemTypes() results per org/project and clears it on token updates/disconnect.

Comment thread src/providers/workItemProvider.ts Outdated
Comment on lines +178 to +181
const { scopes, items: scopedItems } = await forEachScope(this.client, this.config, async scope => {
const workItems = await this.client.getWorkItems(
scope.project,
this.config.activeWorkItemQuery.filter,
Comment thread src/providers/pipelinesProvider.ts Outdated
Comment on lines +239 to +243
const { scopes, items: scopedRuns } = await forEachScope(this.client, this.config, async scope => {
const builds = await this.client.listPipelineRuns(
scope.project,
scope.organization,
{ top: this.config.pipelineRunsTop, filter: this.config.pipelineRunsFilter }
Marc Kassubeck and others added 3 commits May 21, 2026 00:30
- TtlCache.has() now evicts expired entries (delegates to get())
- Move forEachScope from utils/async.ts to providers/projectScopes.ts
  so unrelated utils/async consumers don't transitively pull in the
  provider layer
- Capture activeWorkItemQuery.filter / pipelineRunsTop / pipelineRunsFilter
  before the concurrent fetcher to guard against config changes mid-load
PanelBase handles webview panel creation, common options (enableScripts, retainContextWhenHidden, localResourceRoots), onDidDispose wiring, message listener registration via onMessage(), and disposal cleanup.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
…ls to extend PanelBase

Each panel now extends PanelBase, removing duplicate constructor boilerplate (webview creation, onDidDispose, onDidReceiveMessage, _disposables field). Common lifecycle managed in the base class. Net savings: ~62 lines.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
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.

2 participants