Skip to content

feat: group scheduled task results#977

Open
Nikhil (shadowfax92) wants to merge 1 commit intodevfrom
polecat/jade/bosmain-obt@moxnpvqc
Open

feat: group scheduled task results#977
Nikhil (shadowfax92) wants to merge 1 commit intodevfrom
polecat/jade/bosmain-obt@moxnpvqc

Conversation

@shadowfax92
Copy link
Copy Markdown
Contributor

Summary

  • Groups scheduled task run results by scheduled task instead of rendering one flat chronological list.
  • Adds single-open collapse/expand sections with task name, latest run timestamp, latest status icon, and result count.
  • Adds focused tests for result grouping, newest-first ordering, and missing-task fallback labels.

Test plan

  • bun run --filter @browseros/agent typecheck
  • bun run --filter @browseros/agent test
  • bun run --filter @browseros/agent lint (exits 0; reports existing unrelated warnings in NewTab, Sentry sanitize, and tool-labels)
  • bun run --filter @browseros/agent build

Fixes #950

@shadowfax92
Copy link
Copy Markdown
Contributor Author

Claude (@claude) review

@shadowfax92
Copy link
Copy Markdown
Contributor Author

Greptile (@greptileai) review

@claude
Copy link
Copy Markdown

claude Bot commented May 9, 2026

Claude Code is working…

I'll analyze this and get back to you.

View job run

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 9, 2026

✅ Tests passed — 1224/1228

Suite Passed Failed Skipped
agent 81/81 0 0
build 9/9 0 0
eval 93/93 0 0
server-agent 261/261 0 0
server-api 203/203 0 0
server-browser 4/4 0 0
server-integration 9/10 0 1
server-lib 242/242 0 0
server-root 60/63 0 3
server-skills 31/31 0 0
server-tools 231/231 0 0

View workflow run

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 9, 2026

Greptile Summary

This PR refactors the scheduled-task results panel from a flat chronological list into grouped, single-open collapsible sections — one per scheduled task — showing the task name, result count, and latest run status in the header. A new scheduledTaskResultsUtils.ts module handles grouping logic in isolation with dedicated tests.

  • Grouping & ordering: groupScheduledTaskRuns correctly separates display sort order (running runs first, then newest) from the header's latestRun value (strictly newest by startedAt), and groups are themselves ordered by their latest run — matching what the tests assert.
  • Accordion state: The derived visibleExpandedGroupId correctly handles three states — uninitialized (auto-open first), explicitly closed by the user (null), and stale (group deleted → fall back to first group).
  • Event handling: The refactored inner-run layout separates the clickable content area from the action buttons as siblings inside a plain <div>, so stopPropagation is no longer needed (and has been correctly removed).

Confidence Score: 5/5

Safe to merge — grouping logic is well-isolated, the accordion state machine handles all edge cases, and the button-event refactor correctly replaces stopPropagation with structural separation.

The change is self-contained: new utility logic is covered by targeted tests, the UI state derivation handles initialization/stale-group/user-closed branches correctly, and no existing behavior is regressed. No data paths, storage calls, or cross-component contracts are affected.

No files require special attention.

Important Files Changed

Filename Overview
packages/browseros-agent/apps/agent/entrypoints/app/scheduled-tasks/scheduledTaskResultsUtils.ts New utility that groups runs by job ID, resolves names, sorts groups and intra-group runs with clear separation between display order (running-first) and header data (latest by startedAt). Logic is correct and well-extracted.
packages/browseros-agent/apps/agent/entrypoints/app/scheduled-tasks/ScheduledTaskResults.tsx Replaces flat run list with grouped collapsible sections; single-open accordion state is correctly derived; button structure is refactored so Cancel/Retry no longer need stopPropagation; clean and no regressions found.
packages/browseros-agent/apps/agent/entrypoints/app/scheduled-tasks/ScheduledTaskResults.test.ts New test file covers grouping, newest-first ordering, unknown-task fallback, and running-first display sort; all three assertions are well-targeted and match the implemented behavior.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["ScheduledTaskResults renders"] --> B["groupScheduledTaskRuns(runs, jobs)"]
    B --> C["Build jobsById Map"]
    C --> D["Group runs by jobId → groupsByJobId Map"]
    D --> E["For each group:\nsortedRuns = compareRunsForDisplay\nlatestRun = compareRunsByNewest[0]"]
    E --> F["filter(group.latestRun exists)"]
    F --> G["sort groups by latestRun.startedAt desc"]
    G --> H["taskGroups returned"]
    H --> I["Derive visibleExpandedGroupId"]
    I -->|"undefined (initial)"| J["taskGroups[0].id"]
    I -->|"expandedGroupId not in groups"| J
    I -->|"null (user closed)"| K["null — all collapsed"]
    I -->|"valid id"| L["expandedGroupId"]
    J --> M["Render Collapsibles\none open at a time"]
    K --> M
    L --> M
    M --> N["CollapsibleTrigger: name, count, latest status"]
    M --> O["CollapsibleContent: per-run rows"]
    O --> P["button → onViewRun (content area)"]
    O --> Q["Cancel / Retry / View buttons (sibling div)"]
