Skip to content

feat(memories): make Auto-capture state explicit with badge + toast#13134

Closed
keval718 wants to merge 2 commits into
release-1.10.0from
fix/memory-auto-capture-feedback
Closed

feat(memories): make Auto-capture state explicit with badge + toast#13134
keval718 wants to merge 2 commits into
release-1.10.0from
fix/memory-auto-capture-feedback

Conversation

@keval718
Copy link
Copy Markdown
Collaborator

@keval718 keval718 commented May 14, 2026

Summary

Make the Auto-capture toggle on the Memory Base details header self-explanatory. Before this PR the only feedback after a toggle was a small green/gray dot in the sidebar — easy to miss, especially for first-time users, and not anywhere near the button they just clicked.

Two complementary signals are now wired up, both built on patterns already in Langflow:

  1. Persistent state badge on the buttonON renders as an emerald pill, OFF as a slate pill, using the same rounded / uppercase / text-[10px] token shape as the status badges in IngestionRunsSection and IngestionHistoryPanel. The toggle icon swaps ToggleRightToggleLeft and tints emerald when ON for a second glanceable cue. aria-pressed reflects state; aria-label switches between "Enable auto-capture" and "Disable auto-capture" so screen readers announce the action.
  2. Toast on commituseAutoCaptureDebouncedToggle gains optional onToggleSuccess(nextIsActive) and onToggleError(nextIsActive) callbacks that fire only when the debounced mutation actually resolves (rapid on → off → on within the debounce window stays silent). useMemoriesData wires the success callback to setSuccessData({ title: "Auto-capture enabled" | "Auto-capture disabled" }). The existing updateMemoryMutation.onError already pushes an error toast, so the new path stays quiet on failure to avoid double-notification.

The button keeps the outline variant in both states; the pill carries the status color so the control's footprint stays stable across toggles. No layout jitter on click.

Files

  • MemoryDetailsHeader.tsx — outline button with state-aware aria, ToggleRight/Left icon w/ emerald-tint when ON, emerald/slate status pill rendered via data-testid="memory-auto-capture-state".
  • useAutoCaptureDebouncedToggle.ts — new optional onToggleSuccess / onToggleError callbacks invoked from the mutation's onSuccess / onError.
  • useMemoriesData.ts — wires the success callback to setSuccessData with the appropriate copy.

Tests

  • MemoryDetailsHeader.test.tsx — split into ON / OFF cases; asserts pill text, aria-pressed, and the state-aware aria-label.
  • useMemoriesData.test.tsx — two new cases (toggle on, toggle off) drive the debounced mutation, invoke the captured onSuccess, and assert the right toast copy is pushed via setSuccessData.
  • Full MemoriesMainContent jest suite: 68 / 68 ✅
  • make format_frontend clean.

Test plan

  • Open a flow with at least one memory → click a memory → header button reads Auto-capture · OFF with a slate pill and ToggleLeft icon.
  • Click the button → pill turns emerald, label becomes ON, icon swaps to ToggleRight tinted emerald. After debounce, a "Auto-capture enabled" success toast appears.
  • Click again → flips back to OFF with slate pill, "Auto-capture disabled" toast.
  • Rapidly toggle on → off → on within the debounce window — no toast fires (collapsed no-op).
  • Sidebar dot still matches the committed state (regression check, no change to that behavior).
  • Screen reader: button announces "Enable auto-capture, pressed: false" / "Disable auto-capture, pressed: true".

Screen shots

Before
image

After
image

The only feedback after toggling Auto-capture was a small colored dot in
the sidebar. New users routinely missed the change, both because the dot
is easy to overlook and because it sits well away from the button being
clicked.

Add two complementary signals, matching patterns already used elsewhere
in Langflow:

  1. Persistent state badge on the button (the part the user is looking
     at). ON renders as an emerald pill, OFF as a slate pill — same
     shape, type, and color tokens as the status badges in
     IngestionRunsSection / IngestionHistoryPanel, so KB users will
     recognize it. The toggle icon swaps ToggleRight/Left and tints
     emerald when ON for a second glanceable cue. aria-pressed and a
     state-aware aria-label keep screen readers in the loop.

  2. Brief toast on commit. ``useAutoCaptureDebouncedToggle`` gains
     ``onToggleSuccess``/``onToggleError`` callbacks that fire only
     when the debounced mutation actually resolves (so rapid on→off→on
     within the debounce window stays silent). ``useMemoriesData``
     wires the success callback to ``setSuccessData`` with
     "Auto-capture enabled" / "Auto-capture disabled". The mutation's
     existing onError already pushes an error toast, so the new path
     stays silent on failure to avoid double-notification.

