Skip to content

TT-7380 fix: auto-save when editing Segment Reference in Mark Verse step#353

Merged
gtryus merged 2 commits into
developfrom
TT-7380_autosave-segment-ref-mark-verse-step
Jun 11, 2026
Merged

TT-7380 fix: auto-save when editing Segment Reference in Mark Verse step#353
gtryus merged 2 commits into
developfrom
TT-7380_autosave-segment-ref-mark-verse-step

Conversation

@nabalone

@nabalone nabalone commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Converts autosave logic in PassageDetailMarkVerses from a useEffect (triggered by toolsChanged state) to a direct checkBlockersAndScheduleAutosave() function called on every cell/segment change — this ensures autosave fires immediately when a user edits a Segment Reference cell rather than waiting for a separate state update cycle.

  • Fixes SnackBar open-state detection: replaces the brittle message?.type === 'span' check with !!message && message.type !== Fragment so snackbar correctly opens/closes when message content is a non-span React element.

🤖 Generated with Claude Code

@nabalone nabalone force-pushed the TT-7380_autosave-segment-ref-mark-verse-step branch from 0cb534e to 76c7296 Compare June 11, 2026 14:19
setData(newData);
setSegments();
toolChanged(verseToolId);
if (!isChanged(verseToolId)) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

toolChanged handles checking if any change is needed, so this is unnecessary code

}
if (!init && !isChanged(verseToolId)) toolChanged(verseToolId);
if (!init) {
if (!isChanged(verseToolId)) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

toolChanged handles checking if any change is needed, so this is unnecessary code

Convert the autosave logic in PassageDetailMarkVerses from a useEffect
(triggered by toolsChanged state) to a direct function call invoked on
every cell/segment change. This ensures autosave fires immediately when
the user edits a Segment Reference cell rather than waiting for a separate
state update cycle. Also fix SnackBar open-state detection to use
Fragment type-check instead of brittle 'span' type comparison.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@nabalone nabalone force-pushed the TT-7380_autosave-segment-ref-mark-verse-step branch from 76c7296 to 69df630 Compare June 11, 2026 15:39

// Simulate a user boundary edit (init=false) so checkBlockersAndScheduleAutosave
// runs with "9:9" still in the table — the blocker should be detected and warned.
act(() => {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Copilot claims this test had previously been passing only by accident

useEffect(() => {
if ((message?.type === 'span') !== open) {
setOpen(!open);
const hasMessage = !!message && message.type !== Fragment;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I'm a little nervous about this change because the SnackBar is used in so many different places. But it definitely seems like a bug that previously toasts weren't appearing because their messages were wrapped in non-spans

// eslint-disable-next-line react-hooks/exhaustive-deps
}, [toolsChanged, scheduleAutosave]);

useEffect(() => {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Devin flagged that we are now further diverging from the mobile version, which still uses an effect for this. But the logic is already different enough in the mobile version that I was thinking this is fine

@gtryus gtryus merged commit 36f75da into develop Jun 11, 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.

3 participants