Skip to content

Add source descriptions for manual imports#38

Merged
Ayobami-00 merged 2 commits into
mainfrom
fix/add-source-description-for-manual-imports
May 27, 2026
Merged

Add source descriptions for manual imports#38
Ayobami-00 merged 2 commits into
mainfrom
fix/add-source-description-for-manual-imports

Conversation

@Ayobami-00
Copy link
Copy Markdown
Owner

@Ayobami-00 Ayobami-00 commented May 27, 2026

Summary

Fixes #37.

  • Adds an optional source description sheet after manual image selection from the Today FAB and empty state.
  • Stores the description locally on the source metadata and includes it in the queued extract_source job input.
  • Threads the description into local AI prompts as import context while preserving source-evidence grounding.
  • Treats sheet dismissal as cancel, while the explicit Skip action imports without a description.

Validation

  • flutter analyze
  • flutter test
  • Targeted simulator/E2E check, if relevant

Targeted checks:

  • flutter test test/features/source_ingestion/presentation/source_ingestion_cubit_test.dart test/features/source_ingestion/domain/source_ingestion_use_cases_test.dart test/features/ai_processing/domain/ai_job_queue_test.dart test/features/today/presentation/today_screen_test.dart
  • flutter test integration_test/beta_feedback_icon_e2e_test.dart attempted; blocked locally because Xcode could not find the booted simulator destination.
  • flutter test integration_test/beta_feedback_icon_e2e_test.dart -d macos attempted fallback; blocked because no macOS desktop project is configured.

Sanitized validation note: artifacts/issue_37_manual_import_description/validation.md (ignored).
Private demo proof uploaded for PR 38 attempt 2.

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 27, 2026

Greptile Summary

This PR adds an optional source-description bottom sheet that appears after a user manually picks an image from the Today FAB or empty state. The description is stored in the source's metadataJson, forwarded through QueueSourceProcessingParams into the AI job's inputJson, and injected into both the vision-extraction and intention AI prompts as grounding context.

  • Cubit orchestration: SourceIngestionCubit.importImage now owns the pick-then-describe sequence; a null return from the requestDescription callback (dismiss gesture) correctly aborts the import, while an empty string (Skip) proceeds without storing a description.
  • Params promotion: NoParams replaced by ImportImageSourceParams carrying an optional pickedImage and sourceDescription; QueueSourceProcessingParams gains the same optional field, writing it into inputJson only when present.
  • New tests: A dedicated cubit test file covers the dismiss-cancels and skip-imports paths; use-case and AI-job-queue tests verify trimming, metadata storage, and prompt injection end-to-end.

Confidence Score: 5/5

Safe to merge; the description field flows cleanly through all layers and dismiss/skip/save paths are covered by targeted tests.

The pick → describe → import sequence is correctly sequenced in the cubit, with explicit null-return semantics distinguishing cancel from skip. The description value is normalised before storage and before job queuing, keeping empty-string edge cases handled consistently. New unit and integration tests exercise all three user paths (dismiss, skip, save with text).

No files require special attention. The previously noted concerns about _normalizedSourceDescription duplication and repeated jsonDecode in _metadataString remain open but were flagged in an earlier review pass.

Important Files Changed

Filename Overview
lib/features/source_ingestion/presentation/logic/source_ingestion_cubit.dart Cubit now orchestrates pick → description sheet → import; dismiss (null) correctly cancels, skip ('') continues without description; logic paths are clear and well-guarded.
lib/features/today/presentation/screens/today_screen.dart Adds _ManualImageDescriptionSheet with correct keyboard-avoidance animation, proper controller disposal, and context.mounted guard before showing the sheet.
lib/features/source_ingestion/domain/use_cases/import_image_source.dart Params updated from NoParams to ImportImageSourceParams; pre-picked image consumed via pickedImage ?? pickImage() fallback; description normalised and written to metadata JSON.
lib/features/source_ingestion/domain/use_cases/queue_source_processing.dart sourceDescription threaded into job inputJson; _normalizedSourceDescription duplicated from ImportImageSource (flagged in prior review); no logic errors.
lib/features/source_ingestion/domain/entities/source_item_entity.dart sourceDescription getter added via _metadataString which re-parses metadataJson on every call (flagged in prior review); returns null cleanly on missing/empty/invalid JSON.
lib/core/ai/prompts/cactus_prompt_templates.dart Description injected into both vision extraction and intention prompts via _sourceDescriptionPromptBlock; null-guarded; instructions preserve source-evidence grounding.
test/features/source_ingestion/presentation/source_ingestion_cubit_test.dart New test file covering dismiss-cancels and skip-imports paths; real DB + file store wired up; assertions on metadata and queue params are thorough.
test/features/today/presentation/today_screen_test.dart E2E test replaced with a data-seeding approach that skips the FAB → picker → description-sheet UI flow; verifies description propagates into both AI prompts.

Reviews (2): Last reviewed commit: "Cancel manual import on description dism..." | Re-trigger Greptile

Comment thread lib/features/today/presentation/screens/today_screen.dart
@Ayobami-00 Ayobami-00 merged commit 2758795 into main May 27, 2026
2 checks passed
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.

[Bug]: Add source description for manual imports

1 participant