Skip to content

前端优化: 审查队列页面增加侧边栏分类 rework review queue with internal sidebar workspace#172

Closed
YumemiDream wants to merge 4 commits into
NickCharlie:mainfrom
YumemiDream:main
Closed

前端优化: 审查队列页面增加侧边栏分类 rework review queue with internal sidebar workspace#172
YumemiDream wants to merge 4 commits into
NickCharlie:mainfrom
YumemiDream:main

Conversation

@YumemiDream

@YumemiDream YumemiDream commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

描述

背景

原版审查队列页(#page-reviews)是一个 2 列网格布局,所有面板(人格状态、备份、
待审人格、风格审查、已审历史、黑话、批次)平铺在一起。随着面板增多,页面
越来越长,用户需要不断滚动才能在"概览"和"待办操作"之间切换。

改动

将审查队列重构为"左侧固定侧边栏 + 右侧内容区"布局,按功能分为 6 个分类,
每个分类可一键切换,无需滚动。

6 个分类

Tab data 属性 包含内容
待审人格 persona 待审人格列表
风格审查 style 风格学习审查列表
黑话 jargon 黑话候选列表 + 筛选/搜索/翻页
人格状态 persona-state 当前生效人格 + 备份
已审 reviewed 最近已审人格历史
批次 batches 最近学习批次

视觉

  • 左侧 position: sticky 侧边栏,桌面端始终可见
  • 每个分类按钮显示实时数据角标(待审数、备份数等)
  • 切换有淡入动画 (pageIn keyframes)
  • < 1100px 时侧边栏自动转为顶部横向布局

交互

  • 新增 setReviewTab(tab) JS 函数:切换 active 类 + 显示对应 section
  • 新增 updateReviewNavCounts(counts) JS 函数:实时更新侧边栏角标
  • state.reviews.tab 持久化当前 tab,刷新页面/返回时恢复
  • 点击 tab 时通过 aria-selected 同步无障碍属性

后端

无任何后端改动。所有改动均在 web_res/static/html/dashboard.html 一个文件内完成。

配套测试

tests/integration/test_webui_static_assets.py 新增 test_dashboard_review_queue_uses_sidebar_categories
断言关键字符串(CSS 类、data 属性、JS 函数名)必须存在,防止未来误删侧边栏结构。

风险评估

  • 🟢 低风险:纯前端 HTML/CSS/JS 改动,不影响后端 API
  • 🟢 可回滚:单一文件改动,git revert 即可
  • 🟢 兼容:不改变 DOM ID(personaList、styleList、jargonList、batchList 等保持不变),
    原有 render 函数无需修改

测试

# 1. 运行集成测试
python -m pytest tests/integration/test_webui_static_assets.py -v

# 2. 手动检查
# 打开 dashboard → 审查队列 → 应看到左侧 6 个分类的侧边栏
# 切换 tab → 角标实时变化
# 浏览器宽度 < 1100px → 侧边栏变成顶部横向

## 提交信息

d153989 refactor: rework review queue with internal sidebar workspace

**改动量**`dashboard.html` +495 / -119 行(纯一个文件)
**测试**`test_webui_static_assets.py` +22 行


<img width="1606" height="888" alt="48d3e7d2-db92-4ba9-b725-05cf0939805e" src="https://github.com/user-attachments/assets/25b6bcd0-f0b2-429d-8f72-7142b70c0e28" />

## Summary by Sourcery

Refactor the review queue dashboard into a tabbed sidebar workspace with categorized panels and synchronized summary badges, improving navigation and readability while preserving existing review data panels.

Enhancements:
- Introduce a sticky sidebar-based review workspace layout that groups review panels into six tabbed categories with responsive behavior for smaller screens.
- Add client-side state and helpers to switch review tabs, persist the active tab, and update sidebar badge counts based on current review, jargon, backup, and batch statistics.
- Adjust jargon statistics and item metadata wording from “出现” to “命中” and simplify sorting options by removing occurrence-based sorting.

Tests:
- Add an integration test that asserts the presence of the new sidebar review queue structure, data attributes, and JavaScript helpers to guard against accidental removal of the new layout.

YumemiDream and others added 4 commits June 6, 2026 14:45
- Add a dedicated review workspace layout with sticky sidebar
  containing 6 category buttons: persona / style / jargon /
  persona-state / reviewed / batches
- Each button shows live count badges; counts update whenever
  persona, style, jargon, persona-state, backup or batch data
  is loaded
- Add setReviewTab(tab) / updateReviewNavCounts(counts) helpers
  and bind button clicks + page-revisit restore (state.reviews.tab)
- Add new integration test test_dashboard_review_queue_uses_sidebar_categories
  to lock in the new structure
@sourcery-ai

sourcery-ai Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Refactors the review queue dashboard section into a sidebar-driven tabbed workspace with six categorized panels, adds JS helpers to manage active tabs and sidebar counters, wires them into existing data rendering and navigation, adjusts responsive CSS, and introduces a regression test to ensure the new sidebar structure remains intact.

Sequence diagram for review tab switching via sidebar

sequenceDiagram
    actor Reviewer
    participant ReviewSidebar as review_nav_btn
    participant DashboardJS as setReviewTab
    participant Panels as review_tab_panel

    Reviewer->>ReviewSidebar: click [data-review-tab]
    ReviewSidebar->>DashboardJS: setReviewTab(tab)
    DashboardJS->>DashboardJS: validate tab
    DashboardJS->>ReviewSidebar: toggle active class
    DashboardJS->>ReviewSidebar: set aria-selected
    DashboardJS->>Panels: toggle active class
    DashboardJS->>Panels: set hidden flag
Loading

Flow diagram for updating review sidebar counters

flowchart TD
    A[state.data] --> B[updateReviewNavCounts]
    B --> C[compute personaBacklog
styleBacklog
pendingJargon
backupTotal
reviewedTotal
batchTotal]
    C --> D[setText reviewSidebarSummary]
    C --> E[setText reviewNavPersonaCount]
    C --> F[setText reviewNavStyleCount]
    C --> G[setText reviewNavJargonCount]
    C --> H[setText reviewNavPersonaStateCount]
    C --> I[setText reviewNavReviewedCount]
    C --> J[setText reviewNavBatchCount]
Loading

File-Level Changes

Change Details Files
Rework the review queue layout into a sidebar + tabbed content workspace with six categorized panels.
  • Replace the previous multi-row queue-grid panels with a .review-workspace container that holds a sticky .review-sidebar and a .review-main content area.
  • Define six .review-tab-panel sections (persona, style, jargon, persona-state, reviewed, batches) that each host the pre-existing panel contents, now shown/hidden per active tab.
  • Introduce .review-split-grid for the persona-state view to show current persona state and backups side by side, preserving existing DOM IDs for panel bodies and lists.
web_res/static/html/dashboard.html
Introduce new sidebar navigation UI styles, responsive behavior, and accessibility attributes for the review workspace.
  • Add CSS for .review-workspace, .review-sidebar, .review-nav, .review-nav-btn, badges, and icon blocks including active and hover states.
  • Adjust responsive rules so that at narrower widths the workspace and split grid collapse to one column and the sidebar loses sticky positioning and tightens padding/button height.
  • Add aria-label and aria-selected attributes on sidebar nav containers and buttons for better accessibility and state indication.
web_res/static/html/dashboard.html
Add JavaScript state, helpers, and event wiring to manage active review tabs and to keep sidebar counters in sync with dashboard data.
  • Extend the global state with state.reviews.tab defaulting to 'persona'.
  • Implement setReviewTab(tab) to validate the tab, persist it into state.reviews.tab, toggle .active classes and aria-selected on nav buttons, and show/hide the corresponding [data-review-panel] sections via class and hidden attribute.
  • Implement updateReviewNavCounts(counts) to compute defaults from existing dashboard data (persona, style, personaReviewed, personaBackups, jargonStats, batch totals), derive pending counts, and update the sidebar summary and individual badges.
  • Invoke updateReviewNavCounts and setReviewTab within the main dashboard render pipeline (after queue data is rendered), and also from jargon and batch render functions so that pagination / filtering keeps counts fresh.
  • Update the document-level click handler to route clicks on [data-review-tab] buttons through setReviewTab, and extend jumpToInsightTarget to also set the appropriate review tab using a new getReviewTabForInsightTarget helper.
web_res/static/html/dashboard.html
Tweak jargon statistics presentation and simplify sorting behavior.
  • Remove the 'occurrences' sort option from jargon list ordering logic so it no longer sorts by occurrences count.
  • Rename occurrences-related labels from “出现” to “命中” in both the jargon stats summary and individual item metadata display.
  • Ensure pending jargon counts for the sidebar are recomputed in both the main render and renderJargonPanel and passed into updateReviewNavCounts.
web_res/static/html/dashboard.html
Add an integration test to guard the new sidebar-based structure and JS entry points for the review queue.
  • Introduce test_dashboard_review_queue_uses_sidebar_categories that reads dashboard.html and asserts presence of the sidebar-related CSS class names, data-review-tab attributes for all six categories, and the new JS functions setReviewTab and updateReviewNavCounts.
tests/integration/test_webui_static_assets.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

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.

