Fix embedded page jargon regressions#215
Closed
EterUltimate wants to merge 2 commits into
Closed
Conversation
Contributor
Reviewer's GuideReplaces window.confirm-based batch actions in the embedded dashboard with an in-page dialog-based confirmation flow, hides review controls for already-confirmed jargon entries, and updates jargon persistence/inference logic so completed or manually-defined jargon is preserved and skipped during automatic relearning, with tests covering the new behavior. Sequence diagram for in-page dialog batch confirmation flowsequenceDiagram
participant User
participant DashboardPage
participant showConfirm
participant apiPost
User->>DashboardPage: trigger handleBatchReviewAction/handleJargonBatchAction/handleStyleBatchAction
DashboardPage->>showConfirm: showConfirm(title, message, confirmText)
showConfirm-->>DashboardPage: Promise<boolean>
alt user_confirms
DashboardPage->>apiPost: apiPost("review/action" | "jargon/action" | "style/action", payload)
apiPost-->>DashboardPage: result
DashboardPage-->>User: update list UI
else user_cancels
DashboardPage-->>User: no-op
end
Sequence diagram for V2 jargon batch preserving completed definitionssequenceDiagram
participant V2Integration as _jargon_batch
participant db
participant llm
participant JargonFacade
V2Integration->>db: get_jargon(group_id, candidate.term)
db-->>V2Integration: existing_jargon
alt existing_jargon.is_complete
V2Integration->>V2Integration: skip candidate
else not_completed
V2Integration->>llm: generate_response(term context prompt)
llm-->>V2Integration: meaning
V2Integration->>db: save_or_update_jargon(group_id, term, { meaning, raw_content: "[]", is_jargon: True, count: observed_count, is_complete: True, _preserve_completed: True })
db->>JargonFacade: _jargon_update_values(jargon_data, now_ts)
JargonFacade-->>db: update_values with _completed_preserving_value/_completed_preserving_count
db-->>V2Integration: upsert complete
end
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The integration test assertion
assert "window.confirm" not in scriptis quite brittle and may fail if any unrelated bundled dependency or future feature legitimately useswindow.confirm; consider scoping this to the specific dashboard module or a more targeted check (e.g., absence in the batch handlers) instead of the entire script string. - The
_preserve_completedcontrol flag is currently a magic string used in multiple places (SQLAlchemy upsert and the select-then-write path); consider centralizing this key name and its semantics behind a small helper or constant to avoid divergence or typos in future changes.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The integration test assertion `assert "window.confirm" not in script` is quite brittle and may fail if any unrelated bundled dependency or future feature legitimately uses `window.confirm`; consider scoping this to the specific dashboard module or a more targeted check (e.g., absence in the batch handlers) instead of the entire script string.
- The `_preserve_completed` control flag is currently a magic string used in multiple places (SQLAlchemy upsert and the select-then-write path); consider centralizing this key name and its semantics behind a small helper or constant to avoid divergence or typos in future changes.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
8bc7e03 to
a3ccdbe
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #211
Fixes #212
Fixes #213
Summary
window.confirm()calls with the existing in-page<dialog>modal, so sandboxed AstrBot iframes do not silently cancel batch actionsEvidence
window.confirm()in AstrBot v4.25.5 sandboxed Plugin Page iframes withoutallow-modals, affectinghandleBatchReviewAction,handleJargonBatchAction, andhandleStyleBatchAction.services/core_learning/v2_learning_integration.py::_jargon_batch()callingsave_or_update_jargon()withmeaningandcount: 1; current upsert code inservices/database/facades/jargon_facade.pyupdates those fields on conflict.pages/dashboard/app.jsrendered both buttons unconditionally.Validation
python -m pytest tests\integration\test_webui_static_assets.py::test_embedded_plugin_page_uses_astrbot_bridge_and_module_dashboard tests\unit\test_database_engine.py::test_jargon_relearning_upsert_preserves_completed_manual_definition tests\unit\test_provider_registry_rebind.py::test_v2_jargon_batch_skips_completed_terms_and_preserves_candidate_count -qpython -m py_compile services\core_learning\v2_learning_integration.py services\database\facades\jargon_facade.pypython -m ruff check services\core_learning\v2_learning_integration.py services\database\facades\jargon_facade.py tests\integration\test_webui_static_assets.py tests\unit\test_database_engine.py tests\unit\test_provider_registry_rebind.pygit diff --checkNotes
C:\Users\zacza\Desktop\x\AstrBot\data\plugins\astrbot_plugin_self_learningwas attempted but blocked by Windows ACLAccess deniedon the installed plugin directory/files.c503048; Group Chat Plus officialmainfast-forwarded to0a4a00dwhile the local embed branch remains separate.Summary by Sourcery
Replace blocked native confirmation dialogs in the embedded dashboard with in-page modals and harden jargon learning so completed/manual definitions are preserved and skipped by automatic relearning.
New Features:
Bug Fixes:
Enhancements:
Tests: