Skip to content

refactor: rework review queue with internal sidebar workspace#173

Closed
YumemiDream wants to merge 2 commits into
NickCharlie:mainfrom
YumemiDream:fix/pr172-commit-msg
Closed

refactor: rework review queue with internal sidebar workspace#173
YumemiDream wants to merge 2 commits into
NickCharlie:mainfrom
YumemiDream:fix/pr172-commit-msg

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 侧边栏
  • 每个分类按钮显示实时数据角标
  • 切换有淡入动画
  • < 1100px 时侧边栏自动转为顶部横向布局

交互

  • setReviewTab(tab) 切换函数
  • updateReviewNavCounts(counts) 角标更新
  • state.reviews.tab 持久化
  • 同步 aria-selected 无障碍属性

后端

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

配套测试

tests/integration/test_webui_static_assets.py 新增 test_dashboard_review_queue_uses_sidebar_categories
断言关键字符串必须存在,防止未来误删侧边栏结构。

风险评估

  • 🟢 低风险:纯前端 HTML/CSS/JS 改动
  • 🟢 可回滚:单一文件改动
  • 🟢 兼容:DOM ID 保持不变,原有 render 函数无需修改

测试

python -m pytest tests/integration/test_webui_static_assets.py -v

---

## Summary by Sourcery

Refactor the review queue UI into a sidebar-based workspace with categorized tabs and synchronized counts, while preserving existing backend behavior.

Enhancements:
- Introduce a sticky sidebar layout for the review queue with six categorized tabs and responsive behavior on smaller screens.
- Add tab state management and navigation helper functions so the selected review category is persisted and can be deep-linked from insights.
- Aggregate and display backlog and history counts across personas, style reviews, jargon, backups, reviewed items, and batches via a centralized counter updater.
- Adjust jargon statistics and labels for clearer terminology in the UI (e.g., renaming occurrence metrics to hits).

Tests:
- Add an integration test asserting the presence of the new review sidebar structure, tab identifiers, and supporting functions in the dashboard HTML.

- 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 section of dashboard.html into a sidebar-driven, tabbed workspace with category badges and counts, adds JS state and helpers to manage tabs and sidebar metrics, tweaks jargon stats/labels, and introduces an integration test to assert the new sidebar structure is present.

Sequence diagram for review queue sidebar tab switching

sequenceDiagram
    actor User
    participant DashboardPage
    participant setReviewTab

    User->>DashboardPage: click [data-review-tab]
    DashboardPage->>setReviewTab: setReviewTab(dataset.reviewTab)
    activate setReviewTab
    setReviewTab->>setReviewTab: update state.reviews.tab
    setReviewTab->>setReviewTab: toggle .active on [data-review-tab]
    setReviewTab->>setReviewTab: set aria-selected on [data-review-tab]
    setReviewTab->>setReviewTab: toggle .active on [data-review-panel]
    setReviewTab->>setReviewTab: set hidden on [data-review-panel]
    deactivate setReviewTab
Loading

Sequence diagram for insights jumping into a specific review tab

sequenceDiagram
    actor User
    participant DashboardPage
    participant getInsightTargetId
    participant getInsightTargetPage
    participant getReviewTabForInsightTarget
    participant navigateToPage
    participant setReviewTab

    User->>DashboardPage: click insight item
    DashboardPage->>getInsightTargetId: getInsightTargetId(target)
    getInsightTargetId-->>DashboardPage: targetId
    DashboardPage->>getInsightTargetPage: getInsightTargetPage(target)
    getInsightTargetPage-->>DashboardPage: pageId
    DashboardPage->>navigateToPage: navigateToPage(pageId, { keepScroll: true })
    DashboardPage->>getReviewTabForInsightTarget: getReviewTabForInsightTarget(target)
    getReviewTabForInsightTarget-->>DashboardPage: reviewTab
    alt [reviewTab]
        DashboardPage->>setReviewTab: setReviewTab(reviewTab)
    end
Loading

Flow diagram for updating review sidebar badge counts

flowchart TD
    A[state.data] --> B[updateReviewNavCounts]
    B --> C[extractJargonStats]
    B --> D[safeArray persona.updates]
    B --> E[safeNumber style.total]
    B --> F[safeNumber persona.total]
    B --> G[compute personaBacklog
styleBacklog
pendingJargon
reviewedTotal
backupTotal
batchTotal
pendingTotal]
    G --> H[formatCount]
    H --> I[setText reviewSidebarSummary]
    H --> J[setText reviewNavPersonaCount]
    H --> K[setText reviewNavStyleCount]
    H --> L[setText reviewNavJargonCount]
    H --> M[setText reviewNavPersonaStateCount]
    H --> N[setText reviewNavReviewedCount]
    H --> O[setText reviewNavBatchCount]
Loading

File-Level Changes

Change Details Files
Restructure the review queue UI from flat grid panels into a sidebar + tabbed content workspace with six categories.
  • Replace multiple queue-grid sections with a single review-workspace layout containing a sticky review-sidebar and review-main area.
  • Introduce six tabbed panels (persona, style, jargon, persona-state, reviewed, batches) wired via data-review-tab/data-review-panel attributes and aria labels.
  • Reorganize existing panels (persona state, backups, queues, jargon, batches, reviewed history) into the appropriate tab panels without changing their core content markup.
web_res/static/html/dashboard.html
Add styling and responsive behavior for the new review sidebar workspace.
  • Define CSS classes for review-workspace, review-sidebar, review-nav buttons, badges, and tab panels, including active/hover states and simple grid-based layouts.
  • Ensure tab panels are hidden by default and shown via .active class, with review-split-grid used to lay out persona state + backups side by side.
  • Adjust media queries so the workspace collapses to a single column on narrow screens and tweak sidebar padding/button heights for small viewports.
web_res/static/html/dashboard.html
Introduce frontend state and logic to manage review tabs and update sidebar badge counts based on dashboard data.
  • Extend the global state with a reviews.tab field initialized to 'persona'.
  • Add getReviewTabForInsightTarget and integrate it into jumpToInsightTarget so insight links can switch to the appropriate review tab.
  • Implement setReviewTab(tab) to validate tab names, toggle .active/aria-selected on nav buttons, and show/hide panels via data-review-panel/hidden.
  • Implement updateReviewNavCounts(counts) to compute pending and total counts from state.data (persona/style/jargon/personaReviewed/personaBackups/batch), apply overrides from optional counts, and update the sidebar summary and per-tab badges.
  • Invoke updateReviewNavCounts from renderDashboardOverview, renderJargonPanel, and renderBatchPanel so counts stay in sync with data refreshes, and call setReviewTab(state.reviews.tab) after initial render.
  • Add event delegation in bindEvents to handle clicks on [data-review-tab] buttons, calling setReviewTab with the selected tab.
web_res/static/html/dashboard.html
Tighten jargon queue behavior and copy to better match the new workspace.
  • Remove support for the 'occurrences' sort option from the jargon sort select and sort logic.
  • Rename the jargon stats label and per-item metadata from “出现” to “命中”.
  • Recalculate pendingJargon in overview rendering and pass it into updateReviewNavCounts for accurate badge counts tied to jargon candidates vs confirmed jargon.
web_res/static/html/dashboard.html
Add an integration test to lock in the presence of the sidebar-based review queue structure and helpers.
  • Introduce test_dashboard_review_queue_uses_sidebar_categories asserting key CSS classes, data-review-tab attributes for all six categories, and the presence of setReviewTab/updateReviewNavCounts in dashboard.html.
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 left some high level feedback:

  • The pendingJargon computation logic is duplicated in both updateReviewNavCounts and the dashboard render path; consider extracting a small helper (e.g. getPendingJargonCount(jargonStats)) to keep the formula consistent and easier to adjust later.
  • The review tab buttons currently set aria-selected but are missing explicit tab semantics; adding role="tablist"/role="tab" (and possibly keyboard handling) would make the new sidebar navigation more accessible to assistive technologies.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `pendingJargon` computation logic is duplicated in both `updateReviewNavCounts` and the dashboard render path; consider extracting a small helper (e.g. `getPendingJargonCount(jargonStats)`) to keep the formula consistent and easier to adjust later.
- The review tab buttons currently set `aria-selected` but are missing explicit tab semantics; adding `role="tablist"`/`role="tab"` (and possibly keyboard handling) would make the new sidebar navigation more accessible to assistive technologies.

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.

@YumemiDream YumemiDream closed this Jun 7, 2026
@YumemiDream YumemiDream deleted the fix/pr172-commit-msg branch June 7, 2026 06:08
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