Skip to content

chore: clean up unused code and add CI checks#33

Closed
cogwheel0 wants to merge 1 commit intomainfrom
codex/analyze-codebase-for-unused-components
Closed

chore: clean up unused code and add CI checks#33
cogwheel0 wants to merge 1 commit intomainfrom
codex/analyze-codebase-for-unused-components

Conversation

@cogwheel0
Copy link
Owner

@cogwheel0 cogwheel0 commented Aug 22, 2025

Summary

  • remove unused dependencies and orphaned components
  • add CI workflow to run analyzer, dependency validator, code metrics, and tests

Testing

  • dart pub get
  • dart analyze
  • ~/.pub-cache/bin/dependency_validator
  • flutter test (fails: Test directory "test" not found.)

https://chatgpt.com/codex/tasks/task_e_68a8b49d0e608324a1c4c89019bae0de

Summary by CodeRabbit

  • Refactor

    • Removed deep-link navigation and navigation state persistence.
    • Removed chat UI components (conversation list, archived view, batch actions).
    • Removed file viewer, folder and tag management dialogs.
    • Removed server management flows (add/delete/set active server).
    • Removed keyboard utilities, cached image/avatar widgets, and empty/error state components.
    • Removed centralized error handling and recovery features.
  • Chores

    • Added CI workflow to run static analysis, dependency checks, code metrics, and tests on pushes and pull requests.

@coderabbitai
Copy link

coderabbitai bot commented Aug 22, 2025

Walkthrough

Adds a GitHub Actions CI workflow. Removes multiple Dart/Flutter services, providers, widgets, and utilities across core, chat, server, and shared modules. Updates pubspec.yaml by removing four dependencies. No other files are modified.

Changes

Cohort / File(s) Summary
CI Workflow
.github/workflows/ci.yml
Added a CI workflow that checks out code, sets up Flutter 3.35.0 (stable), runs pub get, static analysis (dart analyze), dependency validation, code metrics, and conditional tests.
Core Services Removal
lib/core/services/deep_link_service.dart, lib/core/services/error_handling_service.dart, lib/core/services/error_recovery_service.dart, lib/core/services/focus_management_service.dart, lib/core/services/navigation_state_service.dart
Deleted deep-linking, error handling, error recovery (with retry/backoff), focus management, and navigation state persistence services, including their public APIs and providers.
Chat UI/Providers Removal
lib/features/chat/providers/attachment_cache_provider.dart, lib/features/chat/widgets/conversation_components.dart, lib/features/chat/widgets/file_viewer_dialog.dart, lib/features/chat/widgets/folder_management_dialog.dart, lib/features/chat/widgets/message_batch_widget.dart, lib/features/chat/widgets/tag_management_dialog.dart
Deleted attachment cache provider and multiple chat widgets/dialogs (conversation tiles, archived view, file viewer, folder management, message batch ops, tag management) with associated providers and logic.
Server Providers Removal
lib/features/server/providers/server_providers.dart
Deleted server management providers for adding, deleting, and activating servers tied to storage.
Shared Utils & Widgets Removal
lib/shared/utils/keyboard_utils.dart, lib/shared/widgets/cached_image.dart, lib/shared/widgets/empty_states.dart, lib/shared/widgets/error_widgets.dart
Deleted keyboard utilities and shared widgets for cached images/avatars, empty states, and error displays.
Dependencies Update
pubspec.yaml
Removed dependencies: highlight, collection, cupertino_icons, json_annotation.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant GH as GitHub
  participant Runner as Actions Runner (ubuntu-latest)
  participant Flutter as Flutter SDK 3.35.0
  participant Repo as Repository

  GH->>Runner: Trigger CI (push to main / PR)
  Runner->>Repo: actions/checkout
  Runner->>Flutter: setup-flutter (stable 3.35.0)
  Runner->>Flutter: flutter pub get
  Runner->>Flutter: dart analyze
  Runner->>Flutter: dependency_validator
  Runner->>Flutter: dart_code_metrics: metrics analyze lib
  alt tests directory exists
    Runner->>Flutter: flutter test
  else no tests
    Runner->>Runner: echo "No tests found"
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