Button outline variant is kept in both states; the pill carries the
status color so the control's footprint stays stable across toggles.

Tests cover both directions: state badge present + aria reflects state
in MemoryDetailsHeader; toast fires with the right copy from
useMemoriesData when the resolved mutation is on or off.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 14, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: dd1cc7b1-aeb6-4ec1-a064-e128f27407b9

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/memory-auto-capture-feedback

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.

@github-actions github-actions Bot added enhancement New feature or request and removed enhancement New feature or request labels May 14, 2026
@keval718 keval718 self-assigned this May 14, 2026
@github-actions github-actions Bot added enhancement New feature or request and removed enhancement New feature or request labels May 14, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 54.89%. Comparing base (e067f18) to head (f7e99ee).
⚠️ Report is 50 commits behind head on release-1.10.0.

❌ Your project check has failed because the head coverage (49.30%) is below the target coverage (60.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                 @@
##           release-1.10.0   #13134      +/-   ##
==================================================
+ Coverage           54.83%   54.89%   +0.05%     
==================================================
  Files                2146     2147       +1     
  Lines              200251   200352     +101     
  Branches            30214    28587    -1627     
==================================================
+ Hits               109805   109977     +172     
+ Misses              89265    89192      -73     
- Partials             1181     1183       +2     
Flag Coverage Δ
backend 60.07% <ø> (-0.14%) ⬇️
frontend 54.95% <100.00%> (+0.12%) ⬆️
lfx 49.30% <ø> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...MainContent/components/MemoryAutoCaptureToggle.tsx 95.34% <100.00%> (ø)
...riesMainContent/components/MemoryDetailsHeader.tsx 93.56% <100.00%> (+0.71%) ⬆️
...MainContent/hooks/useAutoCaptureDebouncedToggle.ts 92.41% <100.00%> (+4.91%) ⬆️
...nents/MemoriesMainContent/hooks/useMemoriesData.ts 99.14% <100.00%> (+0.03%) ⬆️

... and 36 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 14, 2026

Frontend Unit Test Coverage Report

Coverage Summary

Lines Statements Branches Functions
Coverage: 38%
38.47% (48017/124800) 68.05% (6582/9671) 38.47% (1108/2880)

Unit Test Results

Tests Skipped Failures Errors Time
4321 0 💤 0 ❌ 0 🔥 9m 36s ⏱️

…ndards

Follow-up cleanup on top of the badge + toast change. Addresses the
B-grade items I called out in self-review:

  - Extract MemoryAutoCaptureToggle component. MemoryDetailsHeader was
    inlining a 20-line Tailwind blob; pull it into a small presentational
    component with prop-level JSDoc and a single accessible button.
    Header now reads as orchestration only.

  - Replace the hand-rolled status pill with the existing Badge primitive
    (variant=successStatic / secondaryStatic, size=sm). One source of
    truth for badge tokens across the app — no more drifting Tailwind
    blobs.

  - Route all user-visible Auto-capture copy through i18n
    (memories.autoCapture.{label,stateOn,stateOff,ariaEnable,ariaDisable,
    toastEnabled,toastDisabled} in en.json). No more hardcoded English
    in TS.

  - Export NextIsActive from useAutoCaptureDebouncedToggle so the
    toggle component can type its onToggle prop precisely.

  - Add focused unit tests for useAutoCaptureDebouncedToggle in
    isolation (debounce, on→off→on collapse, success/error callbacks,
    memory-id cleanup, no-memory no-op). Previously only covered through
    useMemoriesData integration tests.

  - Update MemoryDetailsHeader.test.tsx to assert against the new
    state-aware aria-labels and the badge testid.

74/74 memories suite green, 841/841 across FlowPage + createMemoryModal.
@github-actions github-actions Bot added enhancement New feature or request and removed enhancement New feature or request labels May 14, 2026
@olayinkaadelakun
Copy link
Copy Markdown
Collaborator

Hey @keval718 and @dkaushik94

I am not sure who assigned you this ticket, but I have a similar change
https://datastax.jira.com/browse/LE-1192, and i also have a PR for it. I also Designed approved the changes with @rodrigosnader yesterday

@keval718 keval718 requested a review from olayinkaadelakun May 15, 2026 14:06
@github-actions github-actions Bot added the lgtm This PR has been approved by a maintainer label May 19, 2026
@keval718 keval718 added this pull request to the merge queue May 19, 2026
@keval718 keval718 removed this pull request from the merge queue due to a manual request May 19, 2026
@keval718
Copy link
Copy Markdown
Collaborator Author

closing this PR as @olayinkaadelakun has already fixed it in #13116

@keval718 keval718 closed this May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request lgtm This PR has been approved by a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants