Mastersam07 / Mastersam07/kaisel

refactor: decompose the KaiselRouterDelegate monolith

Open
#54 0 comments 0 reactions 1 assignee View on GitHub

@Mastersam07 is already working on this.

Since Jul 20, 2026.

enhancement pkg:kaisel
Dominant language
Dart
Stars
69
Forks
2
Avg merge
18m
Merged PRs (30d)
9

Description

[authored by Randal, assisted by Gemini]

## Problem
`KaiselRouterDelegate` in `packages/kaisel/lib/src/kaisel_router_delegate.dart` is currently a monolithic class spanning over 1,100 lines:

https://github.com/Mastersam07/kaisel/blob/dev/packages/kaisel/lib/src/kaisel_router_delegate.dart

It has multiple responsibilities mixed into a single class:
- Core widget subtree rendering (`Navigator` and `modalBuilder`).
- Deep-linking & State Restoration (`restorationScopeId`).
- System-back and Android predictive back navigation handling.
- Web browser transition configurations.
- DevTools Inspector registrations and hook tracking.
- Nested routing registrations (`KaiselNestedHost`).

This large footprint makes the class difficult to test in isolation, maintain, and audit as the codebase scales.

## Proposed Solution
Refactor and modularize `KaiselRouterDelegate` by delegating single responsibilities to separate helper classes, mixins, or extensions:

- **State Restoration**: Pull out state restoration logic into a dedicated helper class (e.g., `KaiselRestorationHelper`) or mixin.
- **Back Navigation Handling**: Move predictive back and pop handling to a separate class/mixin.
- **Inspector / DevTools Tracking**: Decouple the DevTools registry hooks.
- **Nested Host Registry**: Move tracking of active inner navigators/branches out of the main delegate.

By separating these concerns, the core delegate can focus primarily on listening to the router and rendering the widget tree.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.