Skip to content

Commit ea2c534

Browse files
authored
Merge pull request #3154 from GCWing/nonoqing/fix/scheduled-jobs-icon-followup
fix(web-ui): show the scheduled job badge on workspace rows
2 parents 8471a65 + b34961f commit ea2c534

3 files changed

Lines changed: 33 additions & 9 deletions

File tree

‎src/web-ui/src/app/components/NavPanel/sections/sessions/SessionsSectionLayout.test.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ describe('SessionsSection layout styles', () => {
170170
const btwBadgeBlock = extractInlineItemBlock(stylesheet, 'btw-badge');
171171
const reviewBadgeBlock = extractInlineItemBlock(stylesheet, 'review-badge');
172172
const backgroundSubagentBadgeBlock = extractInlineItemBlock(stylesheet, 'background-subagent-badge');
173+
// Shared by session rows and workspace rows, so it must hold its slot width.
174+
const cronBadgeBlock = extractInlineItemBlock(stylesheet, 'cron-badge');
173175

174176
expect(labelBlock).toContain('flex: 1 1 0;');
175177
expect(labelBlock).toContain('overflow: hidden;');
@@ -189,6 +191,10 @@ describe('SessionsSection layout styles', () => {
189191
expect(backgroundSubagentBadgeBlock).toContain('line-height: 0;');
190192
expect(backgroundSubagentBadgeBlock).toContain('width: var(--openbitfun-control-icon-size-md);');
191193
expect(backgroundSubagentBadgeBlock).toContain('height: var(--openbitfun-control-icon-size-md);');
194+
expect(cronBadgeBlock).toContain('flex: 0 0 auto;');
195+
expect(cronBadgeBlock).toContain('display: inline-flex;');
196+
expect(cronBadgeBlock).toContain('align-items: center;');
197+
expect(cronBadgeBlock).toContain('white-space: nowrap;');
192198

193199
const backgroundSubagentIconBlock = extractInlineItemBlock(stylesheet, 'background-subagent-icon');
194200
expect(backgroundSubagentIconBlock).toContain('place-self: center;');

‎src/web-ui/src/app/components/NavPanel/sections/workspaces/WorkspaceItem.tsx‎

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,18 @@ const WorkspaceItem: React.FC<WorkspaceItemProps> = ({
117117
getCronJobCountsSnapshot,
118118
);
119119
const scheduledJobCount = cronJobCounts.byWorkspaceId.get(workspace.id) ?? 0;
120+
// Rendered through ActionItem's trailing slot so both name rows keep the badge on
121+
// the name line. The rows flatten that label slot with `display: contents`, so a
122+
// badge appended to the label children would silently break if that rule changed.
123+
const scheduledJobBadge = scheduledJobCount > 0 ? (
124+
<span
125+
className="openbitfun-nav-panel__inline-item-cron-badge"
126+
title={t('nav.scheduledJobs.badgeTooltip', { count: scheduledJobCount })}
127+
>
128+
<Icon name="clock" size="2xs" aria-hidden />
129+
{scheduledJobCount}
130+
</span>
131+
) : undefined;
120132
const {
121133
setActiveWorkspace,
122134
closeWorkspaceById,
@@ -866,20 +878,12 @@ const WorkspaceItem: React.FC<WorkspaceItemProps> = ({
866878
className="openbitfun-nav-panel__assistant-item-name-action"
867879
triggerClassName="openbitfun-nav-panel__assistant-item-name-btn"
868880
labelBehavior="static"
881+
metadata={scheduledJobBadge}
869882
onClick={e => { e.stopPropagation(); handleCollapseToggle(); }}
870883
data-testid="nav-workspace-name-btn"
871884
data-workspace-id={workspace.id}
872885
>
873886
<OverflowText className="openbitfun-nav-panel__assistant-item-label" data-openbitfun-product-component="workspace-item" data-openbitfun-product-part="label">{workspaceDisplayName}</OverflowText>
874-
{scheduledJobCount > 0 ? (
875-
<span
876-
className="openbitfun-nav-panel__inline-item-cron-badge"
877-
title={t('nav.scheduledJobs.badgeTooltip', { count: scheduledJobCount })}
878-
>
879-
<Icon name="clock" size="2xs" aria-hidden />
880-
{scheduledJobCount}
881-
</span>
882-
) : null}
883887
</ActionItem>
884888
</Tooltip>
885889

@@ -1181,6 +1185,7 @@ const WorkspaceItem: React.FC<WorkspaceItemProps> = ({
11811185
className="openbitfun-nav-panel__workspace-item-name-action"
11821186
triggerClassName="openbitfun-nav-panel__workspace-item-name-btn"
11831187
labelBehavior="static"
1188+
metadata={scheduledJobBadge}
11841189
onClick={e => { e.stopPropagation(); handleCollapseToggle(); }}
11851190
data-testid="nav-workspace-name-btn"
11861191
data-workspace-id={workspace.id}

‎src/web-ui/src/app/components/NavPanel/sections/workspaces/WorkspaceListSectionLayout.test.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,19 @@ describe('WorkspaceListSection layout styles', () => {
159159
expect(source.match(/data-testid="nav-workspace-new-session-btn"/g)).toHaveLength(2);
160160
});
161161

162+
it('keeps the scheduled-job badge on the trailing slot of both workspace rows', () => {
163+
const source = readWorkspaceItemSource();
164+
165+
// The workspace row and the assistant-group row both flatten their ActionItem
166+
// label slot with `display: contents`, so the badge must stay one flex sibling of
167+
// the name and be rendered by each variant from a single source.
168+
expect(source).toContain('const scheduledJobBadge = scheduledJobCount > 0 ? (');
169+
expect(source.match(/metadata=\{scheduledJobBadge\}/g)).toHaveLength(2);
170+
expect(source).not.toContain('{scheduledJobCount > 0 ?');
171+
expect(source).toContain('className="openbitfun-nav-panel__inline-item-cron-badge"');
172+
expect(source).toContain("title={t('nav.scheduledJobs.badgeTooltip', { count: scheduledJobCount })}");
173+
});
174+
162175
it('keeps workspace and assistant rows flat on hover', () => {
163176
const stylesheet = readWorkspaceListStylesheet();
164177

0 commit comments

Comments
 (0)