refactor: extract PanelBase for webview panels#64
Open
CompN3rd wants to merge 5 commits into
Open
Conversation
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>
There was a problem hiding this comment.
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
PanelBaseto 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 inAdoClient.
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 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 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 } |
- 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
PanelBase (new)
Migrated panels
Not migrated
Verification
pm run compile\ — all TypeScript checks pass