Skip to content

fix(playground): align Select All bulk-delete icon with session ⋮ column#13313

Open
keval718 wants to merge 1 commit into
release-1.10.0from
fix/playground-bulk-delete-icon-alignment
Open

fix(playground): align Select All bulk-delete icon with session ⋮ column#13313
keval718 wants to merge 1 commit into
release-1.10.0from
fix/playground-bulk-delete-icon-alignment

Conversation

@keval718
Copy link
Copy Markdown
Collaborator

@keval718 keval718 commented May 23, 2026

Summary

The bulk-delete trash icon in the Select All row of the playground sessions sidebar did not line up with the MoreMenu icons of the session rows below — both vertically (different row heights) and horizontally (different inner-padding shape). This PR aligns the Select All row to the exact same shape and dimensions as a SessionSelector row so the icons sit in the same column on the same baseline.

Root cause

Old Select All wrapper:

<div className="flex items-center justify-between px-2 py-1 mb-1"><div className="w-8 h-8 flex items-center justify-center">
    <Button  className="h-8 w-8 p-0 …"><Trash2 h-4 w-4 /></Button>
  </div>
</div>

Compared with each SessionSelector row (h-8 flex items-center with a SessionMoreMenu trigger of h-8 w-8 p-2):

  • py-1 mb-1 made the Select All row taller and pushed the trash icon's center down relative to the centers in the rows beneath it.
  • The trash button used p-0 and sat in an unpadded host column, so its right edge landed 8 px left of where the SessionMoreMenu trigger's right edge sits (the trigger has its own p-2).

Fix

Mirror the SessionSelector row shape exactly:

  • Outer wrapper: flex h-8 items-center justify-between — no extra vertical padding, no bottom margin. Row height now matches a session row.
  • Trash button: drop the wrapper div; render <Button size="icon" className="h-8 w-8 p-2 rounded …"> directly, matching the SessionMoreMenu trigger's inner padding. The icon centers in the same 32×32 column as .
  • Left cluster: move px-2 from the outer wrapper onto the Select All checkbox cluster so the left edge still aligns with the SessionSelector's internal left padding.

Drive-bys (lines biome would re-flag because they were touched)

  • Removed an unused isDefaultSession local in the sessions map.
  • Sorted useAlertStore / useFlowStore imports per biome organizeImports.
  • Converted the Select All click target from <div onClick> to a real <button type="button" aria-pressed> so keyboard users can toggle it and biome's a11y warning no longer fires.

Trade-offs / alternatives considered

  • Add right padding to the trash column instead of changing the button shape — works visually but leaves two different button shapes for the same conceptual control (row action). Mirroring the SessionMoreMenu shape keeps the codebase consistent.
  • Refactor SessionMoreMenu + bulk-delete into a shared RowActionButton primitive — the right long-term call once a third call site appears. With only two today it would be premature; covered as a future follow-up.

Tests

New __tests__/chat-sidebar.test.tsx (4 cases):

  1. Bulk-delete button not rendered when nothing is selected.
  2. Bulk-delete button renders with h-8 w-8 p-2 shape (regression guard against drift back to p-0).
  3. Host row uses h-8 with no py-* / mb-* padding (regression guard against re-introducing py-1 mb-1).
  4. Clicking the bulk-delete button calls onBulkDeleteSessions with the checked sessions and excludes the default currentFlowId session.

useGetFlowId, useFlowStore, useAlertStore, and SessionSelector are mocked at the module boundary so the test exercises only the Select All row composition.

  • Full playgroundComponent jest suite: 140 / 140 ✅
  • @biomejs/biome check clean on both changed files (0 errors, 0 warnings).
  • make format_frontend clean.

Test plan

  • cd src/frontend && npm start, open playground for any flow.
  • Create 3-4 sessions via the New Chat button.
  • Tick at least one session — the trash icon appears in the Select All row.
  • Visually verify: trash icon center aligns horizontally with the icons in the session rows below; row height matches.
  • Click trash → bulk delete fires, success toast appears.
  • Keyboard test: tab to Select All label, press Enter/Space → toggles selection (aria-pressed flips). Previously the <div> was not focusable.

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Improved the alignment and styling of the select-all and bulk-delete controls in the chat sidebar to ensure better visual consistency and proper positioning relative to session rows.
  • Tests

    • Added comprehensive test coverage for select-all button behavior, including validation of visibility states, button styling and sizing, layout alignment, and correct execution of bulk-delete actions.

Review Change Stack

The bulk-delete trash icon in the Select All row sat off-axis from the
``⋮`` MoreMenu icons of the session rows below: lower (the wrapper had
``py-1 mb-1`` while session rows are ``h-8`` with no vertical padding)
and further left (the trash button was ``p-0`` inside an unpadded
column while the SessionMoreMenu trigger is ``h-8 w-8 p-2``).