Hey - I've found 1 issue, and left some high level feedback:

  • The sidebar tab controls currently only use aria-selected; consider adding appropriate ARIA roles (e.g. role="tablist" on the nav and role="tab"/role="tabpanel" on buttons/panels) to make the new review workspace more accessible to screen readers.
  • The list of valid review tabs is hardcoded in multiple places (setReviewTab, getReviewTabForInsightTarget, HTML data-review-tab/data-review-panel), which makes it easy for them to drift out of sync; it may be worth centralizing the tab IDs in one data structure and deriving both JS logic and markup from it where possible.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The sidebar tab controls currently only use `aria-selected`; consider adding appropriate ARIA roles (e.g. `role="tablist"` on the nav and `role="tab"`/`role="tabpanel"` on buttons/panels) to make the new review workspace more accessible to screen readers.
- The list of valid review tabs is hardcoded in multiple places (`setReviewTab`, `getReviewTabForInsightTarget`, HTML `data-review-tab`/`data-review-panel`), which makes it easy for them to drift out of sync; it may be worth centralizing the tab IDs in one data structure and deriving both JS logic and markup from it where possible.

## Individual Comments

### Comment 1
<location path="web_res/static/html/dashboard.html" line_range="920-929" />
<code_context>
+            gap: 16px;
+        }
+
+        .review-tab-panel.active {
+            display: grid;
+        }
</code_context>
<issue_to_address>
**suggestion:** Consider aligning ARIA roles/attributes with the tabbed navigation semantics.

The current use of `aria-selected` on the sidebar buttons and `hidden` on panels is close to a tab interface. To improve accessibility, add tab roles: `role="tablist"` on the nav container, `role="tab"` on each `.review-nav-btn`, and `role="tabpanel"` on each `.review-tab-panel`, linked via `id`/`aria-controls` so assistive technologies recognize this as a tabset.

Suggested implementation:

```
<div class="review-sidebar" role="tablist">

```

```
<button class="review-nav-btn" role="tab"

```

```
<div class="review-tab-panel" role="tabpanel"

```

To fully align with tab semantics, you should also:
1. Ensure each tab button has a unique `id` (e.g. `id="review-tab-overview"`) and an `aria-controls` attribute pointing to its panel (e.g. `aria-controls="review-panel-overview"`).
2. Ensure each `.review-tab-panel` has a matching unique `id` (e.g. `id="review-panel-overview"`) and an `aria-labelledby` pointing back to the tab `id`.
3. Confirm that the existing JS that toggles `aria-selected` and `hidden` continues to work with these new attributes; if necessary, update it to:
   - Set `aria-selected="true"` on the active tab and `"false"` on inactive tabs.
   - Set `hidden` on inactive panels and remove `hidden` from the active panel based on the `aria-controls` / `id` linkage rather than class names alone.
4. If the nav container for `.review-nav-btn` is not exactly `.review-sidebar`, adjust the first SEARCH/REPLACE to target the actual container element that wraps the set of review nav buttons and add `role="tablist"` there instead.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +920 to +929
.review-tab-panel.active {
display: grid;
}

.review-split-grid {
display: grid;
grid-template-columns: minmax(0, 1fr) minmax(300px, 0.85fr);
gap: 16px;
}

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.

suggestion: Consider aligning ARIA roles/attributes with the tabbed navigation semantics.

The current use of aria-selected on the sidebar buttons and hidden on panels is close to a tab interface. To improve accessibility, add tab roles: role="tablist" on the nav container, role="tab" on each .review-nav-btn, and role="tabpanel" on each .review-tab-panel, linked via id/aria-controls so assistive technologies recognize this as a tabset.

Suggested implementation:

<div class="review-sidebar" role="tablist">

<button class="review-nav-btn" role="tab"

<div class="review-tab-panel" role="tabpanel"

To fully align with tab semantics, you should also:

  1. Ensure each tab button has a unique id (e.g. id="review-tab-overview") and an aria-controls attribute pointing to its panel (e.g. aria-controls="review-panel-overview").
  2. Ensure each .review-tab-panel has a matching unique id (e.g. id="review-panel-overview") and an aria-labelledby pointing back to the tab id.
  3. Confirm that the existing JS that toggles aria-selected and hidden continues to work with these new attributes; if necessary, update it to:
    • Set aria-selected="true" on the active tab and "false" on inactive tabs.
    • Set hidden on inactive panels and remove hidden from the active panel based on the aria-controls / id linkage rather than class names alone.
  4. If the nav container for .review-nav-btn is not exactly .review-sidebar, adjust the first SEARCH/REPLACE to target the actual container element that wraps the set of review nav buttons and add role="tablist" there instead.

@YumemiDream YumemiDream closed this Jun 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant