Skip to content

fix(ui): re-prompt for the first behavior on a declined quit or blank name - #621

Open
gbeane wants to merge 2 commits into
mainfrom
fix/KLAUS-847-reprompt-first-behavior
Open

gbeane wants to merge 2 commits into
mainfrom
fix/KLAUS-847-reprompt-first-behavior

Conversation

@gbeane

@gbeane gbeane commented Nov 29, 2026 •

Copy link
Copy Markdown
Collaborator

KLAUS-847. Follow-up to #620.

When a JABS project has no behaviors, the "New Behavior" prompt asks for one. Its Cancel button is "Quit JABS". If the main window declined that close, _get_first_label returned with no behavior. Both callers (opening a project, archiving the last behavior) then emitted behavior_changed(''), so the classifier load, counts and settings save ran for an empty behavior name, and the prompt never came back. Clicking OK with a blank name led to the same state.

_get_first_label now asks again in both cases, so it only returns once a behavior has been entered:

  • Declined quit: if the window refuses to close, the prompt is shown again with its normal text, and a DEBUG line is logged. When the close is accepted, it still exits after the window's cleanup, as before.
  • Blank name: OK with an empty or whitespace-only name changes the prompt to "The behavior name can't be blank. Please enter a behavior name to continue:" and asks again. The entered name is saved without surrounding whitespace (" Walk " becomes "Walk").

The callers are unchanged. Nothing in JABS declines the main window's close today (MainWindow.closeEvent keeps QMainWindow's default accept), so the declined-quit path is defensive. The blank-name path can be reached by anyone.

The reserved multi-class name "None", and blank names in the "+" dialog, are still accepted. That is tracked in KLAUS-848.

Tests

  • test_first_label_asks_again_when_the_quit_is_declined, test_declined_quit_after_archiving_the_last_behavior_asks_again and test_declined_quit_on_project_open_asks_again: the user quits once, the window refuses, and the user then enters "Walk". Only ["Walk"] is emitted, and after archiving the drop-down's change handler still works.
  • test_first_label_asks_again_for_a_blank_name: "", then " ", then " Walk ". The prompt shows the blank-name message twice and adds "Walk" once.
  • test_declined_quit_resets_the_blank_name_message: blank name, declined quit, then "Walk". The prompt goes back to its normal text after the declined quit.

All five fail without the fix. They replace the two tests that pinned the old behavior: the declined quit returning with no behavior, and #620's empty-name emit. tests/ui: 629 passed. Not yet exercised by hand in the GUI.

@gbeane
gbeane requested a lite review from Copilot December 1, 2026 13:09
@gbeane gbeane self-assigned this Dec 1, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Manual GUI validation remains necessary because the change affects nested Qt modal-dialog reuse and main-window close/cleanup sequencing, while automated tests mock QInputDialog and close() without exercising real event-loop and closeEvent behavior.

No open issues 🎉

What changed in this PR

Updates the first-behavior prompt so it cannot return without a valid behavior name after blank input or a declined quit, preventing empty behavior-change events.

Changes:

  • Re-prompts after blank or whitespace-only names, trims surrounding whitespace, and shows a validation message.
  • Re-prompts after a declined main-window close, restores the normal prompt text, and logs the event.
  • Adds UI regression tests for blank names, declined quits, signal emissions, and handler reconnection.
File Description
tests/​ui/​test_main_control_widget.py Adds regression tests covering blank-name validation, declined quits, normalized names, behavior-change signals, and handler reconnection.
src/​jabs/​ui/​main_control_widget/​main_control_widget.py Implements repeated prompting, blank-name validation, whitespace trimming, and declined-quit handling.

Review effort: Lite

This branch has not been deployed

No deployments
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