Mirror the SessionSelector row shape exactly:

  - Outer wrapper: ``flex h-8 items-center justify-between`` — no extra
    vertical padding, no bottom margin.
  - Trash button: ``size="icon" h-8 w-8 p-2 rounded`` — matches the
    SessionMoreMenu trigger inner padding so the icon centers in the
    same 32×32 column as ``⋮`` below.
  - Inner padding moved to the Select All checkbox cluster (``px-2``)
    so the left edge still lines up with the SessionSelector internal
    padding.

Drive-bys (touched lines biome would flag otherwise):

  - Remove unused ``isDefaultSession`` local in the sessions map.
  - Sort the alertStore/flowStore imports.
  - Convert the Select All click target from ``<div onClick>`` to a
    real ``<button type="button" aria-pressed>`` so keyboard users can
    toggle it and the a11y lint warning no longer fires.

Adds ``__tests__/chat-sidebar.test.tsx`` covering: button hidden when
nothing selected, ``h-8 w-8 p-2`` button shape, host row uses ``h-8``
with no ``py-*`` / ``mb-*`` padding, and bulk delete fires with the
expected (default-session-excluded) selection.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 23, 2026

Walkthrough

This PR refactors the ChatSidebar "Select All" and bulk-delete controls to improve visual alignment with session rows. The "Select All" row now uses a dedicated button element with aria-pressed, and the bulk-delete button styling is updated for consistency. A comprehensive test suite validates the new layout constraints and interaction behavior.

Changes

Select All and Bulk-Delete UI Refactoring

