|
| 1 | +# FLUTTER AGENT PANEL - PROJECT KNOWLEDGE BASE |
| 2 | + |
| 3 | +**Generated:** 2026-01-08 |
| 4 | +**Commit:** b8ef0c5 |
| 5 | +**Branch:** main |
| 6 | + |
| 7 | +## OVERVIEW |
| 8 | +Cross-platform desktop terminal aggregator with AI agent integration. Built with Flutter + shadcn_ui, using BLoC/HydratedBloc for state persistence. |
| 9 | + |
| 10 | +## STRUCTURE |
| 11 | +``` |
| 12 | +flutter_agent_panel/ |
| 13 | +├── lib/ |
| 14 | +│ ├── main.dart # Entry: error handling, HydratedStorage init |
| 15 | +│ ├── app.dart # Root widget: MultiBlocProvider, theming |
| 16 | +│ ├── core/ # Cross-cutting: services, router, l10n, extensions |
| 17 | +│ ├── features/ # Feature modules (BLoC pattern) |
| 18 | +│ │ ├── home/ # App shell layout |
| 19 | +│ │ ├── info/ # About/Help dialogs |
| 20 | +│ │ ├── settings/ # App configuration (879-line dialog) |
| 21 | +│ │ ├── terminal/ # PTY management, themes |
| 22 | +│ │ └── workspace/ # Multi-workspace organization |
| 23 | +│ └── shared/ # Utils, constants, common widgets |
| 24 | +├── packages/ |
| 25 | +│ ├── flutter_pty/ # FFI PTY bindings (ConPTY/POSIX) |
| 26 | +│ └── xterm/ # Terminal emulator core (60fps render) |
| 27 | +└── assets/ # Images, agent logos |
| 28 | +``` |
| 29 | + |
| 30 | +## WHERE TO LOOK |
| 31 | + |
| 32 | +| Task | Location | Notes | |
| 33 | +|------|----------|-------| |
| 34 | +| Add new feature | `lib/features/{name}/` | Create bloc/, models/, views/, widgets/ | |
| 35 | +| Modify theming | `lib/app.dart` | ShadThemeData, colorScheme switching | |
| 36 | +| Add localization | `lib/core/l10n/` | ARB files, regenerate with `flutter gen-l10n` | |
| 37 | +| Configure routing | `lib/core/router/app_router.dart` | AutoRoute, regenerate with `lean_builder` | |
| 38 | +| Add service | `lib/core/services/` | Singleton pattern, init in main.dart | |
| 39 | +| Terminal rendering | `packages/xterm/lib/src/ui/` | Custom RenderBox, pixel-aligned painting | |
| 40 | +| PTY native code | `packages/flutter_pty/src/` | C files per platform | |
| 41 | + |
| 42 | +## CONVENTIONS |
| 43 | + |
| 44 | +### State Management |
| 45 | +- **HydratedBloc** for persistent state (workspace, settings) |
| 46 | +- **Regular Bloc** for ephemeral state (terminal instances) |
| 47 | +- Event/State in `part` files: `{name}_event.dart`, `{name}_state.dart` |
| 48 | +- Always use `.copyWith()` for immutable updates |
| 49 | + |
| 50 | +### UI Patterns |
| 51 | +- **shadcn_ui** components: ShadDialog, ShadSelect, ShadInput, ShadTooltip |
| 52 | +- **Context extensions**: `context.theme`, `context.t` (localization) |
| 53 | +- **LucideIcons** throughout |
| 54 | +- **Gap** widgets for spacing (not SizedBox) |
| 55 | + |
| 56 | +### Code Style |
| 57 | +- Single quotes for strings |
| 58 | +- Trailing commas required |
| 59 | +- Relative imports within lib/ |
| 60 | +- `@pragma('vm:prefer-inline')` on hot paths (xterm painter) |
| 61 | + |
| 62 | +## ANTI-PATTERNS (THIS PROJECT) |
| 63 | + |
| 64 | +| Forbidden | Reason | |
| 65 | +|-----------|--------| |
| 66 | +| Direct list mutation | Use `.copyWith()` or create new list | |
| 67 | +| Heavy logic in `build()` | Move to Bloc or extract methods | |
| 68 | +| Inline sorting | Delegate to Bloc events | |
| 69 | +| Hardcoded strings | Use `context.t` localized strings | |
| 70 | +| Manual mock edits | `*.mocks.dart` are generated | |
| 71 | +| `flutter_pty_bindings_generated.dart` edits | Auto-generated by ffigen | |
| 72 | +| Sub-pixel offsets in painter | Use `roundToDouble()` for crispness | |
| 73 | +| Blocking PTY calls on main isolate | Use dedicated isolates | |
| 74 | + |
| 75 | +## COMMANDS |
| 76 | +```bash |
| 77 | +# Development |
| 78 | +flutter pub get |
| 79 | +dart run lean_builder build # Generate routes |
| 80 | +flutter gen-l10n # Generate localizations |
| 81 | +flutter run -d windows # Run on Windows |
| 82 | + |
| 83 | +# Packages (run from package dir) |
| 84 | +flutter pub run ffigen --config ffigen.yaml # Regenerate PTY bindings |
| 85 | + |
| 86 | +# Build |
| 87 | +flutter build windows |
| 88 | +flutter build macos |
| 89 | +flutter build linux |
| 90 | +``` |
| 91 | + |
| 92 | +## NOTES |
| 93 | + |
| 94 | +### Desktop-Only |
| 95 | +No Android/iOS directories - configured for Windows, macOS, Linux only. |
| 96 | + |
| 97 | +### Monorepo Structure |
| 98 | +Uses Flutter workspace with local packages: |
| 99 | +- `packages/xterm` - forked/customized terminal emulator |
| 100 | +- `packages/flutter_pty` - native PTY bindings |
| 101 | + |
| 102 | +### Large File Hotspots |
| 103 | +- `settings_dialog.dart` (879 lines) - Tab-based settings UI |
| 104 | +- `workspace_drawer.dart` (541 lines) - Drag-drop with pin constraints |
| 105 | +- `terminal_bloc.dart` (434 lines) - Cross-platform shell handling |
| 106 | + |
| 107 | +### Platform-Specific Shell Logic |
| 108 | +Terminal creation handles: PowerShell, pwsh, cmd, WSL, bash, zsh. See `TerminalServiceImpl` and `TerminalBloc._createTerminalNode()`. |
| 109 | + |
| 110 | +### Inter-Feature Dependencies |
| 111 | +``` |
| 112 | +workspace → terminal (TerminalConfig model) |
| 113 | +settings → terminal (font/theme models) |
| 114 | +terminal → flutter_pty, xterm packages |
| 115 | +``` |
0 commit comments