Skip to content

Add cancelable confirmations and message types to WebUI - #857

Merged
briemla merged 9 commits into
mainfrom
webui/03-confirmation-dialogs
Oct 16, 2026
Merged

briemla merged 9 commits into
mainfrom
webui/03-confirmation-dialogs

Conversation

@briemla

@briemla briemla commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

OP#10514

Problem

In the WebUI, confirmations could not be canceled. NiceGuiUiFactory.info_box only showed a ui.notify and returned an info box whose canceled was always False. Loading an otconfig, loading an otflow over existing sections/flows and starting a new project therefore discarded the current sections, flows and videos without a way to cancel.

In addition:

  • every message was shown as an error (type="negative"), including plain hints,
  • minimal_info_box ("Create events...", "Apply offset...") showed nothing.

UiFactory.info_box is synchronous, but a NiceGUI dialog has to be awaited.

Solution

  • UiFactory gets two new methods, async ask_for_confirmation(message, initial_position) -> bool and show_message(message, initial_position, message_type), plus the MessageType enum (ERROR, WARNING, INFO). Both methods are deliberately not abstract: other front-ends (OTCloud) implement UiFactory, and the repo rule is that it must not gain abstract methods. Their defaults fall back to info_box, so such front-ends behave as before.
  • NiceGUI
    • ask_for_confirmation opens a modal ConfirmationDialog (based on BaseDialog) with OK/Cancel. BaseDialog gets an overridable apply_label(), and GeneralKeys.LABEL_OK is new in the ResourceManager.
    • show_message maps the type to the notification type: error → negative, warning → warning, info → info. info_box still shows an error.
    • minimal_info_box shows a persistent notification with a spinner. update_message changes its text and close dismisses it. Without a client (e.g. startup preload), it does nothing instead of raising.
  • customtkinter: ask_for_confirmation uses the existing CtkInfoBox(show_cancel=True). show_message uses the default, i.e. the same CtkInfoBox as before, so the customtkinter GUI does not change.
  • View model
    • _load_otconfig, _load_otflow and start_new_project await ask_for_confirmation and stop on cancel.
    • _load_otflow and start_new_project (including the ViewModel port) are now async. load_configuration already awaited them, and the customtkinter GUI calls it via asyncio.run. start_new_project currently has no UI caller.
    • Every message now passes its type at the call site: failures are errors, missing selections and preconditions are warnings, and a successful cut is info.
    • show_cancel is no longer used by info_box and was removed from its signature. CtkInfoBox keeps it.
  • Acceptance helper: open_project_otconfig confirms the new dialog.

Tests

  • New tests/unit/OTAnalytics/adapter_ui/test_dummy_viewmodel_confirmation.py, run against a mocked UiFactory:
    • Cancel prevents loading an otconfig, loading an otflow and resetting the project. OK carries each action out.
    • An otflow loads without asking when nothing is configured.
    • Message types are passed at the call sites.
  • tests/unit/OTAnalytics/plugin_ui/nicegui_gui/test_ui_factory.py:
    • The confirmation dialog returns True on OK and False on Cancel (NiceGUI User).
    • Each message type maps to the right notification type.
    • minimal_info_box is visible, updates its text, can be closed and works without a client.
  • New tests/unit/OTAnalytics/adapter_ui/test_ui_factory_defaults.py covers the backward-compatible defaults of the new UiFactory methods.
  • Updated the existing view model tests for the info_box → show_message / ask_for_confirmation change.

Results:

  • pytest tests/unit: 1671 passed, 6 skipped.
  • pre-commit run --all-files: flake8, black, isort and mypy pass. Three hooks fail locally for reasons unrelated to this PR, and they fail the same way on main:
    • ShellCheck needs a .venv in the checkout.
    • The mypy dependency auto-updater rewrites the config.
    • "fix end of files" flags a test data file.
  • Acceptance tests:
    • test_project_information.py and test_filters_navigation_buttons.py pass. They open a project through the new confirmation dialog.
    • test_sections_and_flows.py::test_create_sections_two_times and test_export_track_statistics.py time out locally after the project is opened. They fail the same way on main.

🤖 Generated with Claude Code

briemla and others added 7 commits October 13, 2026 13:52
Add MessageType and the non-abstract UiFactory methods show_message and
ask_for_confirmation. They are not abstract because other front-ends
implement UiFactory; their defaults fall back to info_box and keep the
previous behaviour. The customtkinter factory asks for confirmation with
the existing CtkInfoBox(show_cancel=True).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- ask_for_confirmation opens a modal ConfirmationDialog with OK/Cancel
  based on BaseDialog and returns whether the user confirmed.
- show_message maps the message type to the notification type: errors
  stay negative, warnings and infos are no longer shown as errors.
- minimal_info_box shows a persistent notification with a spinner;
  update_message changes its text and close dismisses it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Loading an otconfig, loading an otflow over existing sections or flows,
and starting a new project now await ask_for_confirmation and stop if the
user cancels. _load_otflow and start_new_project become async for that;
load_configuration already awaits them and the customtkinter GUI calls it
via asyncio.run.

Messages are shown via show_message with an explicit type at each call
site: failures as errors, missing selections or preconditions as
warnings and a successful cut as info. show_cancel is no longer used by
info_box and is removed from its signature.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Opening an otconfig in the WebUI now asks for confirmation before the
current project is replaced, so the helper that opens a project clicks OK.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@briemla
briemla requested a review from schubsen October 15, 2026 07:22
Comment thread OTAnalytics/adapter_ui/dummy_viewmodel.py Outdated
Comment thread OTAnalytics/adapter_ui/dummy_viewmodel.py Outdated
Comment thread OTAnalytics/adapter_ui/dummy_viewmodel.py Outdated
Comment thread OTAnalytics/adapter_ui/dummy_viewmodel.py Outdated
Comment thread OTAnalytics/adapter_ui/dummy_viewmodel.py
Comment thread OTAnalytics/adapter_ui/dummy_viewmodel.py
…-dialogs

# Conflicts:
#	tests/unit/OTAnalytics/plugin_ui/test_flow_form.py
@briemla
briemla enabled auto-merge October 16, 2026 10:51
@briemla
briemla requested a review from schubsen October 16, 2026 10:51
@briemla
briemla merged commit c003e2f into main Oct 16, 2026
15 checks passed
@briemla
briemla deleted the webui/03-confirmation-dialogs branch October 16, 2026 11:35
randy-seng added a commit that referenced this pull request Oct 16, 2026
…mplement-create-new-project-use-case

#857 added UiFactory.ask_for_confirmation and a
NiceGUI ConfirmationDialog, as this branch did. Keep main's versions and
drop this branch's duplicates, with two additions:

- delete the NiceGUI dialog once answered, so answered dialogs do not pile
  up in the page
- mark the confirmation message for Playwright; answer_confirmation replaces
  main's confirm_dialog helper and also answers with Cancel

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ELfr5L29V7e22eWrXiL3jh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants