fix: lifecycle scripts getting recognized in resource monitor#2222
fix: lifecycle scripts getting recognized in resource monitor#2222janburzinski wants to merge 2 commits into
Conversation
Greptile SummaryThis PR fixes lifecycle scripts (setup/run/teardown) not being grouped under their owning task in the resource monitor. The root cause was that agent PTYs use a task ID as their
Confidence Score: 4/5Safe to merge — the grouping fix is well-scoped and the label map keys match what createLifecycleScriptTerminalId produces today. The bucketing logic correctly handles both agent PTYs and lifecycle-script PTYs. The LIFECYCLE_SCRIPT_LABELS keys are verified against the shared terminals.ts source but are hardcoded string literals that could silently drift if the shared function's naming pattern changes. The LIFECYCLE_SCRIPT_LABELS constant in resource-monitor-utils.ts is worth a second look — its string keys duplicate the output of createLifecycleScriptTerminalId and could drift silently.
|
| Filename | Overview |
|---|---|
| src/renderer/features/command-palette/resource-monitor-utils.ts | Adds LIFECYCLE_SCRIPT_LABELS, exports entryLabel and isLifecycleScriptEntry, and updates buildGroups to resolve lifecycle-script PTYs (scoped by workspaceId) to their owning task bucket. The label map hardcodes strings that should derive from createLifecycleScriptTerminalId. |
| src/renderer/features/command-palette/resource-monitor-view.tsx | Imports and uses the new entryLabel and isLifecycleScriptEntry helpers; adds a Terminal icon for lifecycle-script rows. Changes look correct. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[ResourcePtyEntry] --> B{projectStore found?}
B -- No --> C[Use scopeId as bucketKey, group under Other]
B -- Yes --> D{Direct task lookup via tasks.get scopeId}
D -- Hit --> E[bucketKey equals taskId, agent PTY path]
D -- Miss --> F{Fallback: scan tasks for matching workspaceId}
F -- Found --> G[bucketKey equals taskId, lifecycle script path]
F -- Not Found --> H[bucketKey equals scopeId, grouped under Other]
E --> I[Push entry into task bucket]
G --> I
H --> I
C --> I
I --> J[Group by project, sort and return Groups]
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
src/renderer/features/command-palette/resource-monitor-utils.ts:40-44
The keys in `LIFECYCLE_SCRIPT_LABELS` are string literals that duplicate the output of `createLifecycleScriptTerminalId` from `@shared/terminals`. If that function's naming pattern ever changes, this map will silently keep returning `undefined` for every lifecycle-script entry, causing them to fall back to the truncated `leafId` label — the very problem this PR fixes. Using computed property keys from the shared function keeps both in sync automatically.
```suggestion
import { createLifecycleScriptTerminalId } from '@shared/terminals';
const LIFECYCLE_SCRIPT_LABELS: Record<string, string> = {
[createLifecycleScriptTerminalId('setup')]: 'Setup script',
[createLifecycleScriptTerminalId('run')]: 'Run script',
[createLifecycleScriptTerminalId('teardown')]: 'Teardown script',
};
```
Reviews (1): Last reviewed commit: "feat(resource-monitor): lifecycle script..." | Re-trigger Greptile
summary
this is after:
