Skip to content

Dead code removal 2#78

Merged
GT-610 merged 4 commits into
mainfrom
dead-code-removal-2
Jun 2, 2026
Merged

Dead code removal 2#78
GT-610 merged 4 commits into
mainfrom
dead-code-removal-2

Conversation

@GT-610

@GT-610 GT-610 commented Jun 2, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • Bug Fixes

    • Improved peers-fetching error handling in download task details.
    • Fixed selection pruning behavior in download page.
  • Refactor

    • Removed build mode definitions and debug override system.
    • Simplified logging to basic formatted output.
    • Removed URL launcher and throttle utility functions.
    • Reduced platform detection to desktop platforms only.
    • Streamlined UI style constants (retained core text and spacing styles).
    • Removed value-listenable builder utilities.
    • Instance dialog no longer uses save callbacks; returns instance directly.
    • Window frame caption now depends solely on desktop platform detection.

GT-610 added 2 commits June 2, 2026 17:19
Remove unused code identified by deep scan:
- Delete kit/core/func.dart (Fns.throttle unused)
- Delete kit/core/build.dart (BuildMode unused after dprint removal)
- Delete kit/core/ext/string.dart (StringX.launchUrl unused)
- Remove dprint/lprint and unused Loggers.root/store/route/app from logger.dart
- Remove nullOr() extension and nvn() function from obj.dart
- Remove RNodeX.listen(), ValBuilder, listenVal(), EmptyListenable, RNodes from rnode.dart
- Remove WindowFrameConfig.setShowCaption() (never called)
- Remove unused platform constants: isAndroid, isIOS, isWeb, isMobile
- Remove ~20 unused UIs style constants (keep textGrey, textRed, text15, placeholder, height13)
- Remove InstanceDialog.onSave parameter and dead branch in _submit
- Clean up barrel exports in kit.dart
Performance:
- Extract _statusOrder Map to static const (avoids allocation per comparison)
- Extract _compareIgnoreCase helper for case-insensitive sort

Code quality:
- Move _pruneSelection mutation inside setState callback
- Move peers fetch state mutations inside setState in task_details_dialog
- Remove no-op empty setState in instance_dialog host/port onChange handlers
@coderabbitai

coderabbitai Bot commented Jun 2, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@GT-610, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 31 minutes and 22 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: bf540a02-1f47-406b-8bf5-ff2b7d67a96e

📥 Commits

Reviewing files that changed from the base of the PR and between 9fd36fd and 0ab258e.

📒 Files selected for processing (1)
  • lib/pages/download_page/components/task_details_dialog.dart
📝 Walkthrough

Walkthrough

This PR systematically simplifies the setsuna kit package and refactors dialog state management patterns. It removes unused utilities (BuildMode enum, Fns throttle, logger setup, extensions), refactors platform detection constants, minimizes UI resources, and eliminates builder helpers from RNode. Dialog state updates are modernized to use explicit setState calls instead of conditional rebuilds, and instance dialogs no longer rely on callbacks for result passing.

Changes

Kit Package API Cleanup

Layer / File(s) Summary
Core extensions and utility removals
lib/kit/core/ext/obj.dart, lib/kit/core/ext/string.dart, lib/kit/core/logger.dart, lib/kit/kit.dart
ObjectXNullable loses nullOr helper, StringX extension with launchUrl() is removed, logger module drops Logger instances and debug helpers (dprint, lprint), and kit barrel exports are updated to remove deprecated exports.
Platform detection constants refactoring
lib/kit/core/platform.dart
Mobile platform flags (isAndroid, isIOS, isWeb, isMobile) are removed and replaced with desktop platform flags (isLinux, isMacOS, isWindows) derived from Pfs.type.
UI resources minimization
lib/kit/res/ui.dart
UIs class is reduced to five constants (text15, textGrey, textRed, placeholder, height13), removing numerous TextStyle variants, dimension constants, and utility methods like dot() and centerLoading.
RNode builder utilities removal
lib/kit/core/rnode.dart
RNodeX extension with listen() builder, ValueListenableX extension with listenVal(), and helper classes (ValBuilder, ListenBuilder, EmptyListenable, RNodes) are removed.
Window frame caption configuration simplification
lib/kit/widgets/virtual_window_frame.dart
WindowFrameConfig.showCaption now depends only on isDesktop platform flag, removing the previous _showCaption toggle and setShowCaption() method.

Dialog State Management Improvements

Layer / File(s) Summary
Instance dialog callback removal and submit logic
lib/pages/instance_page/components/instance_dialog.dart
InstanceDialog removes onSave callback parameter, _submit() pops the dialog directly with the created/updated instance, and host/port field error handlers now explicitly clear error state via setState instead of triggering empty rebuilds.
Task details dialog peers and tab handling
lib/pages/download_page/components/task_details_dialog.dart
Peers-fetch flow now uses explicit setState in success and error paths to update peersError and isLoadingPeers, and tab-change listener moves currentTabIndex update into setState with immediate forced peer fetch.
Download page selection pruning state updates
lib/pages/download_page/download_page.dart
_pruneSelection() now unconditionally wraps removeWhere in setState instead of conditionally rebuilding only when selection size changed and widget is mounted.

Download Service Optimization

Layer / File(s) Summary
Task sorting extraction and optimization
lib/services/download_data_service.dart
_compareTasks refactoring extracts status order as static const _statusOrder map and delegates name comparison to private _compareIgnoreCase helper for case-insensitive string ordering.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Dead code removal 2' accurately describes the PR's main objective of removing unused code and simplifying the codebase across multiple files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

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


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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 `@lib/pages/download_page/components/task_details_dialog.dart`:
- Around line 225-233: fetchPeersIfNeeded() leaves isLoadingPeers true on early
returns and calls setState after dispose; refactor so the peers cleanup
(clearing isLoadingPeers and updating peersError/peers list) runs in a finally
block that updates state only if the widget/context is still mounted.
Concretely: wrap the peersClient!.getPeers(...) call in try/catch and capture
results into local variables (e.g., peersResult and peersErrorLocal), handle
instance == null by setting peersErrorLocal and skipping the fetch, then in a
finally block do if (context.mounted) setState(() { peersError =
peersErrorLocal; isLoadingPeers = false; peers = peersResult; }); and remove the
duplicated setState calls inside try/catch so setState is only invoked once in
the finally block; ensure you reference fetchPeersIfNeeded(),
disposeResources(), peersClient!.getPeers(), peersError and isLoadingPeers in
your edits.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b94c971d-ca26-4b83-a474-afbb0780c1df

📥 Commits

Reviewing files that changed from the base of the PR and between 1a43f8f and 9fd36fd.

📒 Files selected for processing (14)
  • lib/kit/core/build.dart
  • lib/kit/core/ext/obj.dart
  • lib/kit/core/ext/string.dart
  • lib/kit/core/func.dart
  • lib/kit/core/logger.dart
  • lib/kit/core/platform.dart
  • lib/kit/core/rnode.dart
  • lib/kit/kit.dart
  • lib/kit/res/ui.dart
  • lib/kit/widgets/virtual_window_frame.dart
  • lib/pages/download_page/components/task_details_dialog.dart
  • lib/pages/download_page/download_page.dart
  • lib/pages/instance_page/components/instance_dialog.dart
  • lib/services/download_data_service.dart
💤 Files with no reviewable changes (9)
  • lib/kit/core/platform.dart
  • lib/kit/core/build.dart
  • lib/kit/core/func.dart
  • lib/kit/core/ext/string.dart
  • lib/kit/res/ui.dart
  • lib/kit/kit.dart
  • lib/kit/core/rnode.dart
  • lib/kit/core/ext/obj.dart
  • lib/kit/core/logger.dart

Comment thread lib/pages/download_page/components/task_details_dialog.dart Outdated
GT-610 added 2 commits June 2, 2026 17:47
- Replace early return on instance==null with local error variable
- Move setState into finally block with context.mounted guard
- Use local peersResult/peersErrorLocal to avoid duplicated setState
@GT-610 GT-610 merged commit d5cf274 into main Jun 2, 2026
2 checks passed
@GT-610 GT-610 deleted the dead-code-removal-2 branch June 2, 2026 10:08
@coderabbitai coderabbitai Bot mentioned this pull request Jun 7, 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