Layer / File(s) Summary
Component refactoring for Select All button and bulk-delete layout
src/frontend/src/components/.../chat-sidebar.tsx
Imports are reordered, the "Select All" control switches from div wrapper to a dedicated <button> with aria-pressed and updated wrapper styling for alignment, and the bulk-delete button is restyled with updated size, padding, and rounded properties while preserving the handleBulkDelete callback.
Test coverage for Select All and bulk-delete alignment and behavior
src/frontend/src/components/.../chat-sidebar.test.tsx
New test suite with store/component mocks validates conditional rendering (no button when nothing selected), correct sizing classes (h-8, w-8, p-2) and absence of conflicting padding, proper wrapper row alignment without vertical padding, and that clicking the bulk-delete button invokes onBulkDeleteSessions with the correct selected ids excluding the current flow id.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 7 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Test Quality And Coverage ⚠️ Warning Tests check p-0 on trash button but the bug is p-0 on Select All button overriding px-2. Missing tests for deselect, callback execution, and edge cases. Add tests for: (1) Select All button px-2 padding not overridden, (2) deselect toggle, (3) onSuccess callback execution with side effects, (4) missing callback behavior.
✅ Passed checks (7 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly and specifically describes the main change: fixing alignment of the Select All bulk-delete icon with the session menu column, which is the primary objective of the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Test Coverage For New Implementations ✅ Passed Test file with 4 test cases and 13 assertions covers all changes: button visibility, CSS classes, row alignment, and bulk-delete functionality. Follows project naming conventions and proper mocking.
Test File Naming And Structure ✅ Passed Frontend test file correctly named (*.test.tsx), uses Jest/RTL framework, includes 4 descriptive test cases with positive/negative/edge scenarios, 4 dependency mocks, and proper assertions.
Excessive Mock Usage Warning ✅ Passed Mocking strategy is appropriate: 4 module mocks target external dependencies (hooks/stores/child component) for Select All/bulk-delete testing without excessive obscuring of core logic.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/playground-bulk-delete-icon-alignment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added the bug Something isn't working label May 23, 2026
@github-actions
Copy link
Copy Markdown
Contributor

✅ Test Coverage Advisor

No source changes detected without accompanying tests. Thanks for keeping coverage up! 🎉

Advisory check only — never blocks merge.

@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels May 23, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 55.49%. Comparing base (1fe9b39) to head (6548f51).

Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                 @@
##           release-1.10.0   #13313      +/-   ##
==================================================
+ Coverage           55.42%   55.49%   +0.07%     
==================================================
  Files                2179     2179              
  Lines              205846   205848       +2     
  Branches            31073    29397    -1676     
==================================================
+ Hits               114091   114243     +152     
+ Misses              90427    90276     -151     
- Partials             1328     1329       +1     
Flag Coverage Δ
backend 60.35% <ø> (+0.03%) ⬆️
frontend 55.29% <100.00%> (+0.10%) ⬆️
lfx 51.71% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
.../chat-view/chat-header/components/chat-sidebar.tsx 93.97% <100.00%> (+51.46%) ⬆️

... and 28 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/frontend/src/components/core/playgroundComponent/chat-view/chat-header/components/__tests__/chat-sidebar.test.tsx (1)

25-41: ⚡ Quick win

Avoid mocking SessionSelector for this alignment-focused test suite.

These tests validate alignment against SessionSelector row behavior, but the local mock replaces that contract with a simplified button. Keep mocks for external dependencies/stores, and render the real SessionSelector (or a higher-fidelity test double) so alignment and interaction assertions track real behavior.

As per coding guidelines, "Ensure mocks are used appropriately for external dependencies only, not for core logic".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/frontend/src/components/core/playgroundComponent/chat-view/chat-header/components/__tests__/chat-sidebar.test.tsx`
around lines 25 - 41, Remove the local jest.mock call that replaces
SessionSelector (the mocked factory returning a simple button) and instead
render the real SessionSelector (or a higher-fidelity test double) in
chat-sidebar.test.tsx so alignment and interaction assertions exercise the real
component behavior; keep mocking only external dependencies/stores, update any
test setup to import the actual SessionSelector component and adjust test
harness data (e.g., the session prop and data-testid session-row-<session>) so
the tests assert against the real DOM structure emitted by SessionSelector
rather than the simplified mock.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@src/frontend/src/components/core/playgroundComponent/chat-view/chat-header/components/chat-sidebar.tsx`:
- Line 159: The Select All button in chat-sidebar.tsx uses conflicting Tailwind
padding utilities ("px-2" and "p-0") so p-0 cancels the horizontal padding;
update the button's className on the Select All element (the element with
className="flex items-center gap-2 cursor-pointer px-2 bg-transparent border-0
p-0") to remove the conflicting p-0 and instead use explicit vertical padding if
needed (e.g., replace p-0 with py-0 or simply remove p-0) so px-2 remains
effective and row alignment is preserved.

---

Nitpick comments:
In
`@src/frontend/src/components/core/playgroundComponent/chat-view/chat-header/components/__tests__/chat-sidebar.test.tsx`:
- Around line 25-41: Remove the local jest.mock call that replaces
SessionSelector (the mocked factory returning a simple button) and instead
render the real SessionSelector (or a higher-fidelity test double) in
chat-sidebar.test.tsx so alignment and interaction assertions exercise the real
component behavior; keep mocking only external dependencies/stores, update any
test setup to import the actual SessionSelector component and adjust test
harness data (e.g., the session prop and data-testid session-row-<session>) so
the tests assert against the real DOM structure emitted by SessionSelector
rather than the simplified mock.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d408783b-ede4-4317-9826-acd3325ca52f

📥 Commits

Reviewing files that changed from the base of the PR and between 1fe9b39 and 6548f51.

📒 Files selected for processing (2)
  • src/frontend/src/components/core/playgroundComponent/chat-view/chat-header/components/__tests__/chat-sidebar.test.tsx
  • src/frontend/src/components/core/playgroundComponent/chat-view/chat-header/components/chat-sidebar.tsx

<div className="flex h-8 items-center justify-between">
<button
type="button"
className="flex items-center gap-2 cursor-pointer px-2 bg-transparent border-0 p-0"
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.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Fix conflicting padding utilities on the Select All button.

At Line 159, p-0 overrides px-2, so the left padding intended to preserve row alignment is effectively removed.

Suggested fix
- className="flex items-center gap-2 cursor-pointer px-2 bg-transparent border-0 p-0"
+ className="flex items-center gap-2 cursor-pointer px-2 bg-transparent border-0 py-0"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
className="flex items-center gap-2 cursor-pointer px-2 bg-transparent border-0 p-0"
className="flex items-center gap-2 cursor-pointer px-2 bg-transparent border-0 py-0"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/frontend/src/components/core/playgroundComponent/chat-view/chat-header/components/chat-sidebar.tsx`
at line 159, The Select All button in chat-sidebar.tsx uses conflicting Tailwind
padding utilities ("px-2" and "p-0") so p-0 cancels the horizontal padding;
update the button's className on the Select All element (the element with
className="flex items-center gap-2 cursor-pointer px-2 bg-transparent border-0
p-0") to remove the conflicting p-0 and instead use explicit vertical padding if
needed (e.g., replace p-0 with py-0 or simply remove p-0) so px-2 remains
effective and row alignment is preserved.

@github-actions
Copy link
Copy Markdown
Contributor

Frontend Unit Test Coverage Report

Coverage Summary

Lines Statements Branches Functions
Coverage: 39%
39.92% (50732/127074) 68.52% (6926/10107) 39.11% (1144/2925)

Unit Test Results

Tests Skipped Failures Errors Time
4428 0 💤 0 ❌ 0 🔥 10m 59s ⏱️

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant