Skip to content

Conversation

Potatomonsta
Copy link
Contributor

@Potatomonsta Potatomonsta commented Sep 24, 2025

Description

  • Create new packages/stac_core/lib/annotations/ directory
  • Add stac_screen.dart with @StacScreen annotation class
  • Add annotations.dart export file for the annotations package
  • Update core.dart to export annotations package

Breaking Changes:

  • Methods returning StacWidget must now be annotated with @StacScreen to be processed
  • Previously unannotated StacWidget-returning methods will no longer be automatically processed

Usage:

import 'package:stac_core/stac_core.dart';

@StacScreen('home')
StacWidget buildHomeScreen() => StacWidget();

Type of Change

  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Code refactor
  • Build configuration change
  • Documentation
  • Chore

Summary by CodeRabbit

  • New Features
    • Added a @StacScreen annotation (const StacScreen(screenName: ...)) for marking screen-producing methods.
    • Annotation is exported from the annotations module and re-exported via core and top-level package so it’s available from main imports.
    • Simplified imports for users by exposing the annotation through primary package entry points.
    • Includes documentation and a usage example.

Copy link

coderabbitai bot commented Sep 24, 2025

Walkthrough

Adds a new StacScreen annotation class, creates an annotations library barrel (library; + export), and re-exports that barrel from core/core.dart and the package top-level stac_core.dart, extending the package's public API surface.

Changes

Cohort / File(s) Summary of changes
Annotations barrel
packages/stac_core/lib/annotations/annotations.dart
Added a library; directive and export 'stac_screen.dart';.
New annotation
packages/stac_core/lib/annotations/stac_screen.dart
Added StacScreen annotation: const StacScreen({required this.screenName}); with final String screenName;.
Core barrel exports
packages/stac_core/lib/core/core.dart
Added export '../annotations/annotations.dart';.
Top-level barrel exports
packages/stac_core/lib/stac_core.dart
Added export 'annotations/annotations.dart';.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant App as Consumer code
  participant Top as stac_core.dart (barrel)
  participant Core as core/core.dart (barrel)
  participant Anns as annotations/annotations.dart (barrel)
  participant Screen as stac_screen.dart

  Note over App,Top: Prior usage: imported barrels to access widgets/actions
  App->>Top: import 'package:stac_core/stac_core.dart'
  Top->>Core: re-exports existing core symbols
  Core->>Top: (re-exported)

  Note over Top,Anns: New re-export chain
  Top->>Anns: re-export annotations/annotations.dart
  Core->>Anns: re-export ../annotations/annotations.dart
  Anns->>Screen: export 'stac_screen.dart'
  App->>Screen: uses @StacScreen(...) via top-level barrel
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I hop with a label, tiny tag on the green,
A StacScreen named softly, tidy and keen.
Barrels link like burrows, exports snug and neat,
I nibble at the code—new pathways are sweet. 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly describes the key changes—adding the StacScreen annotation, introducing an annotations barrel, and updating existing barrels for re-exports—which directly reflects the primary work in this PR.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch mn/stac-screen-annotation-cli

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2203430 and ecc851d.

📒 Files selected for processing (4)
  • packages/stac_core/lib/annotations/annotations.dart (1 hunks)
  • packages/stac_core/lib/annotations/stac_screen.dart (1 hunks)
  • packages/stac_core/lib/core/core.dart (1 hunks)
  • packages/stac_core/lib/stac_core.dart (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/stac_core/lib/stac_core.dart
🔇 Additional comments (3)
packages/stac_core/lib/core/core.dart (1)

5-5: LGTM — forwarding the annotations barrel makes sense

Re-exporting the annotations package from the core barrel keeps the public surface cohesive.

packages/stac_core/lib/annotations/stac_screen.dart (1)

14-19: LGTM — annotation API looks solid

Constructor and field shape the metadata exactly as needed for consumer lookups. Nicely documented as well.

packages/stac_core/lib/annotations/annotations.dart (1)

1-3: Fix invalid bare library; directive

A standalone library; directive is a syntax error and will break analysis/compilation. Drop it (or replace it with a properly named library directive) so the annotations barrel parses correctly.

Apply this diff:

-library;

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai bot changed the title @coderabbitai Add StacScreen annotation and annotations barrel; re-export in barrels Sep 24, 2025
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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/stac_core/lib/core/core.dart (1)

1-1: Invalid library; directive

Same issue here: remove or name the library.

Apply this diff:

-library;
+
🧹 Nitpick comments (2)
packages/stac_core/lib/stac_core.dart (1)

4-4: Export looks good; watch for redundant re‑exports

This is fine. Note core/core.dart also re‑exports annotations; consider keeping only one path to avoid redundancy in the public API surface.

packages/stac_core/lib/core/core.dart (1)

5-5: Re‑export is OK, but it duplicates top‑level export

This makes annotations available via core/, which is fine. Since stac_core.dart also exports annotations, decide if you want both or a single canonical export path.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0cf7c4b and b4adb45.

📒 Files selected for processing (4)
  • packages/stac_core/lib/annotations/annotations.dart (1 hunks)
  • packages/stac_core/lib/annotations/stac_screen.dart (1 hunks)
  • packages/stac_core/lib/core/core.dart (1 hunks)
  • packages/stac_core/lib/stac_core.dart (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: analyze
🔇 Additional comments (3)
packages/stac_core/lib/annotations/annotations.dart (1)

3-3: LGTM: barrel export

Exporting stac_screen.dart from the annotations barrel looks good.

packages/stac_core/lib/annotations/stac_screen.dart (2)

14-20: Solid minimal annotation

Const, final field, and clear docs are good.


14-20: Constrain usage and validate input (non‑breaking enhancements)

Limit where the annotation can be applied and guard against empty names; add the meta import and dependency, and update any functions that should be annotated (examples/stac_gallery/lib/main.dart:60 currently returns StacWidget without @StacScreen).

Apply this diff to packages/stac_core/lib/annotations/stac_screen.dart:

+@Target({TargetKind.method, TargetKind.function})
 class StacScreen {
   /// Creates a [StacScreen] annotation with the given screen name.
-  const StacScreen(this.name);
+  const StacScreen(this.name) : assert(name.isNotEmpty, 'StacScreen name must be non-empty');
 
   /// The name identifier for this screen.
   final String name;
 }

Add at the top of that file:

import 'package:meta/meta_meta.dart';

Add meta to packages/stac_core/pubspec.yaml under dependencies. Annotate any StacWidget-returning functions that represent screens (e.g., examples/stac_gallery/lib/main.dart:60).

@@ -0,0 +1,20 @@
/// Annotation to mark methods that return StacWidget instances.
///
/// This annotation is used to identify screen-level widgets in the STAC framework.
Copy link
Member

Choose a reason for hiding this comment

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

Do not make Stac all caps, use "Stac"

const StacScreen(this.name);

/// The name identifier for this screen.
final String name;
Copy link
Member

Choose a reason for hiding this comment

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

Should we call this variable "routeName" as we are using the same name in Stac() class when fetching the screen? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

routename conflicts with flutter routes no?
maybe we should make it stacRouteName @divyanshub024?

@Potatomonsta Potatomonsta force-pushed the mn/stac-screen-annotation-cli branch from b4adb45 to 2203430 Compare September 24, 2025 17:02
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: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/stac_core/lib/core/core.dart (1)

1-1: Unnamed library; directive is invalid Dart.

Either remove the directive or give it a proper name (e.g., library stac_core.core;). Leaving it as library; will not parse.

🧹 Nitpick comments (2)
packages/stac_core/lib/annotations/stac_screen.dart (1)

1-13: Polish dartdoc: link types and tighten example.

  • Link to symbols so dartdoc auto-links.
  • Use a concise arrow function in the example.

Apply this diff:

-/// Annotation to mark methods that return StacWidget instances.
+/// Annotation to mark methods that return [StacWidget] instances.
@@
-/// Methods that return StacWidget should be annotated with this to indicate
+/// Methods that return [StacWidget] should be annotated with this to indicate
@@
-/// StacWidget buildHomeScreen() {
-///   return StacWidget(jsonData: {'type': 'scaffold', 'body': '...'});
-/// }
+/// StacWidget buildHomeScreen() =>
+///     StacWidget(jsonData: {'type': 'scaffold', 'body': '...'});
packages/stac_core/lib/core/core.dart (1)

5-5: Remove redundant annotation export: In packages/stac_core/lib/core/core.dart (line 5), drop export '../annotations/annotations.dart'; — it’s already re-exported in lib/stac_core.dart.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b4adb45 and 2203430.

📒 Files selected for processing (4)
  • packages/stac_core/lib/annotations/annotations.dart (1 hunks)
  • packages/stac_core/lib/annotations/stac_screen.dart (1 hunks)
  • packages/stac_core/lib/core/core.dart (1 hunks)
  • packages/stac_core/lib/stac_core.dart (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/stac_core/lib/annotations/annotations.dart
  • packages/stac_core/lib/stac_core.dart
🔇 Additional comments (1)
packages/stac_core/lib/annotations/stac_screen.dart (1)

19-19: Name alignment: consider routeName (or stacRouteName) for consistency.

Prior feedback suggested routeName to match the Stac() class usage; author raised Flutter route collision concerns and proposed stacRouteName. Pick one and use consistently across docs/APIs.

Example diff if choosing routeName:

-  const StacScreen(this.screenName);
+  const StacScreen(this.routeName);
@@
-  final String screenName;
+  final String routeName;

Comment on lines 14 to 20
class StacScreen {
/// Creates a [StacScreen] annotation with the given screen name.
const StacScreen(this.screenName);

/// The name identifier for this screen.
final String screenName;
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

🧩 Analysis chain

Restrict where the annotation can be applied (methods only).

Add @Target({TargetKind.method}) to prevent accidental usage on classes/fields. Requires package:meta.

If meta isn’t already a dep, add it. Then:

+import 'package:meta/meta_meta.dart';
+
+@Target({TargetKind.method})
 class StacScreen {
   /// Creates a [StacScreen] annotation with the given screen name.
   const StacScreen(this.screenName);
@@
   /// The name identifier for this screen.
   final String screenName;
 }

Verify meta availability:


🏁 Script executed:

#!/bin/bash
rg -nP '^\s*meta\s*:' pubspec.yaml -n -C2 || rg -nP 'package:meta' -C2

Length of output: 0


🏁 Script executed:

#!/bin/bash
# Show where dependencies are declared and check for any "meta" entries
rg -nP '^(dependencies|dev_dependencies):' -n -C3 pubspec.yaml
rg -nP '^\s*meta\s*:' -n -C3 pubspec.yaml

Length of output: 86


🏁 Script executed:

#!/bin/bash
# Locate all pubspec.yaml files and check for meta dependency
find . -type f -name pubspec.yaml | while read f; do
  echo "== $f =="
  rg -nP '^\s*(dependencies|dev_dependencies):' -C3 "$f"
  rg -nP '^\s*meta\s*:' -C3 "$f"
done

Length of output: 2797


Restrict annotation to methods only

Add meta to packages/stac_core/pubspec.yaml:

dependencies:
  meta: ^1.10.0

Then update lib/annotations/stac_screen.dart:

+import 'package:meta/meta_meta.dart';
+
 @Target({TargetKind.method})
 class StacScreen {
   /// Creates a [StacScreen] annotation with the given screen name.
   const StacScreen(this.screenName);
@@
   /// The name identifier for this screen.
   final String screenName;
 }
🤖 Prompt for AI Agents
In packages/stac_core/lib/annotations/stac_screen.dart around lines 14 to 20,
the StacScreen annotation should be restricted to methods only; add the meta
package to packages/stac_core/pubspec.yaml (dependencies: meta: ^1.10.0), run
pub get, then update stac_screen.dart to import package:meta/meta.dart and
annotate the StacScreen class with @Target({TargetKind.method}) so the
annotation can only be used on methods; keep the const constructor and existing
field unchanged.

…ation for marking methods that return StacWidget instances.

- Create new `packages/stac_core/lib/annotations/` directory
- Add `stac_screen.dart` with @StacScreen annotation class
- Add `annotations.dart` export file for the annotations package
- Update `core.dart` to export annotations package

```dart
import 'package:stac_core/stac_core.dart';

@StacScreen('home')
StacWidget buildHomeScreen() => StacWidget();
```
@Potatomonsta Potatomonsta force-pushed the mn/stac-screen-annotation-cli branch from 2203430 to ecc851d Compare September 24, 2025 19:56
@divyanshub024 divyanshub024 merged commit fc8512c into dev Sep 25, 2025
5 checks passed
@divyanshub024 divyanshub024 deleted the mn/stac-screen-annotation-cli branch September 25, 2025 06:34
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.

2 participants