A rabbit taps CI with careful paws,
While pruning code with tidy claws.
Widgets hop away, providers too—
The garden’s light, the pathways new.
With fewer trails and clearer sky,
The burrow builds, and tests run by. 🐇✨

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/analyze-codebase-for-unused-components

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@cogwheel0 cogwheel0 marked this pull request as ready for review August 22, 2025 18:43
Copy link

@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: 2

🧹 Nitpick comments (6)
.github/workflows/ci.yml (6)

13-17: Confirm Flutter version or follow latest stable; enable SDK caching

Pinning to '3.35.0' is fine if that version exists in releases. If not, the job will fail. Either verify the version is available or omit flutter-version to always pull latest on the stable channel. Also enable caching in the action for faster runs.

Option A (keep pin, add caching):

       - uses: subosito/flutter-action@v2
         with:
           flutter-version: '3.35.0'
           channel: 'stable'
+          cache: true

Option B (track latest stable, plus caching):

       - uses: subosito/flutter-action@v2
         with:
-          flutter-version: '3.35.0'
           channel: 'stable'
+          cache: true

26-28: Consider switching to the maintained DCM CLI and/or broaden analysis scope

If you’ve migrated to the newer “dcm” CLI, prefer it; otherwise the current invocation is OK. Also consider including test and tool directories if applicable.

Examples:

  • Keep as-is (no action needed).
  • Or migrate:
- name: Run code metrics
  run: |
    dart pub global activate dcm
    dart pub global run dcm analyze lib
    # Optionally: add test tool
    # dart pub global run dcm analyze lib test

3-9: Add workflow concurrency to auto-cancel superseded runs

Prevents wasting CI minutes on outdated commits, especially for PRs.

 on:
   push:
     branches: [main]
   pull_request:
 
+concurrency:
+  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
+  cancel-in-progress: true
+
 jobs:

3-9: Tighten default permissions (principle of least privilege)

Unless you need write permissions (e.g., for release or labels), set minimal read permissions.

 on:
   push:
     branches: [main]
   pull_request:
 
+permissions:
+  contents: read
+
 jobs:

11-19: Cache Pub packages to speed up installs

Caching ~/.pub-cache cuts “pub get” time significantly across runs.

     steps:
       - uses: actions/checkout@v4
       - uses: subosito/flutter-action@v2
         with:
           flutter-version: '3.35.0'
           channel: 'stable'
+          cache: true
+      - name: Cache Pub cache
+        uses: actions/cache@v4
+        with:
+          path: ~/.pub-cache
+          key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.lock') }}
+          restore-keys: |
+            ${{ runner.os }}-pub-
       - name: Install dependencies
         run: flutter pub get

19-20: Optional: fail CI on infos/warnings from the analyzer

If you want stricter gates, enable fatal-infos and fatal-warnings.

-      - name: Run analyzer
-        run: dart analyze
+      - name: Run analyzer
+        run: dart analyze --fatal-infos --fatal-warnings
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 7f30b72 and 66771a5.

