Skip to content

Conversation

@AxelUser
Copy link
Owner

@AxelUser AxelUser commented Jan 16, 2026

Summary by CodeRabbit

  • New Features
    • A contextual suggestion appears when users input or paste bag dimensions, offering a quick "Let's try" action to parse them.
    • Suggestion is presented as a lightweight popover with keyboard/mouse support (Escape to dismiss).
    • Dismissal is remembered so the suggestion won’t repeatedly reappear.
    • Dialog trigger updated for a clearer, more guided dimension-parsing flow.

✏️ Tip: You can customize this high-level summary in your review settings.

@AxelUser AxelUser self-assigned this Jan 16, 2026
@coderabbitai
Copy link

coderabbitai bot commented Jan 16, 2026

📝 Walkthrough

Walkthrough

Replaces the paste-dimensions dialog with a parsing dialog and adds a persisted suggestion manager that watches user dimension edits and document visibility to surface a Popover suggestion; the bag-input component now passes userDimensions into the parsing dialog.

Changes

Cohort / File(s) Summary
Bag input component
src/lib/components/bag-input/bag-input.svelte
Replaced PasteDimensionsDialog import with ParsingDialog; updated props to pass userDimensions, preserved measurementSystem and onDimensionsFound usage and existing handlers.
Parsing dialog UI
src/lib/components/bag-input/parsing-dialog.svelte
Added public prop userDimensions; integrated ParsingDialogSuggestion with reactive showSuggestion state; replaced flat trigger with a Popover-based trigger/content containing suggestion copy, close/disable controls, Escape handling, and reusing existing openDialog flow.
Suggestion state manager (new)
src/lib/components/bag-input/parsing-dialog-suggestion.svelte.ts
New ParsingDialogSuggestion class using PersistedState; watches bag dimensions and document visibility to detect user-initiated dimension edits; exposes disable() and shouldShow() and persists disabled state.

Sequence Diagram(s)

sequenceDiagram
  participant BagInput
  participant ParsingDialogSuggestion
  participant Document as "Document (visibility)"
  participant ParsingDialog

  BagInput->>ParsingDialogSuggestion: provide bagDimensionsGetter
  Note right of ParsingDialogSuggestion: watches bag dimensions & document visibility
  Document-->>ParsingDialogSuggestion: visibility change (hidden/visible)
  BagInput->>ParsingDialogSuggestion: bag dimensions change
  ParsingDialogSuggestion-->>BagInput: shouldShow() true
  BagInput->>ParsingDialog: show Popover suggestion
  ParsingDialog->>ParsingDialogSuggestion: on suggestion close/disable
  ParsingDialog->>BagInput: openDialog (user action) -> close suggestion
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A tiny hint hops into view,
When measurements shift and pages flew,
I watch, I wait, then softly show—
A friendly nudge to help you know.
Tap to try, or hush my cheer, I’ll go.

🚥 Pre-merge checks | ✅ 3
✅ 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 accurately describes the main change: adding a suggestion feature to the parse button, which is reflected in the new ParsingDialogSuggestion class and UI updates.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

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

🤖 Fix all issues with AI agents
In `@src/lib/components/bag-input/parsing-dialog.svelte`:
- Around line 36-45: The popover is being forced open because suggestionOpen is
continuously synced to showSuggestion by both watch and $effect; remove the
redundant watch/$effect and instead only set suggestionOpen = true when
showSuggestion transitions from false to true (i.e., a single watcher that opens
on the true transition), and allow user interactions (outside click) to set
suggestionOpen = false; when the popover closes via user interaction, notify the
parent/state by calling the appropriate callback or dispatching an event (e.g.,
call a provided disableSuggestion or setShowSuggestion(false) function or
dispatch a "close" event) so showSuggestion is cleared—this preserves manual
dismissal and drops the always-on sync (remove the existing watch(...) and
$effect(...) blocks and add a single-transition watcher plus an
onClose/outsideClick handler that sets suggestionOpen=false and notifies the
parent).
🧹 Nitpick comments (1)
src/lib/components/bag-input/parsing-dialog-suggestion.svelte.ts (1)

11-47: Consider explicit cleanup for watch subscriptions.

If a ParsingDialogSuggestion instance is ever discarded (component unmount, hot reload, etc.), the two watch subscriptions could keep running. Recommend capturing their disposers and exposing a destroy() method, then calling it from the parent component’s teardown.

♻️ Suggested approach (adjust to runed API)
 export class ParsingDialogSuggestion {
 	private disabled = new PersistedState('suggestion_dimensionParsing_disabled', false);
+	private stopFns: Array<() => void> = [];

 	private inputBeforeHidden = $state(false);
 	private wasHidden = $state(false);
 	private detected = $state(false);

 	constructor(bagDimensionsGetter: () => UserDimensions) {
 		const visible = new IsDocumentVisible();
 		let lastDimensions = { ...bagDimensionsGetter() };

-		watch(
+		const stopDims = watch(
 			() => ({ ...bagDimensionsGetter() }),
 			(dims) => {
 				if (this.disabled.current || this.detected) return;
                 // ...
 			}
 		);
+		this.stopFns.push(stopDims);

-		watch(
+		const stopVis = watch(
 			() => visible.current,
 			(isVisible) => {
 				if (this.disabled.current || this.detected) return;
                 // ...
 			}
 		);
+		this.stopFns.push(stopVis);
 	}

+	public destroy() {
+		for (const stop of this.stopFns) stop();
+		this.stopFns = [];
+	}

Please verify the disposer/cleanup API for watch in runed and wire teardown accordingly.

@AxelUser AxelUser closed this Jan 16, 2026
@AxelUser AxelUser reopened this Jan 16, 2026
@AxelUser AxelUser merged commit 29e8269 into main Jan 16, 2026
3 checks passed
@AxelUser AxelUser deleted the feat/parse-button-suggestion branch January 16, 2026 23:41
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