Loading

Reviews (2): Last reviewed commit: "feat: group scheduled task results (bosm..." | Re-trigger Greptile

Comment on lines +144 to +206
{group.runs.map((run) => {
const preview = getRunPreview(run)

return (
<div
key={run.id}
className="flex items-start gap-3 rounded-lg border border-border bg-background p-3"
>
<div className="pt-0.5">{getStatusIcon(run.status)}</div>
<button
type="button"
onClick={() => onViewRun(run)}
className="min-w-0 flex-1 text-left"
>
<div className="flex flex-wrap items-center gap-2">
<span className="text-foreground text-sm">
{formatRunTimestamp(run.startedAt)}
</span>
<span className="text-muted-foreground text-xs">
{run.status}
</span>
</div>
{preview && (
<p className="mt-1 line-clamp-2 text-muted-foreground text-xs">
{preview}
</p>
)}
</button>
<div className="flex shrink-0 items-center gap-1">
{run.status === 'running' && (
<Button
variant="ghost"
size="icon-sm"
onClick={() => onCancelRun(run.id)}
className="text-destructive hover:bg-destructive/10 hover:text-destructive"
aria-label="Cancel run"
>
<Square className="h-3.5 w-3.5" />
</Button>
)}
{run.status === 'failed' && (
<Button
variant="ghost"
size="icon-sm"
onClick={() => onRetryRun(run.jobId)}
className="text-muted-foreground hover:text-foreground"
aria-label="Retry run"
>
<RotateCcw className="h-3.5 w-3.5" />
</Button>
)}
<Button
variant="ghost"
size="sm"
onClick={() => onViewRun(run)}
className="text-muted-foreground hover:text-foreground"
>
View
</Button>
</div>
</div>
)
})}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Running tasks no longer sorted to the top within a group

The previous implementation explicitly floated running runs before completed/failed ones. In the new grouping, runs are sorted purely by startedAt (newest-first), so a currently-running task that started earlier than a recently-completed run will appear below it in the list. In practice this edge case is rare, but it's a behavioral regression worth confirming is intentional.

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/browseros-agent/apps/agent/entrypoints/app/scheduled-tasks/ScheduledTaskResults.tsx
Line: 144-206

Comment:
**Running tasks no longer sorted to the top within a group**

The previous implementation explicitly floated `running` runs before `completed`/`failed` ones. In the new grouping, runs are sorted purely by `startedAt` (newest-first), so a currently-running task that started earlier than a recently-completed run will appear below it in the list. In practice this edge case is rare, but it's a behavioral regression worth confirming is intentional.

How can I resolve this? If you propose a fix, please make it concise.

@shadowfax92 Nikhil (shadowfax92) force-pushed the polecat/jade/bosmain-obt@moxnpvqc branch from 764b730 to d405f59 Compare May 9, 2026 01:33
@shadowfax92
Copy link
Copy Markdown
Contributor Author

Addressed the Greptile notes in d405f59: default expanded group is now derived before paint instead of set in an effect, and running runs are kept first within a group while latest-run/group ordering still uses startedAt. Local gates rerun: typecheck, test, lint, build.

@shadowfax92
Copy link
Copy Markdown
Contributor Author

Greptile (@greptileai) review

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feat] Group scheduled task results by task name with collapse/expand

1 participant