⛔ Files ignored due to path filters (1)
  • pubspec.lock is excluded by !**/*.lock
📒 Files selected for processing (18)
  • .github/workflows/ci.yml (1 hunks)
  • lib/core/services/deep_link_service.dart (0 hunks)
  • lib/core/services/error_handling_service.dart (0 hunks)
  • lib/core/services/error_recovery_service.dart (0 hunks)
  • lib/core/services/focus_management_service.dart (0 hunks)
  • lib/core/services/navigation_state_service.dart (0 hunks)
  • lib/features/chat/providers/attachment_cache_provider.dart (0 hunks)
  • lib/features/chat/widgets/conversation_components.dart (0 hunks)
  • lib/features/chat/widgets/file_viewer_dialog.dart (0 hunks)
  • lib/features/chat/widgets/folder_management_dialog.dart (0 hunks)
  • lib/features/chat/widgets/message_batch_widget.dart (0 hunks)
  • lib/features/chat/widgets/tag_management_dialog.dart (0 hunks)
  • lib/features/server/providers/server_providers.dart (0 hunks)
  • lib/shared/utils/keyboard_utils.dart (0 hunks)
  • lib/shared/widgets/cached_image.dart (0 hunks)
  • lib/shared/widgets/empty_states.dart (0 hunks)
  • lib/shared/widgets/error_widgets.dart (0 hunks)
  • pubspec.yaml (0 hunks)
💤 Files with no reviewable changes (17)
  • pubspec.yaml
  • lib/features/chat/widgets/file_viewer_dialog.dart
  • lib/features/server/providers/server_providers.dart
  • lib/features/chat/widgets/message_batch_widget.dart
  • lib/features/chat/providers/attachment_cache_provider.dart
  • lib/core/services/focus_management_service.dart
  • lib/shared/widgets/cached_image.dart
  • lib/features/chat/widgets/folder_management_dialog.dart
  • lib/core/services/navigation_state_service.dart
  • lib/shared/widgets/error_widgets.dart
  • lib/core/services/error_recovery_service.dart
  • lib/core/services/deep_link_service.dart
  • lib/core/services/error_handling_service.dart
  • lib/features/chat/widgets/conversation_components.dart
  • lib/shared/utils/keyboard_utils.dart
  • lib/features/chat/widgets/tag_management_dialog.dart
  • lib/shared/widgets/empty_states.dart
🧰 Additional context used
🪛 actionlint (1.7.7)
.github/workflows/ci.yml

12-12: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🔇 Additional comments (1)
.github/workflows/ci.yml (1)

29-35: Nice: conditional tests prevent false-negative failures when no tests exist

The guard on the test directory aligns with the repo’s current lack of tests and avoids red CI for “directory not found.”

analyze-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Upgrade checkout action to v4 to avoid runner compatibility issues

actionlint flagged actions/checkout@v3 as too old for current runners. Switch to v4.

-      - uses: actions/checkout@v3
+      - uses: actions/checkout@v4
📝 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
- uses: actions/checkout@v3
- uses: actions/checkout@v4
🧰 Tools
🪛 actionlint (1.7.7)

12-12: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🤖 Prompt for AI Agents
In .github/workflows/ci.yml around line 12 the workflow uses actions/checkout@v3
which actionlint flagged as outdated; update the step to use actions/checkout@v4
by changing the version reference to v4 so the workflow runs on current GitHub
runners without compatibility issues and commit the updated workflow file.

Comment on lines +21 to +24
- name: Check unused dependencies
run: |
dart pub global activate dependency_validator
dependency_validator
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix dependency_validator invocation to avoid PATH pitfalls

Running the binary name directly can fail if ~/.pub-cache/bin isn’t on PATH in the runner. Use “dart pub global run …” which does not rely on PATH.

       - name: Check unused dependencies
         run: |
-          dart pub global activate dependency_validator
-          dependency_validator
+          dart pub global activate dependency_validator
+          dart pub global run dependency_validator
📝 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
- name: Check unused dependencies
run: |
dart pub global activate dependency_validator
dependency_validator
- name: Check unused dependencies
run: |
dart pub global activate dependency_validator
dart pub global run dependency_validator
🤖 Prompt for AI Agents
.github/workflows/ci.yml around lines 21 to 24: the workflow invokes the
dependency_validator binary directly which can fail if ~/.pub-cache/bin is not
on PATH in the runner; instead, after activating the package, call it via "dart
pub global run dependency_validator" so it runs through dart and does not rely
on PATH; update the run steps to use dart pub global run (keeping the activate
step) and ensure the command exits non‑zero on issues as before.

@cogwheel0 cogwheel0 closed this Aug 22, 2025
@cogwheel0 cogwheel0 deleted the codex/analyze-codebase-for-unused-components branch August 22, 2025 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant