Skip to content

feat(desktop): add setting to disable sidebar line-change stats#2635

Open
martin-ro wants to merge 1 commit into
superset-sh:mainfrom
martin-ro:lines-changed-setting
Open

feat(desktop): add setting to disable sidebar line-change stats#2635
martin-ro wants to merge 1 commit into
superset-sh:mainfrom
martin-ro:lines-changed-setting

Conversation

@martin-ro
Copy link
Copy Markdown

@martin-ro martin-ro commented Mar 20, 2026

Summary

  • add a new persisted setting Show lines changed (default: on)
  • hide +/- line-change badges in the left workspace sidebar when disabled
  • hide +/- line-change badges in the right Changes sidebar (including commit file lists) when disabled
  • expose the toggle in Settings > Behavior and add settings-search keywords for "lines changed"
  • add local-db migration for show_line_change_stats

Screenshot

Sidebar noise from lines changed setting

Verification

  • bun test src/renderer/routes/_authenticated/settings/utils/settings-search/settings-search.test.ts
  • bun test src/renderer/screens/main/components/WorkspaceView/RightSidebar/ChangesView/hooks/useOrderedSections/useOrderedSections.test.tsx
  • bun run typecheck (in apps/desktop)

Summary by cubic

Adds a new “Show lines changed” setting (default on) to toggle the +/- line-change badges in both sidebars. This reduces sidebar noise when disabled.

  • New Features

    • Added a persisted toggle in Settings > Behavior; searchable via “lines changed”.
    • Introduced getShowLineChangeStats and setShowLineChangeStats and DEFAULT_SHOW_LINE_CHANGE_STATS.
    • Updated dashboard/workspace rows, sidebar items, and commit/file lists to respect the setting.
    • Added tests for settings search and ordered sections.
  • Migration

    • Added settings.show_line_change_stats via migration 0037; no manual steps required.

Written for commit 1ea2271. Summary will update on new commits.

Summary by CodeRabbit

  • New Features
    • Added "Show lines changed" setting in behavior preferences to control visibility of line addition/deletion statistics (+/−) throughout the application, including workspace sidebars and diff views. Defaults to enabled.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 20, 2026

📝 Walkthrough

Walkthrough

A new user-toggleable setting is introduced that controls the display of diff line statistics (additions/deletions counts) across the application. The setting is persisted to the database, exposed via TRPC endpoints, integrated into the Settings UI, and wired into multiple sidebar and changes-view components to conditionally render line-change statistics.

Changes

Cohort / File(s) Summary
Backend TRPC Settings
apps/desktop/src/lib/trpc/routers/settings/index.ts, apps/desktop/src/shared/constants.ts
Added getShowLineChangeStats and setShowLineChangeStats TRPC procedures; new default constant DEFAULT_SHOW_LINE_CHANGE_STATS = true.
Database Schema
packages/local-db/drizzle/0037_add_show_line_change_stats_setting.sql, packages/local-db/drizzle/meta/0037_snapshot.json, packages/local-db/drizzle/meta/_journal.json, packages/local-db/src/schema/schema.ts
Added show_line_change_stats nullable boolean column to settings table; updated Drizzle ORM schema and migration metadata.
Settings Search & Configuration
apps/desktop/src/renderer/routes/_authenticated/settings/utils/settings-search/settings-search.ts, apps/desktop/src/renderer/routes/_authenticated/settings/utils/settings-search/settings-search.test.ts
Added BEHAVIOR_SHOW_LINE_CHANGE_STATS setting item with title, description, and keywords; verified via searchability test.
Behavior Settings UI
apps/desktop/src/renderer/routes/_authenticated/settings/behavior/components/BehaviorSettings/BehaviorSettings.tsx
Integrated new toggle for "Show lines changed" with TRPC query/mutation, optimistic updates, and conditional visibility gating.
Sidebar Components
apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/DashboardSidebar/.../DashboardSidebarWorkspaceItem/DashboardSidebarWorkspaceItem.tsx, apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/DashboardSidebar/.../DashboardSidebarExpandedWorkspaceRow/DashboardSidebarExpandedWorkspaceRow.tsx, apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/WorkspaceListItem.tsx, apps/desktop/src/renderer/screens/main/components/WorkspacesListView/WorkspaceRow/WorkspaceRow.tsx
Fetch showLineChangeStats setting via TRPC query and conditionally render diff-stats UI based on setting value (default: enabled).
Changes View Components & Hooks
apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/ChangesView/ChangesView.tsx, apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/ChangesView/components/CommitItem/CommitItem.tsx, apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/ChangesView/hooks/useOrderedSections/useOrderedSections.tsx, apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/ChangesView/hooks/useOrderedSections/useOrderedSections.test.tsx
Thread showLineChangeStats setting through hook and component chain to conditionally render file stats in commit/staged/unstaged sections; added test case verifying prop forwarding.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 A toggle born from whispered wish,
To hide or show the diff-stat dish,
Through sidebars wide and changes deep,
The line counts now—a secret to keep!
With queries quick and settings neat,
Stats display—on every beat! 📊✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

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.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The PR title 'feat(desktop): add setting to disable sidebar line-change stats' clearly and specifically describes the main change: adding a new setting to control the visibility of line-change statistics in sidebars.
Description check ✅ Passed The PR description is well-structured and comprehensive, covering the summary of changes, related settings/behavior, verification steps, and a screenshot. It follows the repository's description template with clear sections for Description, Type of Change, Testing, and Screenshots.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

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.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 17 files


Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Add one-off context when rerunning by tagging @cubic-dev-ai with guidance or docs links (including llms.txt)
  • Ask questions if you need clarification on any suggestion

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.

🧹 Nitpick comments (1)
apps/desktop/src/renderer/routes/_authenticated/settings/utils/settings-search/settings-search.test.ts (1)

65-70: Consider reorganizing the test into its own describe block.

The new test for "lines changed" is placed within the "settings search - font settings" describe block, but it's testing a behavior setting rather than font settings. This is a minor organizational concern.

♻️ Suggested reorganization
 describe("settings search - font settings", () => {
   // ... existing font-related tests ...
-
-	it('searching "lines changed" returns the behavior toggle for sidebar stats', () => {
-		const results = searchSettings("lines changed");
-		const ids = getIds(results);
-		expect(ids).toContain(SETTING_ITEM_ID.BEHAVIOR_SHOW_LINE_CHANGE_STATS);
-	});
 });
+
+describe("settings search - behavior settings", () => {
+	it('searching "lines changed" returns the behavior toggle for sidebar stats', () => {
+		const results = searchSettings("lines changed");
+		const ids = getIds(results);
+		expect(ids).toContain(SETTING_ITEM_ID.BEHAVIOR_SHOW_LINE_CHANGE_STATS);
+	});
+});
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@apps/desktop/src/renderer/routes/_authenticated/settings/utils/settings-search/settings-search.test.ts`
around lines 65 - 70, The test that calls searchSettings("lines changed") and
asserts SETTING_ITEM_ID.BEHAVIOR_SHOW_LINE_CHANGE_STATS is misplaced in the
"settings search - font settings" describe; move this it(...) into its own
describe block (e.g., "settings search - behavior settings") or create a new
describe specifically for behavior-related searches so the test and any future
behavior tests are grouped logically; update or add a describe wrapper around
the test containing the existing it(...) that uses searchSettings, getIds, and
SETTING_ITEM_ID.BEHAVIOR_SHOW_LINE_CHANGE_STATS.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In
`@apps/desktop/src/renderer/routes/_authenticated/settings/utils/settings-search/settings-search.test.ts`:
- Around line 65-70: The test that calls searchSettings("lines changed") and
asserts SETTING_ITEM_ID.BEHAVIOR_SHOW_LINE_CHANGE_STATS is misplaced in the
"settings search - font settings" describe; move this it(...) into its own
describe block (e.g., "settings search - behavior settings") or create a new
describe specifically for behavior-related searches so the test and any future
behavior tests are grouped logically; update or add a describe wrapper around
the test containing the existing it(...) that uses searchSettings, getIds, and
SETTING_ITEM_ID.BEHAVIOR_SHOW_LINE_CHANGE_STATS.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1fbb9d8e-842b-4d74-9c6c-dfaee0215ace

📥 Commits

Reviewing files that changed from the base of the PR and between 0bc069e and 1ea2271.

📒 Files selected for processing (17)
  • apps/desktop/src/lib/trpc/routers/settings/index.ts
  • apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/DashboardSidebar/components/DashboardSidebarWorkspaceItem/DashboardSidebarWorkspaceItem.tsx
  • apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/DashboardSidebar/components/DashboardSidebarWorkspaceItem/components/DashboardSidebarExpandedWorkspaceRow/DashboardSidebarExpandedWorkspaceRow.tsx
  • apps/desktop/src/renderer/routes/_authenticated/settings/behavior/components/BehaviorSettings/BehaviorSettings.tsx
  • apps/desktop/src/renderer/routes/_authenticated/settings/utils/settings-search/settings-search.test.ts
  • apps/desktop/src/renderer/routes/_authenticated/settings/utils/settings-search/settings-search.ts
  • apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/WorkspaceListItem.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/ChangesView/ChangesView.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/ChangesView/components/CommitItem/CommitItem.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/ChangesView/hooks/useOrderedSections/useOrderedSections.test.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/ChangesView/hooks/useOrderedSections/useOrderedSections.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspacesListView/WorkspaceRow/WorkspaceRow.tsx
  • apps/desktop/src/shared/constants.ts
  • packages/local-db/drizzle/0037_add_show_line_change_stats_setting.sql
  • packages/local-db/drizzle/meta/0037_snapshot.json
  • packages/local-db/drizzle/meta/_journal.json
  • packages/local-db/src/schema/schema.ts

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