[agent-guidance] Name DevTools shared helpers in .gemini/styleguide.md (#10041) * [agent-guidance] Name DevTools shared helpers in .gemini/styleguide.md Maintainers repeatedly ask for specific shared widgets and utilities (CenteredMessage, NotifierSwitch, MultiValueListenableBuilder, safeUnawaited, Logger, mockConnectedApp, ...). List them under Code Reuse & DRY so the review bot can suggest them. * Address review: narrow NotifierSwitch, add theme.dart constants and styles - Suggest NotifierSwitch only for a raw Switch nested inside a ValueListenableBuilder (what NotifierSwitch wraps). - Point at theme.dart constants and shared text styles instead of raw numbers or raw TextStyles.
diff --git a/.gemini/styleguide.md b/.gemini/styleguide.md index f4ecbab..624c4c8 100644 --- a/.gemini/styleguide.md +++ b/.gemini/styleguide.md
@@ -28,6 +28,20 @@ * **Maintainability**: Code should be easy to modify and extend without breaking other screens. * **Consistency**: Adhering to consistent style across all DevTools packages improves collaboration and reduces errors. * **Code Reuse & DRY**: Use shared primitives and components rather than recreating them from scratch. Flag duplicated code blocks (90%+ identical) and repeated sub-expressions or function calls within the same method as `[CONCERN]` or `[NIT]`, and suggest extracting them into local variables or constants. + Prefer these DevTools helpers when the diff re-creates them: + * `CenteredMessage` instead of `Center` + `Text`, and `NotifierSwitch` instead of a raw `Switch` + nested inside a `ValueListenableBuilder` (both from + `packages/devtools_app/lib/src/shared/ui/common_widgets.dart`). + * `MultiValueListenableBuilder` instead of nested `ValueListenableBuilder`s; a `ValueNotifier` + plus a builder instead of calling `markNeedsBuild`/`setState` by hand. + * `safeUnawaited(...)` for fire-and-forget futures; `addAutoDisposeListener(...)` for listeners. + * `Logger` instead of `debugPrint`. + * Constants and shared styles from `packages/devtools_app_shared/lib/src/ui/theme/theme.dart` + instead of raw numbers or raw `TextStyle`s: sizes and spacing such as `smallFontSize`, + `defaultSpacing`, and `defaultIconSize`, and text styles such as + `Theme.of(context).regularTextStyle`, `boldTextStyle`, and `subtleTextStyle`. + * In tests, existing helpers such as `mockConnectedApp` instead of hand-built mocks. + * A small `StatelessWidget` instead of a helper method that returns a widget. * **Constants & Magic Values**: Avoid using raw/magic strings or numbers. Extract them into descriptive named constants so the intent and meaning of the values are clear. * **Testing**: All changes should include automated tests to ensure correctness and prevent regressions. * **Release notes** (`packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md`):