collavre 0.25.0 → 0.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +19 -10
- data/app/assets/images/collavre/kollavy.png +0 -0
- data/app/assets/images/collavre/kollavy.svg +9 -0
- data/app/assets/stylesheets/collavre/actiontext.css +24 -165
- data/app/assets/stylesheets/collavre/activity_logs.css +23 -12
- data/app/assets/stylesheets/collavre/agent_connections.css +196 -0
- data/app/assets/stylesheets/collavre/agent_gateways.css +153 -0
- data/app/assets/stylesheets/collavre/attachment_card.css +34 -0
- data/app/assets/stylesheets/collavre/comments_popup.css +512 -87
- data/app/assets/stylesheets/collavre/creatives.css +827 -126
- data/app/assets/stylesheets/collavre/dark_mode.css +0 -20
- data/app/assets/stylesheets/collavre/design_tokens.css +79 -0
- data/app/assets/stylesheets/collavre/desktop_setup.css +0 -5
- data/app/assets/stylesheets/collavre/image_lightbox.css +12 -0
- data/app/assets/stylesheets/collavre/landing.css +23 -104
- data/app/assets/stylesheets/collavre/llm_usages.css +67 -0
- data/app/assets/stylesheets/collavre/mention_menu.css +18 -0
- data/app/assets/stylesheets/collavre/modal_dialog.css +66 -3
- data/app/assets/stylesheets/collavre/notice_bar.css +465 -0
- data/app/assets/stylesheets/collavre/org_chart.css +0 -4
- data/app/assets/stylesheets/collavre/popup.css +15 -18
- data/app/assets/stylesheets/collavre/search_popup.css +0 -34
- data/app/assets/stylesheets/collavre/slide_view.css +221 -4
- data/app/assets/stylesheets/collavre/workflow_editor.css +101 -0
- data/app/assets/stylesheets/collavre/workspace.css +13 -10
- data/app/channels/collavre/agent_channel.rb +48 -23
- data/app/components/collavre/command_menu_component.html.erb +5 -0
- data/app/components/collavre/command_menu_component.rb +8 -0
- data/app/components/collavre/comment_user_menu_component.html.erb +61 -0
- data/app/components/collavre/comment_user_menu_component.rb +14 -0
- data/app/components/collavre/cron_badge_component.html.erb +80 -0
- data/app/components/collavre/cron_badge_component.rb +50 -0
- data/app/controllers/collavre/admin/orchestration_controller.rb +59 -32
- data/app/controllers/collavre/admin/settings_controller.rb +77 -8
- data/app/controllers/collavre/agent_connections_controller.rb +9 -21
- data/app/controllers/collavre/agent_models_controller.rb +55 -0
- data/app/controllers/collavre/agent_provisioning_controller.rb +31 -22
- data/app/controllers/collavre/api/v1/agents_controller.rb +47 -163
- data/app/controllers/collavre/api/v1/task_suspensions_controller.rb +60 -0
- data/app/controllers/collavre/attachments_controller.rb +12 -12
- data/app/controllers/collavre/comments/activity_logs_controller.rb +2 -0
- data/app/controllers/collavre/comments/reactions_controller.rb +10 -12
- data/app/controllers/collavre/comments/resends_controller.rb +21 -0
- data/app/controllers/collavre/comments/versions_controller.rb +24 -21
- data/app/controllers/collavre/comments_controller.rb +61 -10
- data/app/controllers/collavre/concerns/creative_history_trackable.rb +31 -0
- data/app/controllers/collavre/concerns/tree_manageable.rb +4 -0
- data/app/controllers/collavre/creative_change_sets_controller.rb +112 -0
- data/app/controllers/collavre/creative_imports_controller.rb +9 -1
- data/app/controllers/collavre/creative_invitations_controller.rb +2 -11
- data/app/controllers/collavre/creative_shares_controller.rb +7 -15
- data/app/controllers/collavre/creatives/attachments_controller.rb +16 -4
- data/app/controllers/collavre/creatives/file_drops_controller.rb +35 -0
- data/app/controllers/collavre/creatives/ppt_previews_controller.rb +66 -0
- data/app/controllers/collavre/creatives_controller.rb +49 -272
- data/app/controllers/collavre/crons_controller.rb +48 -0
- data/app/controllers/collavre/desktop_gateway_registrations_controller.rb +2 -19
- data/app/controllers/collavre/desktop_setup_controller.rb +2 -19
- data/app/controllers/collavre/desktop_sidecar_health_controller.rb +2 -14
- data/app/controllers/collavre/google_auth_controller.rb +3 -4
- data/app/controllers/collavre/inline_agent_logins_controller.rb +79 -0
- data/app/controllers/collavre/llm_usages_controller.rb +51 -0
- data/app/controllers/collavre/onboarding_replays_controller.rb +10 -0
- data/app/controllers/collavre/public_assets_controller.rb +48 -4
- data/app/controllers/collavre/seo_controller.rb +83 -0
- data/app/controllers/collavre/sessions_controller.rb +5 -9
- data/app/controllers/collavre/topics_controller.rb +17 -32
- data/app/controllers/collavre/user_creative_preferences_controller.rb +26 -59
- data/app/controllers/collavre/user_notices_controller.rb +64 -0
- data/app/controllers/collavre/user_themes_controller.rb +11 -7
- data/app/controllers/collavre/users_controller.rb +1 -0
- data/app/controllers/concerns/collavre/active_storage_access.rb +127 -0
- data/app/controllers/concerns/collavre/api/claude_channel_prompts.rb +209 -0
- data/app/controllers/concerns/collavre/blob_access_control.rb +57 -0
- data/app/controllers/concerns/collavre/comments/approval_actions.rb +24 -22
- data/app/controllers/concerns/collavre/comments/approval_gate_actions.rb +29 -0
- data/app/controllers/concerns/collavre/comments/batch_operations.rb +1 -1
- data/app/controllers/concerns/collavre/comments/comment_scoping.rb +4 -2
- data/app/controllers/concerns/collavre/comments/history_topic_guard.rb +22 -0
- data/app/controllers/concerns/collavre/creative_destroyable.rb +41 -0
- data/app/controllers/concerns/collavre/creative_permission_guard.rb +6 -0
- data/app/controllers/concerns/collavre/creative_type_editable.rb +76 -0
- data/app/controllers/concerns/collavre/loopback_request.rb +32 -0
- data/app/controllers/concerns/collavre/origin_verification.rb +29 -0
- data/app/controllers/concerns/collavre/permission_update_response.rb +23 -0
- data/app/controllers/concerns/collavre/proxy_error_response.rb +14 -0
- data/app/controllers/concerns/collavre/public_creative_page.rb +52 -0
- data/app/controllers/concerns/collavre/public_creative_redirectable.rb +31 -0
- data/app/controllers/concerns/collavre/successful_authentication.rb +12 -0
- data/app/controllers/concerns/collavre/svg_streaming.rb +39 -0
- data/app/controllers/concerns/collavre/topics/reserved_topic_guard.rb +52 -0
- data/app/controllers/concerns/collavre/user_creative_preferences_controller/persistence.rb +98 -0
- data/app/controllers/concerns/collavre/users_controller/admin_operations.rb +38 -12
- data/app/controllers/concerns/collavre/users_controller/ai_profile_access.rb +25 -0
- data/app/controllers/concerns/collavre/users_controller/ai_user_management.rb +80 -40
- data/app/controllers/concerns/collavre/users_controller/contact_management.rb +31 -18
- data/app/controllers/concerns/collavre/users_controller/profile_and_settings.rb +15 -1
- data/app/controllers/concerns/collavre/users_controller/registration.rb +7 -11
- data/app/controllers/concerns/collavre/workflow_editable.rb +112 -0
- data/app/errors/collavre/approval_gate_pending_error.rb +12 -0
- data/app/errors/collavre/approval_pending_error.rb +5 -2
- data/app/errors/collavre/screening_pending_error.rb +17 -0
- data/app/errors/collavre/task_suspended_error.rb +11 -0
- data/app/helpers/collavre/activity_logs_helper.rb +26 -0
- data/app/helpers/collavre/application_helper.rb +10 -44
- data/app/helpers/collavre/creative_move_helper.rb +15 -0
- data/app/helpers/collavre/creatives_helper.rb +117 -65
- data/app/helpers/collavre/navigation_helper.rb +122 -0
- data/app/helpers/collavre/public_assets_helper.rb +14 -0
- data/app/helpers/collavre/public_creatives_helper.rb +44 -0
- data/app/javascript/__tests__/slide_view.test.js +30 -0
- data/app/javascript/collavre.js +3 -0
- data/app/javascript/collavre_pdf_viewer.js +3 -0
- data/app/javascript/collavre_pdf_worker.js +1 -0
- data/app/javascript/comments/__tests__/user_menu.test.js +137 -0
- data/app/javascript/comments/user_menu.js +205 -0
- data/app/javascript/components/EmojiPicker.js +90 -0
- data/app/javascript/components/HeadingButtons.js +45 -0
- data/app/javascript/components/HistoryButtons.jsx +26 -0
- data/app/javascript/components/ImageResizer.jsx +11 -30
- data/app/javascript/components/InlineLexicalEditor.jsx +19 -77
- data/app/javascript/components/__tests__/EmojiPicker.test.js +127 -0
- data/app/javascript/components/__tests__/HeadingButtons.test.js +111 -0
- data/app/javascript/components/__tests__/creative_tree_row_document_view.test.js +814 -0
- data/app/javascript/components/__tests__/creative_tree_row_progress_toggle.test.js +72 -2
- data/app/javascript/components/__tests__/document_row_swipe.test.js +206 -0
- data/app/javascript/components/creative_header_progress.js +24 -0
- data/app/javascript/components/creative_tree_row.js +39 -82
- data/app/javascript/components/creative_tree_row_document_view.js +251 -0
- data/app/javascript/components/document_row_swipe.js +107 -0
- data/app/javascript/components/plugins/__tests__/creative_links_plugin.test.js +59 -0
- data/app/javascript/components/plugins/__tests__/image_upload_plugin.test.js +107 -0
- data/app/javascript/components/plugins/creative_links_plugin.js +24 -0
- data/app/javascript/components/plugins/image_upload_plugin.jsx +24 -28
- data/app/javascript/components/plugins/markdown_shortcuts_plugin.jsx +5 -2
- data/app/javascript/controllers/__tests__/agent_connection_controller.test.js +433 -3
- data/app/javascript/controllers/__tests__/agent_vendor_controller.test.js +94 -0
- data/app/javascript/controllers/__tests__/comment_agent_model_controller.test.js +148 -0
- data/app/javascript/controllers/__tests__/comment_approval_controls.test.js +45 -0
- data/app/javascript/controllers/__tests__/comment_user_menu_controller.test.js +285 -0
- data/app/javascript/controllers/__tests__/comment_version_controller.test.js +51 -0
- data/app/javascript/controllers/__tests__/controller_csrf_requests.test.js +137 -0
- data/app/javascript/controllers/__tests__/creative_history_controller.test.js +123 -0
- data/app/javascript/controllers/__tests__/creative_history_detail_controller.test.js +104 -0
- data/app/javascript/controllers/__tests__/creative_history_undo_controller.test.js +55 -0
- data/app/javascript/controllers/__tests__/creative_image_lightbox_controller.test.js +583 -0
- data/app/javascript/controllers/__tests__/creative_move_controller.test.js +713 -0
- data/app/javascript/controllers/__tests__/cron_badge_controller.test.js +436 -0
- data/app/javascript/controllers/__tests__/document_preview_controller.test.js +33 -0
- data/app/javascript/controllers/__tests__/entity_list_controller.test.js +270 -0
- data/app/javascript/controllers/__tests__/expansion_controller.test.js +235 -0
- data/app/javascript/controllers/__tests__/index.test.js +6 -0
- data/app/javascript/controllers/__tests__/inline_creative_picker_controller.test.js +232 -0
- data/app/javascript/controllers/__tests__/link_creative_controller.test.js +101 -0
- data/app/javascript/controllers/__tests__/notice_bar_controller.test.js +1076 -0
- data/app/javascript/controllers/__tests__/popup_menu_controller.test.js +267 -0
- data/app/javascript/controllers/__tests__/search_popup_controller.test.js +46 -32
- data/app/javascript/controllers/__tests__/share_modal_public_link.test.js +113 -0
- data/app/javascript/controllers/__tests__/share_user_search_controller.test.js +17 -0
- data/app/javascript/controllers/__tests__/tabs_controller.test.js +137 -0
- data/app/javascript/controllers/__tests__/tool_category_controller.test.js +116 -0
- data/app/javascript/controllers/__tests__/topic_list_controller.test.js +14 -0
- data/app/javascript/controllers/__tests__/workspace_tree_controller.test.js +757 -22
- data/app/javascript/controllers/agent_auth_controller.js +245 -0
- data/app/javascript/controllers/agent_connection_controller.js +29 -189
- data/app/javascript/controllers/agent_vendor_controller.js +47 -1
- data/app/javascript/controllers/comment_agent_model_controller.js +87 -0
- data/app/javascript/controllers/comment_controller.js +34 -77
- data/app/javascript/controllers/comment_image_lightbox_controller.js +15 -0
- data/app/javascript/controllers/comment_user_menu_controller.js +122 -0
- data/app/javascript/controllers/comment_version_controller.js +10 -8
- data/app/javascript/controllers/comments/__tests__/comment_form_request.test.js +72 -0
- data/app/javascript/controllers/comments/__tests__/comment_list_response.test.js +30 -0
- data/app/javascript/controllers/comments/__tests__/comment_read_tracker.test.js +71 -0
- data/app/javascript/controllers/comments/__tests__/contexts_controller_context_list.test.js +466 -0
- data/app/javascript/controllers/comments/__tests__/contexts_controller_dnd.test.js +484 -0
- data/app/javascript/controllers/comments/__tests__/creative_quote_review_controller.test.js +111 -0
- data/app/javascript/controllers/comments/__tests__/drop_trigger_controller.test.js +48 -0
- data/app/javascript/controllers/comments/__tests__/feature_cards_controller.test.js +2 -2
- data/app/javascript/controllers/comments/__tests__/form_controller_double_submit.test.js +38 -0
- data/app/javascript/controllers/comments/__tests__/form_controller_draft.test.js +202 -17
- data/app/javascript/controllers/comments/__tests__/form_controller_review.test.js +375 -0
- data/app/javascript/controllers/comments/__tests__/form_controller_stashed_draft.test.js +4 -4
- data/app/javascript/controllers/comments/__tests__/form_controller_stashed_draft_creative_switch.test.js +2 -2
- data/app/javascript/controllers/comments/__tests__/form_draft_manager.test.js +154 -0
- data/app/javascript/controllers/comments/__tests__/inline_login_preservation.test.js +23 -0
- data/app/javascript/controllers/comments/__tests__/list_controller_approval_gate.test.js +51 -0
- data/app/javascript/controllers/comments/__tests__/list_controller_batch_delete.test.js +97 -0
- data/app/javascript/controllers/comments/__tests__/list_controller_dnd.test.js +26 -0
- data/app/javascript/controllers/comments/__tests__/list_controller_docked.test.js +54 -1
- data/app/javascript/controllers/comments/__tests__/list_controller_load_result.test.js +56 -0
- data/app/javascript/controllers/comments/__tests__/list_controller_loading.test.js +43 -0
- data/app/javascript/controllers/comments/__tests__/list_controller_prev_message.test.js +202 -1
- data/app/javascript/controllers/comments/__tests__/list_controller_read_pointer.test.js +12 -0
- data/app/javascript/controllers/comments/__tests__/list_controller_resend.test.js +69 -0
- data/app/javascript/controllers/comments/__tests__/list_controller_resume_pagination.test.js +191 -0
- data/app/javascript/controllers/comments/__tests__/loading_controller.test.js +83 -0
- data/app/javascript/controllers/comments/__tests__/mention_menu_controller.test.js +59 -0
- data/app/javascript/controllers/comments/__tests__/popup_controller.test.js +318 -4
- data/app/javascript/controllers/comments/__tests__/popup_exit_target.test.js +118 -0
- data/app/javascript/controllers/comments/__tests__/popup_focus.test.js +72 -0
- data/app/javascript/controllers/comments/__tests__/popup_fullscreen.test.js +320 -0
- data/app/javascript/controllers/comments/__tests__/popup_initial_url.test.js +103 -0
- data/app/javascript/controllers/comments/__tests__/popup_resume_resync.test.js +154 -0
- data/app/javascript/controllers/comments/__tests__/presence_controller.test.js +58 -0
- data/app/javascript/controllers/comments/__tests__/presence_controller_agent_online.test.js +244 -0
- data/app/javascript/controllers/comments/__tests__/presence_controller_participant_list.test.js +570 -0
- data/app/javascript/controllers/comments/__tests__/resend_action.test.js +137 -0
- data/app/javascript/controllers/comments/__tests__/review_quotes_store.test.js +27 -0
- data/app/javascript/controllers/comments/__tests__/run_options_controller.test.js +248 -0
- data/app/javascript/controllers/comments/__tests__/topics_controller_archived.test.js +45 -0
- data/app/javascript/controllers/comments/__tests__/topics_controller_creation_container.test.js +165 -0
- data/app/javascript/controllers/comments/__tests__/topics_controller_delete.test.js +231 -0
- data/app/javascript/controllers/comments/__tests__/topics_controller_dnd.test.js +120 -0
- data/app/javascript/controllers/comments/__tests__/topics_controller_scroll.test.js +17 -0
- data/app/javascript/controllers/comments/__tests__/topics_controller_selection_race.test.js +274 -2
- data/app/javascript/controllers/comments/__tests__/topics_controller_topic_list.test.js +4 -4
- data/app/javascript/controllers/comments/approval_request_options.js +12 -0
- data/app/javascript/controllers/comments/comment_form_request.js +26 -0
- data/app/javascript/controllers/comments/comment_list_response.js +20 -0
- data/app/javascript/controllers/comments/comment_read_tracker.js +143 -0
- data/app/javascript/controllers/comments/contexts_controller.js +338 -226
- data/app/javascript/controllers/comments/creative_chat_navigation.js +50 -0
- data/app/javascript/controllers/comments/creative_quote_review_controller.js +30 -0
- data/app/javascript/controllers/comments/drop_trigger_controller.js +2 -7
- data/app/javascript/controllers/comments/feature_cards_controller.js +1 -1
- data/app/javascript/controllers/comments/form_controller.js +128 -706
- data/app/javascript/controllers/comments/form_draft_manager.js +269 -0
- data/app/javascript/controllers/comments/form_draft_migration.js +142 -0
- data/app/javascript/controllers/comments/form_draft_persistence.js +228 -0
- data/app/javascript/controllers/comments/inline_login_preservation.js +18 -0
- data/app/javascript/controllers/comments/list_controller.js +105 -273
- data/app/javascript/controllers/comments/loading_controller.js +48 -0
- data/app/javascript/controllers/comments/mention_menu_controller.js +1 -24
- data/app/javascript/controllers/comments/optimistic_removal.js +15 -0
- data/app/javascript/controllers/comments/pagination_state.js +20 -0
- data/app/javascript/controllers/comments/popup_controller.js +74 -510
- data/app/javascript/controllers/comments/popup_creative_progress.js +51 -0
- data/app/javascript/controllers/comments/popup_exit_target.js +92 -0
- data/app/javascript/controllers/comments/popup_focus.js +5 -0
- data/app/javascript/controllers/comments/popup_fullscreen.js +335 -0
- data/app/javascript/controllers/comments/popup_resume_resync.js +28 -0
- data/app/javascript/controllers/comments/popup_url_open.js +22 -0
- data/app/javascript/controllers/comments/presence_controller.js +295 -142
- data/app/javascript/controllers/comments/previous_message_navigation.js +154 -0
- data/app/javascript/controllers/comments/resend_action.js +63 -0
- data/app/javascript/controllers/comments/review_quotes_store.js +11 -8
- data/app/javascript/controllers/comments/run_options_controller.js +145 -0
- data/app/javascript/controllers/comments/topics/last_topic_save.js +124 -0
- data/app/javascript/controllers/comments/topics/reserved_topic_deletion.js +25 -0
- data/app/javascript/controllers/comments/topics/save_order_state.js +127 -0
- data/app/javascript/controllers/comments/topics/selection_restore_state.js +42 -0
- data/app/javascript/controllers/comments/topics/self_echo_state.js +24 -0
- data/app/javascript/controllers/comments/topics_controller.js +336 -478
- data/app/javascript/controllers/creative_history_controller.js +57 -0
- data/app/javascript/controllers/creative_history_detail_controller.js +41 -0
- data/app/javascript/controllers/creative_history_undo_controller.js +19 -0
- data/app/javascript/controllers/creative_image_lightbox_controller.js +114 -0
- data/app/javascript/controllers/creative_move_controller.js +202 -0
- data/app/javascript/controllers/creatives/__tests__/document_selection_controller.test.js +241 -0
- data/app/javascript/controllers/creatives/__tests__/document_view_controller.test.js +173 -0
- data/app/javascript/controllers/creatives/__tests__/drag_drop_controller.test.js +74 -0
- data/app/javascript/controllers/creatives/__tests__/import_controller.test.js +48 -0
- data/app/javascript/controllers/creatives/__tests__/select_mode_controller.test.js +111 -0
- data/app/javascript/controllers/creatives/__tests__/tree_controller.test.js +605 -2
- data/app/javascript/controllers/creatives/__tests__/workflow_rule_controller.test.js +322 -0
- data/app/javascript/controllers/creatives/document_selection_controller.js +77 -0
- data/app/javascript/controllers/creatives/document_view_controller.js +82 -0
- data/app/javascript/controllers/creatives/drag_drop_controller.js +13 -19
- data/app/javascript/controllers/creatives/expansion_controller.js +21 -19
- data/app/javascript/controllers/creatives/import_controller.js +1 -1
- data/app/javascript/controllers/creatives/select_mode_controller.js +31 -4
- data/app/javascript/controllers/creatives/tree_controller.js +128 -36
- data/app/javascript/controllers/creatives/workflow_rule_controller.js +96 -0
- data/app/javascript/controllers/creatives/workflow_rule_form.js +183 -0
- data/app/javascript/controllers/cron_badge_controller.js +187 -0
- data/app/javascript/controllers/document_preview_controller.js +16 -0
- data/app/javascript/controllers/entity_list_controller.js +147 -0
- data/app/javascript/controllers/gateway_check_controller.js +3 -5
- data/app/javascript/controllers/image_lightbox_controller.js +29 -70
- data/app/javascript/controllers/image_lightbox_values.js +13 -0
- data/app/javascript/controllers/index.js +85 -11
- data/app/javascript/controllers/inline_creative_picker_controller.js +110 -0
- data/app/javascript/controllers/link_creative_controller.js +14 -11
- data/app/javascript/controllers/notice_bar_controller.js +364 -0
- data/app/javascript/controllers/org_chart_controller.js +2 -23
- data/app/javascript/controllers/popup_menu_controller.js +128 -45
- data/app/javascript/controllers/search_popup_controller.js +12 -8
- data/app/javascript/controllers/searchable_list_controller.js +30 -0
- data/app/javascript/controllers/share_modal_controller.js +18 -56
- data/app/javascript/controllers/share_user_search_controller.js +1 -11
- data/app/javascript/controllers/tabs_controller.js +5 -1
- data/app/javascript/controllers/tool_category_controller.js +39 -0
- data/app/javascript/controllers/topic_list_controller.js +5 -31
- data/app/javascript/controllers/topic_search_controller.js +2 -4
- data/app/javascript/controllers/workspace_tree_controller.js +194 -53
- data/app/javascript/creatives/__tests__/row_progress.test.js +155 -0
- data/app/javascript/creatives/__tests__/tree_reload_events.test.js +101 -0
- data/app/javascript/creatives/__tests__/tree_renderer.test.js +116 -1
- data/app/javascript/creatives/__tests__/tree_view_state.test.js +277 -0
- data/app/javascript/creatives/branch_expansion.js +39 -0
- data/app/javascript/creatives/drag_drop/__tests__/command_integration.test.js +194 -0
- data/app/javascript/creatives/drag_drop/__tests__/creative_tree_drop.test.js +964 -0
- data/app/javascript/creatives/drag_drop/__tests__/event_handlers_data.test.js +329 -0
- data/app/javascript/creatives/drag_drop/__tests__/file_drop.test.js +99 -0
- data/app/javascript/creatives/drag_drop/__tests__/hover_expand.test.js +134 -0
- data/app/javascript/creatives/drag_drop/__tests__/indicator.test.js +36 -0
- data/app/javascript/creatives/drag_drop/__tests__/move_command.test.js +471 -0
- data/app/javascript/creatives/drag_drop/__tests__/move_command_dom_recovery.test.js +346 -0
- data/app/javascript/creatives/drag_drop/__tests__/move_command_queued_saves.test.js +201 -0
- data/app/javascript/creatives/drag_drop/__tests__/move_feedback.test.js +79 -0
- data/app/javascript/creatives/drag_drop/__tests__/source_window_bundle.test.js +141 -0
- data/app/javascript/creatives/drag_drop/__tests__/state.test.js +36 -0
- data/app/javascript/creatives/drag_drop/__tests__/touch_tree_integration.test.js +209 -0
- data/app/javascript/creatives/drag_drop/__tests__/workspace_tree_adapter.test.js +517 -0
- data/app/javascript/creatives/drag_drop/__tests__/workspace_tree_dom.test.js +105 -0
- data/app/javascript/creatives/drag_drop/dom.js +9 -0
- data/app/javascript/creatives/drag_drop/event_handlers.js +279 -431
- data/app/javascript/creatives/drag_drop/file_drop.js +60 -0
- data/app/javascript/creatives/drag_drop/indicator.js +2 -1
- data/app/javascript/creatives/drag_drop/move_command.js +297 -0
- data/app/javascript/creatives/drag_drop/move_feedback.js +22 -0
- data/app/javascript/creatives/drag_drop/operations.js +73 -0
- data/app/javascript/creatives/drag_drop/state.js +10 -1
- data/app/javascript/creatives/drag_drop/workspace_tree_adapter.js +161 -0
- data/app/javascript/creatives/drag_drop/workspace_tree_dom.js +52 -0
- data/app/javascript/creatives/row_progress.js +96 -0
- data/app/javascript/creatives/tree_reload_events.js +42 -0
- data/app/javascript/creatives/tree_renderer.js +70 -21
- data/app/javascript/creatives/tree_view_state.js +87 -0
- data/app/javascript/lib/__tests__/creative_quote.test.js +343 -0
- data/app/javascript/lib/__tests__/creative_title.test.js +15 -0
- data/app/javascript/lib/__tests__/entity_list_popup.test.js +47 -0
- data/app/javascript/lib/__tests__/html_escape.test.js +29 -0
- data/app/javascript/lib/__tests__/permission_update.test.js +38 -0
- data/app/javascript/lib/__tests__/popup_toggle_guard.test.js +82 -0
- data/app/javascript/lib/__tests__/ppt_background.test.js +86 -0
- data/app/javascript/lib/__tests__/ppt_connector.test.js +80 -0
- data/app/javascript/lib/__tests__/ppt_formatting.test.js +246 -0
- data/app/javascript/lib/__tests__/ppt_media.test.js +86 -0
- data/app/javascript/lib/__tests__/quote_selection_popup.test.js +100 -0
- data/app/javascript/lib/__tests__/touch_drag_tap.test.js +31 -0
- data/app/javascript/lib/__tests__/touch_drag_targets.test.js +293 -0
- data/app/javascript/lib/__tests__/turbo_stream_actions.test.js +29 -1
- data/app/javascript/lib/__tests__/workspace_scroll_restoration.test.js +310 -0
- data/app/javascript/lib/__tests__/workspace_tree_removal.test.js +108 -0
- data/app/javascript/lib/api/__tests__/creatives.test.js +27 -1
- data/app/javascript/lib/api/__tests__/drag_drop.test.js +136 -0
- data/app/javascript/lib/api/__tests__/expansion_intent.test.js +75 -0
- data/app/javascript/lib/api/__tests__/expansion_save_queue.test.js +110 -0
- data/app/javascript/lib/api/__tests__/queue_manager.test.js +237 -0
- data/app/javascript/lib/api/__tests__/queue_reconciliation.test.js +57 -0
- data/app/javascript/lib/api/__tests__/queue_recovery.test.js +28 -0
- data/app/javascript/lib/api/creatives.js +5 -2
- data/app/javascript/lib/api/drag_drop.js +25 -1
- data/app/javascript/lib/api/expansion_intent.js +28 -0
- data/app/javascript/lib/api/expansion_save_queue.js +51 -0
- data/app/javascript/lib/api/queue_completion.js +30 -0
- data/app/javascript/lib/api/queue_manager.js +34 -50
- data/app/javascript/lib/api/queue_reconciliation.js +44 -0
- data/app/javascript/lib/api/queue_recovery.js +24 -0
- data/app/javascript/lib/common_popup.js +7 -7
- data/app/javascript/lib/creative_quote.js +135 -0
- data/app/javascript/lib/creative_title.js +9 -0
- data/app/javascript/lib/creative_tree_invalidation.js +4 -0
- data/app/javascript/lib/dnd/__tests__/bundle_image.test.js +32 -0
- data/app/javascript/lib/dnd/__tests__/envelope.test.js +262 -0
- data/app/javascript/lib/dnd/__tests__/hit_test.test.js +69 -0
- data/app/javascript/lib/dnd/__tests__/preview.test.js +22 -0
- data/app/javascript/lib/dnd/__tests__/registry.test.js +797 -0
- data/app/javascript/lib/dnd/__tests__/session.test.js +213 -0
- data/app/javascript/lib/dnd/__tests__/session_without_window.test.js +15 -0
- data/app/javascript/lib/dnd/__tests__/touch_bridge.test.js +532 -0
- data/app/javascript/lib/dnd/creative_label.js +21 -0
- data/app/javascript/lib/dnd/envelope.js +194 -0
- data/app/javascript/lib/dnd/hit_test.js +42 -0
- data/app/javascript/lib/dnd/preview.js +10 -0
- data/app/javascript/lib/dnd/registry.js +315 -0
- data/app/javascript/lib/dnd/session.js +152 -0
- data/app/javascript/lib/dnd/touch_bridge.js +184 -0
- data/app/javascript/lib/editor/__tests__/code_languages.test.js +1 -5
- data/app/javascript/lib/editor/code_languages.js +0 -1
- data/app/javascript/lib/entity_list_popup.js +45 -0
- data/app/javascript/lib/html_escape.js +12 -0
- data/app/javascript/lib/image_lightbox_pan.js +31 -0
- data/app/javascript/lib/lexical/__tests__/attachment_payload.test.js +12 -189
- data/app/javascript/lib/lexical/__tests__/creative_link_drop.test.js +414 -0
- data/app/javascript/lib/lexical/__tests__/creative_link_node.test.js +50 -0
- data/app/javascript/lib/lexical/__tests__/file_drop.test.js +288 -0
- data/app/javascript/lib/lexical/attachment_node.jsx +21 -42
- data/app/javascript/lib/lexical/attachment_payload.js +0 -274
- data/app/javascript/lib/lexical/attachment_presentation.js +57 -0
- data/app/javascript/lib/lexical/creative_link_drop.js +98 -0
- data/app/javascript/lib/lexical/creative_link_node.js +30 -4
- data/app/javascript/lib/lexical/file_drop.js +106 -0
- data/app/javascript/lib/lexical/ppt_attachment.js +26 -0
- data/app/javascript/lib/lexical/upload_anchor_node.js +16 -0
- data/app/javascript/lib/lexical/upload_nodes.js +6 -0
- data/app/javascript/lib/media_loading.js +25 -0
- data/app/javascript/lib/permission_update.js +21 -0
- data/app/javascript/lib/popup_toggle_guard.js +56 -0
- data/app/javascript/lib/ppt_background.js +48 -0
- data/app/javascript/lib/ppt_chart.js +59 -0
- data/app/javascript/lib/ppt_connector.js +63 -0
- data/app/javascript/lib/ppt_formatting.js +138 -0
- data/app/javascript/lib/ppt_media.js +61 -0
- data/app/javascript/lib/quote_selection_popup.js +67 -0
- data/app/javascript/lib/responsive_images.js +0 -12
- data/app/javascript/lib/search_combobox.js +61 -0
- data/app/javascript/lib/share_modal_links.js +35 -0
- data/app/javascript/lib/touch_drag.js +119 -37
- data/app/javascript/lib/turbo_stream_actions.js +19 -1
- data/app/javascript/lib/utils/__tests__/attachment_rendering.test.js +189 -0
- data/app/javascript/lib/utils/__tests__/creative_link_navigation.test.js +301 -0
- data/app/javascript/lib/utils/__tests__/filter_navigation.test.js +16 -0
- data/app/javascript/lib/utils/__tests__/focus.test.js +144 -0
- data/app/javascript/lib/utils/__tests__/mermaid_math.test.js +24 -0
- data/app/javascript/lib/utils/__tests__/sanitize_description.test.js +10 -0
- data/app/javascript/lib/utils/creative_link_navigation.js +64 -0
- data/app/javascript/lib/utils/filter_navigation.js +16 -2
- data/app/javascript/lib/utils/focus.js +36 -0
- data/app/javascript/lib/utils/markdown.js +0 -4
- data/app/javascript/lib/utils/sanitize_description.js +12 -4
- data/app/javascript/lib/utils/workspace_chat_navigation.js +25 -0
- data/app/javascript/lib/viewport_region.js +20 -0
- data/app/javascript/lib/workspace_scroll_restoration.js +134 -0
- data/app/javascript/lib/workspace_tree_removal.js +91 -0
- data/app/javascript/lib/workspace_tree_visibility.js +25 -0
- data/app/javascript/modules/__tests__/background_creative_create.test.js +114 -0
- data/app/javascript/modules/__tests__/command_args_form.test.js +96 -0
- data/app/javascript/modules/__tests__/command_menu_details.test.js +199 -0
- data/app/javascript/modules/__tests__/creative_inline_dataset.test.js +35 -0
- data/app/javascript/modules/__tests__/creative_inline_payload.test.js +35 -0
- data/app/javascript/modules/__tests__/creative_row_editor_background_create.test.js +2147 -0
- data/app/javascript/modules/__tests__/creative_row_editor_empty_state_recovery.test.js +15 -320
- data/app/javascript/modules/__tests__/creative_row_editor_empty_state_removal.test.js +122 -0
- data/app/javascript/modules/__tests__/creative_row_editor_instant_reveal.test.js +186 -0
- data/app/javascript/modules/__tests__/creative_row_editor_save_paths.test.js +1132 -0
- data/app/javascript/modules/__tests__/creative_save_state.test.js +165 -0
- data/app/javascript/modules/__tests__/creative_type_editor.test.js +203 -0
- data/app/javascript/modules/__tests__/failed_creative_save.test.js +65 -0
- data/app/javascript/modules/__tests__/html_content_empty.test.js +11 -0
- data/app/javascript/modules/__tests__/integration_wizard.test.js +139 -0
- data/app/javascript/modules/__tests__/mention_menu.test.js +190 -0
- data/app/javascript/modules/__tests__/notice_bar_motion.test.js +132 -0
- data/app/javascript/modules/__tests__/notice_bar_sheet.test.js +108 -0
- data/app/javascript/modules/__tests__/notice_bar_spotlight.test.js +109 -0
- data/app/javascript/modules/__tests__/notice_bar_storage.test.js +31 -0
- data/app/javascript/modules/__tests__/notice_bar_toasts.test.js +71 -0
- data/app/javascript/modules/__tests__/notice_bar_view.test.js +89 -0
- data/app/javascript/modules/__tests__/pdf_assets.test.js +26 -0
- data/app/javascript/modules/__tests__/pdf_document.test.js +231 -0
- data/app/javascript/modules/__tests__/persisted_creative_tree.test.js +48 -0
- data/app/javascript/modules/__tests__/ppt_viewer.test.js +219 -0
- data/app/javascript/modules/__tests__/queued_creative_row.test.js +206 -0
- data/app/javascript/modules/__tests__/recovered_creative_position.test.js +57 -0
- data/app/javascript/modules/__tests__/slide_view_attachments.test.js +71 -0
- data/app/javascript/modules/__tests__/support/inline_editor_dom.js +24 -0
- data/app/javascript/modules/__tests__/viewer_navigation.test.js +42 -0
- data/app/javascript/modules/background_creative_create.js +326 -0
- data/app/javascript/modules/command_args_form.js +32 -30
- data/app/javascript/modules/command_menu.js +91 -17
- data/app/javascript/modules/creative_inline_dataset.js +34 -0
- data/app/javascript/modules/creative_inline_payload.js +10 -14
- data/app/javascript/modules/creative_removal.js +39 -0
- data/app/javascript/modules/creative_row_editor.js +383 -402
- data/app/javascript/modules/creative_save_state.js +141 -0
- data/app/javascript/modules/creative_type_editor.js +139 -0
- data/app/javascript/modules/failed_creative_save.js +42 -0
- data/app/javascript/modules/html_content_empty.js +5 -3
- data/app/javascript/modules/integration_wizard.js +68 -19
- data/app/javascript/modules/keep_goal_text.js +4 -0
- data/app/javascript/modules/lexical_inline_editor.jsx +9 -2
- data/app/javascript/modules/mention_menu.js +34 -22
- data/app/javascript/modules/notice_bar/__tests__/refresh.test.js +177 -0
- data/app/javascript/modules/notice_bar/motion.js +59 -0
- data/app/javascript/modules/notice_bar/refresh.js +53 -0
- data/app/javascript/modules/notice_bar/sheet.js +102 -0
- data/app/javascript/modules/notice_bar/spotlight.js +78 -0
- data/app/javascript/modules/notice_bar/storage.js +14 -0
- data/app/javascript/modules/notice_bar/toasts.js +49 -0
- data/app/javascript/modules/notice_bar/view.js +101 -0
- data/app/javascript/modules/pdf_document.js +65 -0
- data/app/javascript/modules/pending_creative_sync.js +23 -0
- data/app/javascript/modules/persisted_creative_tree.js +39 -0
- data/app/javascript/modules/ppt_viewer.js +76 -0
- data/app/javascript/modules/queued_creative_row.js +128 -0
- data/app/javascript/modules/recovered_creative_position.js +52 -0
- data/app/javascript/modules/slide_view.js +9 -3
- data/app/javascript/modules/viewer_navigation.js +16 -0
- data/app/javascript/slide_view.js +9 -0
- data/app/jobs/collavre/agent_provisioning_sync_job.rb +79 -0
- data/app/jobs/collavre/ai_agent_job.rb +181 -160
- data/app/jobs/collavre/approval_continuation_job.rb +102 -0
- data/app/jobs/collavre/approval_gate_resume_job.rb +22 -0
- data/app/jobs/collavre/async_approval_resume_job.rb +20 -0
- data/app/jobs/collavre/async_approval_sweep_job.rb +44 -0
- data/app/jobs/collavre/batch_destroy_comments_job.rb +17 -0
- data/app/jobs/collavre/cancel_offline_delegated_tasks_job.rb +35 -82
- data/app/jobs/collavre/cdn_invalidation_job.rb +62 -0
- data/app/jobs/collavre/claude_approval_resume_job.rb +15 -0
- data/app/jobs/collavre/comment_push_delivery_sweep_job.rb +9 -1
- data/app/jobs/collavre/compress_job.rb +3 -27
- data/app/jobs/collavre/creative_broadcast_job.rb +13 -16
- data/app/jobs/collavre/creative_history_notice_job.rb +40 -0
- data/app/jobs/collavre/creative_history_prune_job.rb +86 -0
- data/app/jobs/collavre/creative_tree_invalidation_job.rb +33 -0
- data/app/jobs/collavre/cron_action_job.rb +24 -7
- data/app/jobs/collavre/cron_scheduler_job.rb +44 -3
- data/app/jobs/collavre/drop_trigger_job.rb +35 -30
- data/app/jobs/collavre/endpoint_health_probe_job.rb +23 -0
- data/app/jobs/collavre/endpoint_health_sweep_job.rb +22 -0
- data/app/jobs/collavre/gateway_health_probe_job.rb +33 -0
- data/app/jobs/collavre/gateway_health_sweep_job.rb +22 -0
- data/app/jobs/collavre/inline_agent_replay_job.rb +32 -0
- data/app/jobs/collavre/keep_loop_reconcile_job.rb +57 -0
- data/app/jobs/collavre/merge_comments_job.rb +6 -30
- data/app/jobs/collavre/offline_task_sweep_job.rb +44 -0
- data/app/jobs/collavre/permission_cache_job.rb +19 -10
- data/app/jobs/collavre/purge_unreferenced_blob_job.rb +19 -0
- data/app/jobs/collavre/push_notification_job.rb +4 -3
- data/app/jobs/collavre/recover_interrupted_tasks_job.rb +79 -0
- data/app/jobs/collavre/resume_suspended_tasks_job.rb +29 -0
- data/app/jobs/collavre/solid_queue_worker_watchdog_job.rb +108 -0
- data/app/jobs/collavre/trigger_loop_check_job.rb +104 -105
- data/app/jobs/collavre/trigger_loop_verify_job.rb +51 -82
- data/app/jobs/collavre/workflow_outbox_job.rb +10 -0
- data/app/jobs/collavre/workflow_push_job.rb +11 -0
- data/app/jobs/collavre/workflow_sweep_job.rb +11 -0
- data/app/jobs/concerns/collavre/comment_serializable.rb +3 -1
- data/app/jobs/concerns/collavre/dispatch_admission.rb +95 -0
- data/app/jobs/concerns/collavre/trigger_loop_helpers.rb +178 -13
- data/app/models/collavre/agent_gateway.rb +76 -0
- data/app/models/collavre/agent_workspace.rb +42 -7
- data/app/models/collavre/blob_access_flag.rb +24 -0
- data/app/models/collavre/channel.rb +17 -0
- data/app/models/collavre/comment/approvable.rb +14 -1
- data/app/models/collavre/comment/approval_gate.rb +98 -0
- data/app/models/collavre/comment/batch_destruction.rb +173 -0
- data/app/models/collavre/comment/broadcastable.rb +18 -0
- data/app/models/collavre/comment/bulk_follow_up_jobs.rb +29 -0
- data/app/models/collavre/comment/claude_channel_permission.rb +59 -5
- data/app/models/collavre/comment/creative_quote.rb +55 -0
- data/app/models/collavre/comment/image_cdn_eviction.rb +36 -0
- data/app/models/collavre/comment/notifiable.rb +7 -6
- data/app/models/collavre/comment/suspension_notice.rb +20 -0
- data/app/models/collavre/comment/topic_membership.rb +21 -1
- data/app/models/collavre/comment/trigger_loop_resume.rb +77 -0
- data/app/models/collavre/comment.rb +30 -106
- data/app/models/collavre/comment_notification_delivery.rb +19 -8
- data/app/models/collavre/comment_version.rb +4 -0
- data/app/models/collavre/creative/ai_write_policy.rb +26 -0
- data/app/models/collavre/creative/contextual.rb +153 -0
- data/app/models/collavre/creative/describable.rb +34 -25
- data/app/models/collavre/creative/history_trackable.rb +104 -0
- data/app/models/collavre/creative/linkable.rb +21 -1
- data/app/models/collavre/creative/permissible.rb +12 -20
- data/app/models/collavre/creative/publishable.rb +65 -0
- data/app/models/collavre/creative/type_selectable.rb +25 -0
- data/app/models/collavre/creative.rb +26 -110
- data/app/models/collavre/creative_change.rb +55 -0
- data/app/models/collavre/creative_change_set.rb +71 -0
- data/app/models/collavre/creative_share.rb +19 -0
- data/app/models/collavre/current.rb +8 -1
- data/app/models/collavre/llm_model.rb +1 -0
- data/app/models/collavre/llm_usage/requester.rb +9 -0
- data/app/models/collavre/llm_usage.rb +33 -0
- data/app/models/collavre/mcp_tool.rb +25 -3
- data/app/models/collavre/orchestrator_policy.rb +25 -29
- data/app/models/collavre/preview_channel.rb +1 -15
- data/app/models/collavre/retired_task_execution.rb +9 -0
- data/app/models/collavre/system_setting.rb +60 -8
- data/app/models/collavre/task/approval_gate_cleanup.rb +23 -0
- data/app/models/collavre/task/async_approval.rb +30 -0
- data/app/models/collavre/task.rb +76 -30
- data/app/models/collavre/task_merged_instruction.rb +6 -0
- data/app/models/collavre/tool_usage/requester.rb +9 -0
- data/app/models/collavre/tool_usage.rb +69 -0
- data/app/models/collavre/topic.rb +41 -3
- data/app/models/collavre/user/ai_capabilities.rb +38 -0
- data/app/models/collavre/user.rb +28 -24
- data/app/models/collavre/user_creative_preference.rb +25 -1
- data/app/models/collavre/user_notice.rb +64 -0
- data/app/models/collavre/workflow/chain.rb +27 -0
- data/app/models/collavre/workflow/execution.rb +28 -0
- data/app/models/collavre/workflow/outbox.rb +43 -0
- data/app/models/collavre/workflow/receipt.rb +26 -0
- data/app/models/concerns/collavre/agent_liveness.rb +95 -0
- data/app/models/concerns/collavre/agent_run_options.rb +45 -0
- data/app/models/concerns/collavre/ai_agent_resolvable.rb +30 -7
- data/app/models/concerns/collavre/comment/dispatch_revocation.rb +99 -0
- data/app/models/concerns/collavre/comment/keep_loop.rb +166 -0
- data/app/models/concerns/collavre/creation_events.rb +25 -0
- data/app/models/concerns/collavre/creative/trigger_loop.rb +57 -0
- data/app/models/concerns/collavre/creative_history_topic.rb +34 -0
- data/app/models/concerns/collavre/creative_reserved_topics.rb +25 -0
- data/app/models/concerns/collavre/has_inbox_creative.rb +9 -1
- data/app/models/concerns/collavre/system_agent_identity.rb +13 -0
- data/app/models/concerns/collavre/task/replay_loop_completion.rb +78 -0
- data/app/models/concerns/collavre/task/trigger_loop_completion.rb +126 -0
- data/app/models/concerns/collavre/task/usage_attribution_tracking.rb +28 -0
- data/app/models/concerns/collavre/task/workflow_completion.rb +59 -0
- data/app/services/collavre/agent_health/endpoint_request.rb +64 -0
- data/app/services/collavre/agent_health/openai_endpoint_checker.rb +77 -0
- data/app/services/collavre/agent_health/probe.rb +47 -0
- data/app/services/collavre/agent_health.rb +43 -0
- data/app/services/collavre/agent_session_abort.rb +2 -2
- data/app/services/collavre/agent_tool_permission.rb +43 -0
- data/app/services/collavre/ai_agent/a2a_dispatcher.rb +22 -4
- data/app/services/collavre/ai_agent/agent_lifecycle_manager.rb +16 -1
- data/app/services/collavre/ai_agent/approval_conversation.rb +60 -0
- data/app/services/collavre/ai_agent/approval_gate_handler.rb +37 -0
- data/app/services/collavre/ai_agent/approval_handler.rb +8 -1
- data/app/services/collavre/ai_agent/budgeted_tree_renderer.rb +80 -0
- data/app/services/collavre/ai_agent/chat_history_window.rb +87 -0
- data/app/services/collavre/ai_agent/claude_channel_adapter.rb +60 -9
- data/app/services/collavre/ai_agent/creative_quote_context.rb +66 -0
- data/app/services/collavre/ai_agent/history_notice.rb +94 -0
- data/app/services/collavre/ai_agent/message_builder.rb +160 -113
- data/app/services/collavre/ai_agent/prompt_budget.rb +142 -0
- data/app/services/collavre/ai_agent/referenced_creative_renderer.rb +101 -0
- data/app/services/collavre/ai_agent/reply_placeholder.rb +28 -0
- data/app/services/collavre/ai_agent/response_finalizer.rb +15 -1
- data/app/services/collavre/ai_agent/review_handler.rb +17 -17
- data/app/services/collavre/ai_agent/screening_approval_handler.rb +26 -0
- data/app/services/collavre/ai_agent/session_context_resolver.rb +6 -1
- data/app/services/collavre/ai_agent/task_claim_service.rb +55 -3
- data/app/services/collavre/ai_agent/task_reply_service.rb +30 -7
- data/app/services/collavre/ai_agent/task_workspace_user.rb +20 -0
- data/app/services/collavre/ai_agent/turn_screening.rb +132 -0
- data/app/services/collavre/ai_agent/workspace_authentication.rb +74 -0
- data/app/services/collavre/ai_agent_service.rb +49 -74
- data/app/services/collavre/ai_approval_summary.rb +51 -0
- data/app/services/collavre/ai_client/approval_gate.rb +90 -0
- data/app/services/collavre/ai_client/cli_tool_events.rb +100 -0
- data/app/services/collavre/ai_client/decision.rb +101 -0
- data/app/services/collavre/ai_client/error_handling.rb +67 -0
- data/app/services/collavre/ai_client/provider_context.rb +69 -0
- data/app/services/collavre/ai_client.rb +58 -209
- data/app/services/collavre/ai_usage_tracking.rb +93 -0
- data/app/services/collavre/auto_theme_generator.rb +5 -8
- data/app/services/collavre/blob_access.rb +166 -0
- data/app/services/collavre/cdn_invalidation.rb +67 -0
- data/app/services/collavre/claude_approval_handoff.rb +28 -0
- data/app/services/collavre/cli_proxy/adapter_engine.rb +27 -0
- data/app/services/collavre/cli_proxy/client.rb +56 -13
- data/app/services/collavre/cli_proxy/engine_unauthenticated_error.rb +31 -0
- data/app/services/collavre/cli_proxy/health_probe.rb +137 -0
- data/app/services/collavre/cli_proxy/inline_login.rb +239 -0
- data/app/services/collavre/cli_proxy/inline_replay_admission.rb +57 -0
- data/app/services/collavre/cli_proxy/replay_claims.rb +48 -0
- data/app/services/collavre/cli_proxy/replay_routing.rb +43 -0
- data/app/services/collavre/cli_proxy/replay_workspace.rb +53 -0
- data/app/services/collavre/cli_proxy/run_options.rb +90 -0
- data/app/services/collavre/command_menu_service.rb +18 -4
- data/app/services/collavre/comment_move_service.rb +5 -1
- data/app/services/collavre/comment_resend_service/cleanup.rb +20 -0
- data/app/services/collavre/comment_resend_service.rb +125 -0
- data/app/services/collavre/comment_snapshot_restore_service.rb +16 -10
- data/app/services/collavre/comments/action_executor.rb +15 -25
- data/app/services/collavre/comments/approval_gate_decision.rb +54 -0
- data/app/services/collavre/comments/approved_tool_invocation.rb +37 -0
- data/app/services/collavre/comments/async_approval_decision.rb +41 -0
- data/app/services/collavre/comments/command_processor.rb +14 -0
- data/app/services/collavre/comments/creative_quote_rejection_notice.rb +37 -0
- data/app/services/collavre/comments/creative_quote_review.rb +54 -0
- data/app/services/collavre/comments/keep_command.rb +80 -0
- data/app/services/collavre/comments/list_response.rb +30 -2
- data/app/services/collavre/comments/topic_command.rb +6 -27
- data/app/services/collavre/creatives/agent_turn_history.rb +15 -0
- data/app/services/collavre/creatives/ai_write_policy.rb +36 -0
- data/app/services/collavre/creatives/change_set_apply_service.rb +309 -0
- data/app/services/collavre/creatives/change_set_diff.rb +216 -0
- data/app/services/collavre/creatives/change_set_restore_service.rb +20 -0
- data/app/services/collavre/creatives/change_set_revert_service.rb +21 -0
- data/app/services/collavre/creatives/change_set_visibility.rb +108 -0
- data/app/services/collavre/creatives/children_index.rb +19 -8
- data/app/services/collavre/creatives/create_service.rb +3 -1
- data/app/services/collavre/creatives/creation_revert_policy.rb +35 -0
- data/app/services/collavre/creatives/creative_quote_turn.rb +96 -0
- data/app/services/collavre/creatives/description_image_dimensions.rb +50 -0
- data/app/services/collavre/creatives/destroy_service.rb +18 -2
- data/app/services/collavre/creatives/draft_change_set_applicator.rb +121 -0
- data/app/services/collavre/creatives/draft_change_set_capture.rb +206 -0
- data/app/services/collavre/creatives/draft_change_set_reject_service.rb +45 -0
- data/app/services/collavre/creatives/draft_conflict_dependency_pruner.rb +110 -0
- data/app/services/collavre/creatives/draft_link_authorization.rb +61 -0
- data/app/services/collavre/creatives/draft_link_progress_reconciliation.rb +36 -0
- data/app/services/collavre/creatives/drop_trigger_missing_agent_notifier.rb +31 -0
- data/app/services/collavre/creatives/expansion_save_order.rb +70 -0
- data/app/services/collavre/creatives/file_drop_service.rb +49 -0
- data/app/services/collavre/creatives/filter_pipeline.rb +7 -4
- data/app/services/collavre/creatives/filter_state.rb +25 -0
- data/app/services/collavre/creatives/filters/base_filter.rb +3 -2
- data/app/services/collavre/creatives/filters/cron_filter.rb +19 -0
- data/app/services/collavre/creatives/filters/reaction_filter.rb +17 -0
- data/app/services/collavre/creatives/historical_snapshot_authorization.rb +108 -0
- data/app/services/collavre/creatives/history.rb +302 -0
- data/app/services/collavre/creatives/history_page.rb +61 -0
- data/app/services/collavre/creatives/importer.rb +19 -5
- data/app/services/collavre/creatives/index_query.rb +6 -12
- data/app/services/collavre/creatives/keep_agent_scope.rb +29 -0
- data/app/services/collavre/creatives/origin_chain_preloader.rb +23 -0
- data/app/services/collavre/creatives/permission_cache_builder.rb +72 -42
- data/app/services/collavre/creatives/permission_checker.rb +51 -4
- data/app/services/collavre/creatives/permission_filter.rb +14 -1
- data/app/services/collavre/creatives/progress_propagation_targets.rb +36 -0
- data/app/services/collavre/creatives/propagated_change_authorization.rb +142 -0
- data/app/services/collavre/creatives/reorderer.rb +128 -49
- data/app/services/collavre/creatives/snapshot_assignment.rb +25 -0
- data/app/services/collavre/creatives/snapshot_comparison.rb +14 -0
- data/app/services/collavre/creatives/tree_builder.rb +40 -13
- data/app/services/collavre/creatives/tree_formatter.rb +1 -1
- data/app/services/collavre/creatives/trigger_action_command.rb +222 -0
- data/app/services/collavre/creatives/type_transition.rb +58 -0
- data/app/services/collavre/creatives/workspace_expansion_candidates.rb +24 -0
- data/app/services/collavre/creatives/workspace_expansion_order.rb +58 -0
- data/app/services/collavre/creatives/workspace_expansion_presence.rb +38 -0
- data/app/services/collavre/creatives/workspace_tree_builder.rb +19 -11
- data/app/services/collavre/crons/change_broadcaster.rb +35 -0
- data/app/services/collavre/crons/recurring_task_arguments.rb +10 -2
- data/app/services/collavre/crons/recurring_task_index.rb +78 -0
- data/app/services/collavre/decision_questions.rb +125 -0
- data/app/services/collavre/http_client.rb +42 -6
- data/app/services/collavre/inbox_reply_service.rb +1 -0
- data/app/services/collavre/keep_loop.rb +84 -0
- data/app/services/collavre/kollavy/access_scope.rb +84 -0
- data/app/services/collavre/kollavy/identity.rb +25 -0
- data/app/services/collavre/kollavy.rb +153 -0
- data/app/services/collavre/llm_usage/attribution.rb +99 -0
- data/app/services/collavre/llm_usage/history_omission.rb +30 -0
- data/app/services/collavre/llm_usage/recorder.rb +59 -0
- data/app/services/collavre/llm_usage/report.rb +116 -0
- data/app/services/collavre/llm_usage/token_normalizer.rb +54 -0
- data/app/services/collavre/markdown_converter.rb +45 -41
- data/app/services/collavre/mcp_service.rb +61 -35
- data/app/services/collavre/mcp_tool_access.rb +40 -0
- data/app/services/collavre/mcp_tool_categories.rb +57 -0
- data/app/services/collavre/mcp_tool_registrar.rb +217 -0
- data/app/services/collavre/mcp_tool_registry.rb +38 -0
- data/app/services/collavre/mention_parser.rb +48 -14
- data/app/services/collavre/notices/feed.rb +127 -0
- data/app/services/collavre/notices/onboarding_replay.rb +17 -0
- data/app/services/collavre/notices/refresh_deadline.rb +15 -0
- data/app/services/collavre/notices/tracker.rb +68 -0
- data/app/services/collavre/openai_endpoint.rb +24 -0
- data/app/services/collavre/orchestration/agent_context_builder.rb +3 -1
- data/app/services/collavre/orchestration/agent_orchestrator.rb +100 -451
- data/app/services/collavre/orchestration/agent_recovery_trigger.rb +16 -0
- data/app/services/collavre/orchestration/arbiter.rb +15 -8
- data/app/services/collavre/orchestration/deferred_trigger_scope.rb +12 -1
- data/app/services/collavre/orchestration/delivery_record.rb +31 -83
- data/app/services/collavre/orchestration/dispatch_records.rb +52 -0
- data/app/services/collavre/orchestration/execution_fence.rb +97 -0
- data/app/services/collavre/orchestration/job_enqueue.rb +150 -0
- data/app/services/collavre/orchestration/keep_dispatch_admission.rb +76 -0
- data/app/services/collavre/orchestration/keep_dispatch_restoration.rb +57 -0
- data/app/services/collavre/orchestration/keep_loop_ownership.rb +152 -0
- data/app/services/collavre/orchestration/keep_queued_dispatches.rb +73 -0
- data/app/services/collavre/orchestration/loop_breaker.rb +10 -5
- data/app/services/collavre/orchestration/matcher.rb +123 -50
- data/app/services/collavre/orchestration/offline_task_grace.rb +50 -0
- data/app/services/collavre/orchestration/policy_resolver.rb +58 -7
- data/app/services/collavre/orchestration/resource_tracker.rb +4 -1
- data/app/services/collavre/orchestration/restored_dispatch_admission.rb +103 -0
- data/app/services/collavre/orchestration/restored_dispatch_context.rb +15 -0
- data/app/services/collavre/orchestration/resume_context.rb +90 -0
- data/app/services/collavre/orchestration/scheduler.rb +9 -2
- data/app/services/collavre/orchestration/selection.rb +40 -7
- data/app/services/collavre/orchestration/solid_queue_retry_recovery.rb +54 -0
- data/app/services/collavre/orchestration/task_coalescer.rb +52 -22
- data/app/services/collavre/orchestration/task_resumer.rb +408 -0
- data/app/services/collavre/orchestration/waiting_notice_manager.rb +289 -0
- data/app/services/collavre/orchestration/workflow_dispatch.rb +47 -0
- data/app/services/collavre/orchestration/workflow_routing.rb +96 -0
- data/app/services/collavre/ppt_archive.rb +123 -0
- data/app/services/collavre/ppt_backgrounds.rb +97 -0
- data/app/services/collavre/ppt_colors.rb +104 -0
- data/app/services/collavre/ppt_connectors.rb +33 -0
- data/app/services/collavre/ppt_diagrams.rb +50 -0
- data/app/services/collavre/ppt_formatting.rb +134 -0
- data/app/services/collavre/ppt_geometry.rb +92 -0
- data/app/services/collavre/ppt_importer.rb +45 -64
- data/app/services/collavre/ppt_inheritance.rb +122 -0
- data/app/services/collavre/ppt_inline_media.rb +19 -0
- data/app/services/collavre/ppt_media.rb +49 -0
- data/app/services/collavre/ppt_numbering.rb +63 -0
- data/app/services/collavre/ppt_paragraphs.rb +52 -0
- data/app/services/collavre/ppt_preview.rb +12 -0
- data/app/services/collavre/ppt_renderer.rb +259 -0
- data/app/services/collavre/ppt_shape_fills.rb +35 -0
- data/app/services/collavre/ppt_shape_styles.rb +81 -0
- data/app/services/collavre/ppt_tables.rb +35 -0
- data/app/services/collavre/public_asset_allowlist.rb +41 -0
- data/app/services/collavre/quota/agent_execution.rb +31 -0
- data/app/services/collavre/quota/exceeded_error.rb +48 -0
- data/app/services/collavre/quota/notice.rb +15 -0
- data/app/services/collavre/quota/pending_dispatch.rb +35 -0
- data/app/services/collavre/quota/probe.rb +44 -0
- data/app/services/collavre/quota/recovery.rb +97 -0
- data/app/services/collavre/quota/retry_time.rb +65 -0
- data/app/services/collavre/ruby_llm_interaction_logger.rb +17 -7
- data/app/services/collavre/screening/gate.rb +47 -0
- data/app/services/collavre/screening/input.rb +30 -0
- data/app/services/collavre/screening/scope.rb +34 -0
- data/app/services/collavre/screening/screener.rb +57 -0
- data/app/services/collavre/screening/screener_resolver.rb +23 -0
- data/app/services/collavre/screening/turn_guard.rb +196 -0
- data/app/services/collavre/screening/verdict.rb +30 -0
- data/app/services/collavre/screening.rb +65 -0
- data/app/services/collavre/source_browser.rb +186 -0
- data/app/services/collavre/system_events/context_builder.rb +53 -12
- data/app/services/collavre/system_events/dispatcher.rb +26 -17
- data/app/services/collavre/system_events/vocabulary.rb +4 -1
- data/app/services/collavre/task_execution_time.rb +33 -0
- data/app/services/collavre/tool_approval_policy.rb +42 -0
- data/app/services/collavre/tool_description.rb +35 -0
- data/app/services/collavre/tool_usage/approved_invocation.rb +28 -0
- data/app/services/collavre/tool_usage/cli_proxy_recorder.rb +100 -0
- data/app/services/collavre/tool_usage/mcp_call.rb +52 -0
- data/app/services/collavre/tool_usage/recorder.rb +34 -0
- data/app/services/collavre/tool_usage/report.rb +38 -0
- data/app/services/collavre/tools/approval_request_service.rb +54 -0
- data/app/services/collavre/tools/async_approval_request.rb +58 -0
- data/app/services/collavre/tools/creative_attach_files_service.rb +10 -2
- data/app/services/collavre/tools/creative_batch_service.rb +90 -10
- data/app/services/collavre/tools/creative_create_service.rb +33 -4
- data/app/services/collavre/tools/creative_import_service.rb +26 -3
- data/app/services/collavre/tools/creative_link_service.rb +75 -0
- data/app/services/collavre/tools/creative_list_attachments_service.rb +2 -2
- data/app/services/collavre/tools/creative_remove_attachment_service.rb +30 -5
- data/app/services/collavre/tools/creative_reorder_service.rb +111 -0
- data/app/services/collavre/tools/creative_retrieval_service.rb +27 -21
- data/app/services/collavre/tools/creative_unlink_service.rb +60 -0
- data/app/services/collavre/tools/creative_update_service.rb +88 -81
- data/app/services/collavre/tools/cron_cancel_service.rb +3 -17
- data/app/services/collavre/tools/cron_create_service.rb +91 -36
- data/app/services/collavre/tools/cron_list_service.rb +2 -2
- data/app/services/collavre/tools/cron_update_service.rb +5 -19
- data/app/services/collavre/tools/keep_service.rb +42 -0
- data/app/services/collavre/tools/source_list_service.rb +25 -0
- data/app/services/collavre/tools/source_read_service.rb +26 -0
- data/app/services/collavre/tools/source_search_service.rb +25 -0
- data/app/services/collavre/tools/source_tool_support.rb +39 -0
- data/app/services/collavre/tools/task_descendants.rb +32 -0
- data/app/services/collavre/tools/task_lineage.rb +46 -0
- data/app/services/collavre/tools/task_status_service.rb +61 -0
- data/app/services/collavre/tools/task_tracking.rb +67 -0
- data/app/services/collavre/tools/topic_authorizer.rb +2 -2
- data/app/services/collavre/tools/topic_message_create_service.rb +35 -17
- data/app/services/collavre/tools/topic_move_service.rb +3 -4
- data/app/services/collavre/tools/topic_tasks_service.rb +42 -0
- data/app/services/collavre/tools/topic_update_service.rb +1 -1
- data/app/services/collavre/topic_branch_service.rb +1 -0
- data/app/services/collavre/topics/active_topic_snapshot.rb +30 -0
- data/app/services/collavre/topics/agent_resolver.rb +7 -1
- data/app/services/collavre/topics/cron_badge_decorator.rb +32 -0
- data/app/services/collavre/topics/last_topic_preference_payload.rb +1 -0
- data/app/services/collavre/topics/message_page.rb +1 -1
- data/app/services/collavre/topics/orphaned_cron_notifier.rb +33 -14
- data/app/services/collavre/topics/pin_rejection.rb +16 -2
- data/app/services/collavre/topics/reserved_name.rb +6 -0
- data/app/services/collavre/topics/serializer.rb +10 -3
- data/app/services/collavre/topics/topic_move.rb +21 -2
- data/app/services/collavre/trigger_loop_config.rb +15 -0
- data/app/services/collavre/workflow/admission.rb +109 -0
- data/app/services/collavre/workflow/child_context.rb +35 -0
- data/app/services/collavre/workflow/conditions.rb +79 -0
- data/app/services/collavre/workflow/context_preloader.rb +48 -0
- data/app/services/collavre/workflow/continuation.rb +16 -0
- data/app/services/collavre/workflow/dispatch_identity.rb +25 -0
- data/app/services/collavre/workflow/dispatch_outcome.rb +9 -0
- data/app/services/collavre/workflow/editor.rb +79 -0
- data/app/services/collavre/workflow/envelope_validation.rb +18 -0
- data/app/services/collavre/workflow/fallback_delivery.rb +59 -0
- data/app/services/collavre/workflow/fixed_anchor.rb +32 -0
- data/app/services/collavre/workflow/human_handoff.rb +39 -0
- data/app/services/collavre/workflow/inbox_notice.rb +56 -0
- data/app/services/collavre/workflow/invocation.rb +60 -0
- data/app/services/collavre/workflow/materialization.rb +41 -0
- data/app/services/collavre/workflow/publication.rb +55 -0
- data/app/services/collavre/workflow/push_delivery.rb +97 -0
- data/app/services/collavre/workflow/recovery.rb +62 -0
- data/app/services/collavre/workflow/resolver.rb +83 -0
- data/app/services/collavre/workflow/rule.rb +189 -0
- data/app/services/collavre/workflow/safety.rb +61 -0
- data/app/services/collavre/workflow/settlement.rb +60 -0
- data/app/services/collavre/workflow/source_message.rb +39 -0
- data/app/services/collavre/workflow/task_admission.rb +114 -0
- data/app/views/collavre/admin/settings/_system_tab.html.erb +49 -11
- data/app/views/collavre/agent_connections/show.html.erb +76 -69
- data/app/views/collavre/agent_gateways/_form.html.erb +69 -55
- data/app/views/collavre/agent_gateways/edit.html.erb +4 -2
- data/app/views/collavre/agent_gateways/index.html.erb +48 -51
- data/app/views/collavre/agent_gateways/new.html.erb +4 -2
- data/app/views/collavre/agent_models/_editor.html.erb +20 -0
- data/app/views/collavre/comments/_activity_log_details.html.erb +10 -4
- data/app/views/collavre/comments/_agent_run_options.html.erb +12 -0
- data/app/views/collavre/comments/_approval_gate.html.erb +8 -0
- data/app/views/collavre/comments/_comment.html.erb +45 -8
- data/app/views/collavre/comments/_comments_popup.html.erb +81 -12
- data/app/views/collavre/comments/_creative_quote_review.html.erb +29 -0
- data/app/views/collavre/comments/_feature_card.html.erb +1 -1
- data/app/views/collavre/comments/_loading.html.erb +7 -0
- data/app/views/collavre/comments/_reaction_buttons.html.erb +7 -0
- data/app/views/collavre/comments/_reaction_picker.html.erb +1 -8
- data/app/views/collavre/comments/_run_options.html.erb +4 -0
- data/app/views/collavre/comments/_thinking_icon.html.erb +7 -0
- data/app/views/collavre/creative_change_sets/_detail.html.erb +88 -0
- data/app/views/collavre/creative_change_sets/_list.html.erb +40 -0
- data/app/views/collavre/creative_change_sets/_undo_toast.html.erb +22 -0
- data/app/views/collavre/creatives/_import_upload_zone.html.erb +1 -1
- data/app/views/collavre/creatives/_inline_edit_form.html.erb +14 -2
- data/app/views/collavre/creatives/_public_meta.html.erb +16 -0
- data/app/views/collavre/creatives/_share_modal.html.erb +9 -0
- data/app/views/collavre/creatives/_type_selector.html.erb +15 -0
- data/app/views/collavre/creatives/_workflow_panel.html.erb +71 -0
- data/app/views/collavre/creatives/_workspace_tree.html.erb +4 -1
- data/app/views/collavre/creatives/edit.html.erb +7 -4
- data/app/views/collavre/creatives/index.html.erb +74 -11
- data/app/views/collavre/creatives/ppt_previews/_markdown_document.html.erb +17 -0
- data/app/views/collavre/creatives/ppt_previews/show.html.erb +38 -0
- data/app/views/collavre/creatives/show.html.erb +1 -1
- data/app/views/collavre/features/index.html.erb +4 -4
- data/app/views/collavre/inline_agent_logins/show.html.erb +31 -0
- data/app/views/collavre/llm_usages/_metrics.html.erb +13 -0
- data/app/views/collavre/llm_usages/index.html.erb +88 -0
- data/app/views/collavre/notices/_payload.html.erb +5 -0
- data/app/views/collavre/notices/_zone.html.erb +20 -0
- data/app/views/collavre/seo/sitemap.xml.builder +8 -0
- data/app/views/collavre/seo/sitemap_index.xml.builder +8 -0
- data/app/views/collavre/shared/_creative_move_modal.html.erb +59 -0
- data/app/views/collavre/shared/_link_creative_modal.html.erb +2 -0
- data/app/views/collavre/shared/navigation/_help_button.html.erb +21 -2
- data/app/views/collavre/shared/navigation/_search_form.html.erb +14 -1
- data/app/views/collavre/users/_llm_fields.html.erb +26 -31
- data/app/views/collavre/users/_model_picker.html.erb +36 -0
- data/app/views/collavre/users/_tool_details.html.erb +7 -0
- data/app/views/collavre/users/_tool_selection.html.erb +51 -0
- data/app/views/collavre/users/edit_ai.html.erb +29 -24
- data/app/views/collavre/users/index.html.erb +96 -80
- data/app/views/collavre/users/new_ai.html.erb +4 -22
- data/app/views/collavre/users/show.html.erb +12 -29
- data/app/views/layouts/collavre/landing.html.erb +14 -0
- data/app/views/layouts/collavre/slide.html.erb +4 -1
- data/config/initializers/active_storage_access.rb +34 -0
- data/config/initializers/agent_health.rb +7 -0
- data/config/initializers/kollavy_feature_card.rb +11 -0
- data/config/initializers/mcp_discovery_access.rb +17 -0
- data/config/initializers/mcp_tool_usage.rb +17 -0
- data/config/initializers/meta_tool_access.rb +35 -0
- data/config/initializers/rate_limits.rb +4 -0
- data/config/initializers/ruby_llm_openai_cli_events.rb +43 -0
- data/config/initializers/ruby_llm_openai_reasoning_content.rb +8 -7
- data/config/initializers/screening_integration_settings.rb +5 -0
- data/config/initializers/task_recovery.rb +30 -0
- data/config/locales/admin.en.yml +19 -3
- data/config/locales/admin.ko.yml +19 -3
- data/config/locales/agent_gateway.en.yml +6 -2
- data/config/locales/agent_gateway.ko.yml +6 -2
- data/config/locales/ai_agent.en.yml +11 -0
- data/config/locales/ai_agent.ko.yml +11 -0
- data/config/locales/approval_gate.en.yml +11 -0
- data/config/locales/approval_gate.ko.yml +11 -0
- data/config/locales/claude_channel.en.yml +1 -0
- data/config/locales/claude_channel.ko.yml +1 -0
- data/config/locales/comments.en.yml +80 -18
- data/config/locales/comments.ko.yml +80 -18
- data/config/locales/contacts.en.yml +0 -5
- data/config/locales/contacts.ko.yml +0 -5
- data/config/locales/contexts.en.yml +6 -0
- data/config/locales/contexts.ko.yml +6 -0
- data/config/locales/creative_history.en.yml +62 -0
- data/config/locales/creative_history.ko.yml +56 -0
- data/config/locales/creative_types.en.yml +19 -0
- data/config/locales/creative_types.ko.yml +19 -0
- data/config/locales/creatives.en.yml +19 -51
- data/config/locales/creatives.ko.yml +17 -44
- data/config/locales/crons.en.yml +16 -0
- data/config/locales/crons.ko.yml +16 -0
- data/config/locales/dnd.en.yml +26 -0
- data/config/locales/dnd.ko.yml +26 -0
- data/config/locales/drop_trigger.en.yml +5 -16
- data/config/locales/drop_trigger.ko.yml +5 -16
- data/config/locales/features.en.yml +15 -0
- data/config/locales/features.ko.yml +15 -0
- data/config/locales/file_drop.en.yml +5 -0
- data/config/locales/file_drop.ko.yml +5 -0
- data/config/locales/inline_agent_login.en.yml +20 -0
- data/config/locales/inline_agent_login.ko.yml +16 -0
- data/config/locales/integrations.en.yml +0 -1
- data/config/locales/integrations.ko.yml +0 -1
- data/config/locales/keep.en.yml +18 -0
- data/config/locales/keep.ko.yml +18 -0
- data/config/locales/kollavy.en.yml +4 -0
- data/config/locales/kollavy.ko.yml +4 -0
- data/config/locales/landing.en.yml +2 -6
- data/config/locales/landing.ko.yml +2 -6
- data/config/locales/llm_usages.en.yml +45 -0
- data/config/locales/llm_usages.ko.yml +45 -0
- data/config/locales/mcp_tools.en.yml +6 -0
- data/config/locales/mcp_tools.ko.yml +6 -0
- data/config/locales/notices.en.yml +52 -0
- data/config/locales/notices.ko.yml +52 -0
- data/config/locales/orchestration.en.yml +34 -2
- data/config/locales/orchestration.ko.yml +34 -2
- data/config/locales/ppt_viewer.en.yml +18 -0
- data/config/locales/ppt_viewer.ko.yml +18 -0
- data/config/locales/public_creatives.en.yml +6 -0
- data/config/locales/public_creatives.ko.yml +6 -0
- data/config/locales/quota.en.yml +5 -0
- data/config/locales/quota.ko.yml +5 -0
- data/config/locales/screening.en.yml +22 -0
- data/config/locales/screening.ko.yml +22 -0
- data/config/locales/search_popup.en.yml +2 -3
- data/config/locales/search_popup.ko.yml +2 -3
- data/config/locales/task_tracking.en.yml +13 -0
- data/config/locales/task_tracking.ko.yml +13 -0
- data/config/locales/tool_categories.en.yml +14 -0
- data/config/locales/tool_categories.ko.yml +14 -0
- data/config/locales/tool_descriptions.en.yml +163 -0
- data/config/locales/tool_descriptions.ko.yml +163 -0
- data/config/locales/tools.en.yml +26 -0
- data/config/locales/tools.ko.yml +26 -0
- data/config/locales/users.en.yml +19 -23
- data/config/locales/users.ko.yml +19 -22
- data/config/locales/workflow_editor.en.yml +62 -0
- data/config/locales/workflow_editor.ko.yml +62 -0
- data/config/locales/workflow_runtime.en.yml +19 -0
- data/config/locales/workflow_runtime.ko.yml +19 -0
- data/config/routes/account_settings.rb +4 -0
- data/config/routes/agent_api.rb +6 -0
- data/config/routes/agent_connections.rb +24 -0
- data/config/routes/attachments.rb +2 -0
- data/config/routes/comment_actions.rb +10 -0
- data/config/routes/creative_attachments.rb +2 -0
- data/config/routes/creative_contexts.rb +8 -0
- data/config/routes/creative_history.rb +4 -0
- data/config/routes/creative_preferences.rb +3 -0
- data/config/routes/notices.rb +16 -0
- data/config/routes/public_creatives.rb +12 -0
- data/config/routes.rb +13 -42
- data/db/migrate/20251204161133_set_default_routing_expression_for_ai_agents.rb +10 -3
- data/db/migrate/20260903070800_add_joined_at_order_index_to_users.rb +23 -0
- data/db/migrate/20260903180000_create_creative_change_history.rb +47 -0
- data/db/migrate/20260903190000_add_system_kind_to_topics.rb +8 -0
- data/db/migrate/20260908000000_add_last_topic_all_messages_to_user_creative_preferences.rb +5 -0
- data/db/migrate/20260910000000_add_health_to_agent_gateways.rb +10 -0
- data/db/migrate/20260911000000_add_endpoint_health_to_users.rb +9 -0
- data/db/migrate/20260911020000_normalize_user_names_to_single_line.rb +32 -0
- data/db/migrate/20260913000000_create_workflow_executions.rb +64 -0
- data/db/migrate/20260913000002_add_ordinary_delivery_to_workflow_outboxes.rb +7 -0
- data/db/migrate/20260913000100_add_reserved_to_workflow_executions.rb +7 -0
- data/db/migrate/20260914063000_add_justify_creative_descriptions_to_users.rb +5 -0
- data/db/migrate/20260922000000_create_llm_usages.rb +44 -0
- data/db/migrate/20260922000001_add_expansion_save_sequences_to_users.rb +5 -0
- data/db/migrate/20260922000002_deduplicate_root_creative_preferences.rb +37 -0
- data/db/migrate/20260922000003_add_agent_quota_recovery.rb +7 -0
- data/db/migrate/20260922000004_add_agent_quota_probe.rb +6 -0
- data/db/migrate/20260922000005_add_suspension_to_tasks.rb +12 -0
- data/db/migrate/20260922010000_create_retired_task_executions.rb +11 -0
- data/db/migrate/20260922113000_add_emoji_comment_index_to_comment_reactions.rb +17 -0
- data/db/migrate/20260922120000_create_tool_usages.rb +37 -0
- data/db/migrate/20260923000000_link_tool_usages_to_agent_workspaces.rb +44 -0
- data/db/migrate/20260924000000_add_agent_run_options.rb +7 -0
- data/db/migrate/20260924010000_add_run_options_to_comment_versions.rb +5 -0
- data/db/migrate/20260924060000_add_async_approval_recovery_to_comments.rb +24 -0
- data/db/migrate/20260924070000_add_async_approval_task_to_comments.rb +22 -0
- data/db/migrate/20260929000000_create_user_notices.rb +14 -0
- data/db/migrate/20260929010000_add_system_agent_to_users.rb +5 -0
- data/db/migrate/20260929120000_add_actor_lookup_index_to_creative_change_sets.rb +19 -0
- data/db/migrate/20261008000000_add_public_id_to_creatives.rb +6 -0
- data/db/migrate/20261008010000_backfill_public_creative_ids.rb +26 -0
- data/db/migrate/20261012000000_create_blob_access_flags.rb +17 -0
- data/db/migrate/20261012000001_publish_landing_public_assets.rb +16 -0
- data/db/migrate/20261014000000_backfill_implicit_main_cron_topics.rb +38 -0
- data/db/migrate/20261016000000_add_trigger_comment_id_to_tasks.rb +21 -0
- data/db/migrate/20261016000001_index_task_event_causation.rb +20 -0
- data/db/migrate/20261016000002_index_task_merged_instructions.rb +25 -0
- data/db/migrate/20261019000000_add_quoted_creative_to_comments.rb +10 -0
- data/db/migrate/20261028000000_add_deleting_at_to_comments.rb +5 -0
- data/db/seeds.rb +3 -19
- data/lib/collavre/bulk_job_enqueue.rb +145 -0
- data/lib/collavre/engine.rb +11 -6
- data/lib/collavre/feature_card_registry.rb +8 -2
- data/lib/collavre/notice_registry.rb +179 -0
- data/lib/collavre/onboarding_notices.rb +107 -0
- data/lib/collavre/profile_preferences.rb +17 -0
- data/lib/collavre/stylesheets_helper.rb +72 -0
- data/lib/collavre/version.rb +1 -1
- data/lib/collavre.rb +12 -0
- data/lib/generators/collavre/install/install_generator.rb +50 -8
- data/lib/generators/collavre/install/templates/build.cjs.tt +1 -0
- data/lib/tasks/public_assets.rake +24 -0
- data/skills/collavre/SKILL.md +42 -0
- data/skills/collavre/references/tool-authoring.md +121 -0
- data/skills/collavre/references/tool-reference.md +98 -0
- data/skills/collavre/scripts/collavre +30 -11
- metadata +774 -7
- data/config/locales/notifications.en.yml +0 -8
- data/config/locales/notifications.ko.yml +0 -8
- /data/app/javascript/{utils/drag_bundle_image.js → lib/dnd/bundle_image.js} +0 -0
|
@@ -1,7 +1,17 @@
|
|
|
1
|
+
import { reloadDeletedReservedTopic, archivedTopicControls } from './topics/reserved_topic_deletion'
|
|
2
|
+
import { createDragDropRegistry } from '../../lib/dnd/registry'
|
|
3
|
+
import { getDragKind, readDragData, writeDragData } from '../../lib/dnd/envelope'
|
|
4
|
+
import { previewDrop, horizontalHit } from '../../lib/dnd/preview'
|
|
1
5
|
import { Controller } from "@hotwired/stimulus"
|
|
2
6
|
import { createSubscription } from "../../services/cable"
|
|
3
7
|
import { fetchNextTopicName, createTopicWithComments, saveLastTopic } from "../../lib/api/topics"
|
|
4
8
|
import { alertDialog, confirmDialog } from "../../lib/utils/dialog"
|
|
9
|
+
import { invalidateCreativeTree } from '../../lib/creative_tree_invalidation'
|
|
10
|
+
import PopupToggleGuard from '../../lib/popup_toggle_guard'
|
|
11
|
+
import TopicSelectionRestoreState from './topics/selection_restore_state'
|
|
12
|
+
import LastTopicSave from './topics/last_topic_save'
|
|
13
|
+
import LastTopicSaveOrderState, { LAST_TOPIC_SAVE_WINDOW_NAME_PREFIX } from './topics/save_order_state'
|
|
14
|
+
import LastTopicSelfEchoState from './topics/self_echo_state'
|
|
5
15
|
|
|
6
16
|
const ICON_ARCHIVE = `<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="3" width="20" height="5" rx="1"/><path d="M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8"/><path d="M10 12h4"/></svg>`
|
|
7
17
|
const ICON_RESTORE = `<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 7v6h6"/><path d="M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6.69 3L3 13"/></svg>`
|
|
@@ -9,30 +19,71 @@ const AMBIGUOUS_SAVE_CLAIM_TIMEOUT = 5_000
|
|
|
9
19
|
const SAVE_REQUEST_TIMEOUT = 5_000
|
|
10
20
|
const UNREAD_COUNT_REFRESH_DELAY = 250
|
|
11
21
|
const TOPIC_SCROLL_DURATION = 250
|
|
12
|
-
const LAST_TOPIC_SAVE_SESSION_STORAGE_KEY = "collavre:last-topic-save-session-id"
|
|
13
|
-
const LAST_TOPIC_SAVE_SEQUENCE_STORAGE_KEY = "collavre:last-topic-save-sequence"
|
|
14
|
-
const LAST_TOPIC_SAVE_WINDOW_NAME_PREFIX = "collavre:last-topic-save-session:"
|
|
15
|
-
let fallbackClientIdSequence = 0
|
|
16
22
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
// counting from zero would answer to each other's echoes.
|
|
20
|
-
function newClientId() {
|
|
21
|
-
if (typeof crypto !== 'undefined' && crypto.randomUUID) return crypto.randomUUID()
|
|
23
|
+
export default class extends Controller {
|
|
24
|
+
static targets = ["list", "creationContainer", "topicListButton"]
|
|
22
25
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return `save-${Array.from(bytes, byte => byte.toString(16).padStart(2, '0')).join('')}`
|
|
26
|
+
get selectionState() {
|
|
27
|
+
return this._selectionState || (this._selectionState = new TopicSelectionRestoreState())
|
|
26
28
|
}
|
|
27
29
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
30
|
+
get saveOrderState() {
|
|
31
|
+
return this._saveOrderState || (this._saveOrderState = new LastTopicSaveOrderState())
|
|
32
|
+
}
|
|
31
33
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
get lastTopicSave() {
|
|
35
|
+
return this._lastTopicSave || (this._lastTopicSave = new LastTopicSave(this))
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
get selfEchoState() {
|
|
39
|
+
return this._selfEchoState || (this._selfEchoState = new LastTopicSelfEchoState())
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Keep the controller's existing internal surface while the state itself is
|
|
43
|
+
// owned by focused collaborators. Existing lifecycle paths intentionally
|
|
44
|
+
// inspect these values while a request is in flight.
|
|
45
|
+
get _explicitAllMessagesSelection() {
|
|
46
|
+
return this.selectionState.explicitAllMessagesSelection
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
set _explicitAllMessagesSelection(value) {
|
|
50
|
+
this.selectionState.explicitAllMessagesSelection = value
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
get _pendingPick() {
|
|
54
|
+
return this.selectionState.pendingPick
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
set _pendingPick(value) {
|
|
58
|
+
this.selectionState.pendingPick = value
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
get _pickCreativeId() {
|
|
62
|
+
return this.selectionState.pickCreativeId
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
set _pickCreativeId(value) {
|
|
66
|
+
this.selectionState.pickCreativeId = value
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
get _pickTopicId() {
|
|
70
|
+
return this.selectionState.pickTopicId
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
set _pickTopicId(value) {
|
|
74
|
+
this.selectionState.pickTopicId = value
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
get _saveLastTopicTimer() {
|
|
78
|
+
return this.saveOrderState.timer
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
set _saveLastTopicTimer(value) {
|
|
82
|
+
this.saveOrderState.timer = value
|
|
83
|
+
}
|
|
34
84
|
|
|
35
85
|
connect() {
|
|
86
|
+
this._registerDragDrop()
|
|
36
87
|
this.topics = []
|
|
37
88
|
this.canManageTopics = false
|
|
38
89
|
this.canCreateTopic = false
|
|
@@ -44,6 +95,7 @@ export default class extends Controller {
|
|
|
44
95
|
this._topicScrollFrame = null
|
|
45
96
|
this._topicScrollInterrupted = false
|
|
46
97
|
this._topicScrollInterruptionVersion ||= 0
|
|
98
|
+
this._explicitAllMessagesSelection ??= false
|
|
47
99
|
// Initial load if creativeId is available (e.g. from dataset if set server-side)
|
|
48
100
|
if (this.creativeId && this.element.dataset.docked !== 'true') {
|
|
49
101
|
this.loadTopics()
|
|
@@ -61,6 +113,7 @@ export default class extends Controller {
|
|
|
61
113
|
}
|
|
62
114
|
|
|
63
115
|
disconnect() {
|
|
116
|
+
this.dnd?.destroy()
|
|
64
117
|
this.cancelProgrammaticScroll()
|
|
65
118
|
window.removeEventListener('comments--topics:new-message', this.handleNewMessage)
|
|
66
119
|
window.removeEventListener('collavre:topic-moved', this.handleTopicMoved)
|
|
@@ -97,6 +150,7 @@ export default class extends Controller {
|
|
|
97
150
|
// transient — loadTopics() cannot rebuild them.
|
|
98
151
|
if (String(previousCreativeId || '') !== String(creativeId || '')) {
|
|
99
152
|
this.archivedWithNewMessages.clear()
|
|
153
|
+
this._explicitAllMessagesSelection = false
|
|
100
154
|
// Scoped to the creative it was archived in; a topic id from another
|
|
101
155
|
// creative must not veto this one's restored selection.
|
|
102
156
|
this.archivedAwayTopicId = null
|
|
@@ -127,6 +181,7 @@ export default class extends Controller {
|
|
|
127
181
|
this.creativeIdValue = null
|
|
128
182
|
this.topics = []
|
|
129
183
|
this.mainTopicId = null
|
|
184
|
+
this._explicitAllMessagesSelection = false
|
|
130
185
|
this.archivedWithNewMessages.clear()
|
|
131
186
|
this.archivedAwayTopicId = null
|
|
132
187
|
delete this.element.dataset.effectiveCreativeId
|
|
@@ -248,6 +303,9 @@ export default class extends Controller {
|
|
|
248
303
|
}
|
|
249
304
|
if (response.ok) {
|
|
250
305
|
const data = await response.json()
|
|
306
|
+
// A removal or newer load can arrive while a large response is
|
|
307
|
+
// being decoded, after the pre-parse version check above.
|
|
308
|
+
if (version !== this._loadTopicsVersion) return
|
|
251
309
|
const unreadCounts = this._unreadCountsOverlay?.loadVersion === version
|
|
252
310
|
? this._unreadCountsOverlay.counts
|
|
253
311
|
: null
|
|
@@ -271,6 +329,7 @@ export default class extends Controller {
|
|
|
271
329
|
: String(this.creativeId)
|
|
272
330
|
this.knownEffectiveCreativeIds.set(String(creativeId), effectiveCreativeId)
|
|
273
331
|
const snapshotTopicId = data.last_topic_id ? String(data.last_topic_id) : ""
|
|
332
|
+
const snapshotAllMessages = data.last_topic_all_messages === true
|
|
274
333
|
const snapshotTopicRevision = this.normalizeLastTopicRevision(data.last_topic_revision)
|
|
275
334
|
this.element.dataset.effectiveCreativeId = effectiveCreativeId
|
|
276
335
|
this.remapPendingSelfEchoesForCreative(creativeId, effectiveCreativeId)
|
|
@@ -311,6 +370,7 @@ export default class extends Controller {
|
|
|
311
370
|
snapshotTopicId,
|
|
312
371
|
snapshotTopicRevision
|
|
313
372
|
) && this.pickOutranks(selectionEpoch, creativeId, topics, this.archivedTopics)
|
|
373
|
+
let keepEmptySelection = false
|
|
314
374
|
if (skipLastTopicReconciliation) {
|
|
315
375
|
// The GET has a server ordering token, but this save has neither
|
|
316
376
|
// its response revision nor its echo yet. Its predecessor topic is
|
|
@@ -324,6 +384,7 @@ export default class extends Controller {
|
|
|
324
384
|
// belongs to the actual pick, so restore that picked value
|
|
325
385
|
// rather than treating the derived fallback as its value.
|
|
326
386
|
this.serverLastTopicId = this._pickTopicId
|
|
387
|
+
keepEmptySelection = !this._pickTopicId
|
|
327
388
|
// The picked value has not necessarily reached the server yet.
|
|
328
389
|
// Keep the snapshot as the first known remote baseline so a
|
|
329
390
|
// claim created after this load records what its pending save
|
|
@@ -341,14 +402,25 @@ export default class extends Controller {
|
|
|
341
402
|
)
|
|
342
403
|
if (pendingTopicId === undefined) {
|
|
343
404
|
this.serverLastTopicId = snapshotTopicId
|
|
405
|
+
// An empty id is also written when a selected topic is
|
|
406
|
+
// deleted or moved. Only the explicit server flag can
|
|
407
|
+
// distinguish that tombstone from All Messages.
|
|
408
|
+
keepEmptySelection = this.isPersistedAllMessagesSelection(
|
|
409
|
+
snapshotTopicId,
|
|
410
|
+
snapshotAllMessages
|
|
411
|
+
)
|
|
344
412
|
// A retained claim proves this response was an older view of
|
|
345
413
|
// the preference. Do not let that stale snapshot roll back
|
|
346
414
|
// the baseline used by the next save's closed-reopen check.
|
|
347
415
|
this.setLastKnownRemoteTopicId(effectiveCreativeId, snapshotTopicId)
|
|
348
416
|
} else {
|
|
349
417
|
this.serverLastTopicId = pendingTopicId
|
|
418
|
+
keepEmptySelection = !pendingTopicId
|
|
350
419
|
}
|
|
351
420
|
}
|
|
421
|
+
if (!skipLastTopicReconciliation) {
|
|
422
|
+
this._explicitAllMessagesSelection = keepEmptySelection
|
|
423
|
+
}
|
|
352
424
|
// The archive guard only has to outlive the sources that still
|
|
353
425
|
// name the topic. Test the effective selection, not just the
|
|
354
426
|
// preference: an unchanged ?topic_id= outranks it in the getter,
|
|
@@ -368,13 +440,13 @@ export default class extends Controller {
|
|
|
368
440
|
// unresolved revisioned save must not turn its retained local
|
|
369
441
|
// selection into another PATCH while reconciliation is deferred.
|
|
370
442
|
if (!skipLastTopicReconciliation) {
|
|
371
|
-
this.migrateLocalStorage({
|
|
443
|
+
this.migrateLocalStorage({ keepEmptySelection })
|
|
372
444
|
}
|
|
373
445
|
|
|
374
446
|
this.renderTopics(this.topics, this.canManageTopics, this.canCreateTopic, this.canSetPrimaryAgent, creativeId)
|
|
375
447
|
if (this.currentTopicId) this.clearNewMessageBadge(this.currentTopicId)
|
|
376
448
|
if (!skipLastTopicReconciliation) {
|
|
377
|
-
this.restoreSelection({
|
|
449
|
+
this.restoreSelection({ keepEmptySelection })
|
|
378
450
|
}
|
|
379
451
|
this.refreshOpenTopicListPopup()
|
|
380
452
|
}
|
|
@@ -387,21 +459,21 @@ export default class extends Controller {
|
|
|
387
459
|
}
|
|
388
460
|
}
|
|
389
461
|
|
|
390
|
-
//
|
|
391
|
-
//
|
|
392
|
-
//
|
|
393
|
-
//
|
|
394
|
-
//
|
|
395
|
-
//
|
|
396
|
-
// reapplying sends the authoritative empty selection
|
|
397
|
-
// controllers again.
|
|
398
|
-
restoreSelection({
|
|
462
|
+
// keepEmptySelection: the caller established that All Messages is an
|
|
463
|
+
// intentional selection, either from a pick that outran this load or from
|
|
464
|
+
// the explicit All Messages server preference. It names no topic,
|
|
465
|
+
// so it cannot be restored from a topic list and must be reapplied. Without
|
|
466
|
+
// this the Main fallback below treats it as "nothing selected", navigates
|
|
467
|
+
// away from it and persists Main. A prior interim restore may also have
|
|
468
|
+
// dispatched Main, so reapplying sends the authoritative empty selection
|
|
469
|
+
// to downstream controllers again.
|
|
470
|
+
restoreSelection({ keepEmptySelection = this._explicitAllMessagesSelection } = {}) {
|
|
399
471
|
const lastTopicId = this.currentTopicId
|
|
400
472
|
// A deep link controls this popup's view, but it is not a replacement
|
|
401
473
|
// for the saved preference. Replaying the linked selection after a
|
|
402
474
|
// preference broadcast must therefore update the UI without writing the
|
|
403
475
|
// link back over that newer server value.
|
|
404
|
-
const preservePreference = this.hasDeepLinkSelection
|
|
476
|
+
const preservePreference = this.hasDeepLinkSelection
|
|
405
477
|
// archiveTopic() switched away from this topic on purpose. The server
|
|
406
478
|
// preference still names it until the debounced save lands, so accept
|
|
407
479
|
// the local intent over the stale server answer for that window.
|
|
@@ -424,8 +496,8 @@ export default class extends Controller {
|
|
|
424
496
|
}
|
|
425
497
|
}
|
|
426
498
|
|
|
427
|
-
if (
|
|
428
|
-
this.selectTopic("", { pick: false })
|
|
499
|
+
if (keepEmptySelection && !lastTopicId) {
|
|
500
|
+
this.selectTopic("", { pick: false, persist: !preservePreference })
|
|
429
501
|
return
|
|
430
502
|
}
|
|
431
503
|
|
|
@@ -439,7 +511,11 @@ export default class extends Controller {
|
|
|
439
511
|
// re-render landing in that window resolves to Main whatever the user
|
|
440
512
|
// has selected. Counting it as intent would let it outrank the answer
|
|
441
513
|
// it was derived from — and drop the deep link on the way.
|
|
442
|
-
|
|
514
|
+
// Before the first topic response there is no Main id yet. The empty
|
|
515
|
+
// placeholder is not an All Messages choice, so it must not be saved as
|
|
516
|
+
// the explicit empty preference introduced for that user action.
|
|
517
|
+
const persistFallback = Boolean(this.mainTopicId) && !preservePreference
|
|
518
|
+
this.selectTopic(this.mainTopicId || "", { pick: false, persist: persistFallback })
|
|
443
519
|
}
|
|
444
520
|
|
|
445
521
|
// An archived topic can be opened from the topic strip, the topic-list popup,
|
|
@@ -457,14 +533,7 @@ export default class extends Controller {
|
|
|
457
533
|
}
|
|
458
534
|
|
|
459
535
|
renderTopics(topics, canManage = false, canCreateTopic = canManage, canSetPrimaryAgent = canManage, sourceCreativeId = this._topicsCreativeId || this.creativeId) {
|
|
460
|
-
const
|
|
461
|
-
? 'dragstart->comments--topics#handleTopicDragStart dragend->comments--topics#handleTopicDragEnd'
|
|
462
|
-
: ''
|
|
463
|
-
const dropActions = 'dragover->comments--topics#handleDragOver dragleave->comments--topics#handleDragLeave drop->comments--topics#handleDrop'
|
|
464
|
-
const topicDropActions = canManage
|
|
465
|
-
? 'dragover->comments--topics#handleTopicReorderDragOver dragleave->comments--topics#handleTopicReorderDragLeave drop->comments--topics#handleTopicReorderDrop'
|
|
466
|
-
: ''
|
|
467
|
-
|
|
536
|
+
const cronMessageDrafts = this.captureCronMessageDrafts()
|
|
468
537
|
const allMessagesLabel = this.element.dataset.topicMainText || 'All Messages'
|
|
469
538
|
|
|
470
539
|
const mainTopic = this.mainTopicId ? topics.find(t => String(t.id) === String(this.mainTopicId)) : null
|
|
@@ -474,7 +543,7 @@ export default class extends Controller {
|
|
|
474
543
|
|
|
475
544
|
const renderTopic = (topic) => {
|
|
476
545
|
const isActive = String(this.currentTopicId) === String(topic.id) ? 'active' : ''
|
|
477
|
-
const draggable = canManage ? 'draggable="true"' : ''
|
|
546
|
+
const draggable = canManage && !topic.read_only ? 'draggable="true"' : ''
|
|
478
547
|
// agent_locked marks a live agent session topic, whose primary agent is
|
|
479
548
|
// session identity rather than a routing pin — the server refuses to
|
|
480
549
|
// change it, so the avatar must not offer to release it.
|
|
@@ -486,24 +555,24 @@ export default class extends Controller {
|
|
|
486
555
|
const unreadBadge = topic.unread_count > 0
|
|
487
556
|
? `<span class="topic-unread-badge">${topic.unread_count}</span>`
|
|
488
557
|
: ''
|
|
558
|
+
const cronBadge = topic.cron_badge_html || ''
|
|
489
559
|
const isMainTopic = this.mainTopicId && String(topic.id) === String(this.mainTopicId)
|
|
490
560
|
let s = `<span class="topic-tag topic-drop-target ${isActive}" ${draggable}
|
|
491
|
-
data-action="click->comments--topics#select ${
|
|
561
|
+
data-action="click->comments--topics#select" data-dnd-read-only="${!!topic.read_only}"
|
|
492
562
|
data-id="${topic.id}"${topic.source_topic_id ? ` data-source-topic-id="${topic.source_topic_id}"` : ''}>
|
|
493
|
-
${agentAvatar}${branchIcon}#${topic.name}${unreadBadge}`
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
563
|
+
${agentAvatar}${branchIcon}#${topic.display_name || topic.name}${cronBadge}${unreadBadge}`
|
|
564
|
+
if (canManage && !topic.read_only) {
|
|
565
|
+
if (!isMainTopic) s += `<button class="archive-topic-btn" data-action="click->comments--topics#archiveTopic" data-id="${topic.id}" title="Archive">${ICON_ARCHIVE}</button>`
|
|
566
|
+
s += `<button class="delete-topic-btn" data-action="click->comments--topics#deleteTopic" data-id="${topic.id}">×</button>`
|
|
497
567
|
}
|
|
498
|
-
s
|
|
499
|
-
return s
|
|
568
|
+
return s + `</span>`
|
|
500
569
|
}
|
|
501
570
|
|
|
502
571
|
if (mainTopic) html += renderTopic(mainTopic)
|
|
503
572
|
otherTopics.forEach(topic => { html += renderTopic(topic) })
|
|
504
573
|
|
|
505
574
|
html += `<span class="topic-tag topic-drop-target topic-all-messages ${this.currentTopicId ? '' : 'active'}"
|
|
506
|
-
data-action="click->comments--topics#select
|
|
575
|
+
data-action="click->comments--topics#select"
|
|
507
576
|
data-id="">📋 ${allMessagesLabel}</span>`
|
|
508
577
|
|
|
509
578
|
// Archived topics section
|
|
@@ -521,17 +590,19 @@ export default class extends Controller {
|
|
|
521
590
|
const unreadBadge = topic.unread_count > 0
|
|
522
591
|
? `<span class="topic-unread-badge">${topic.unread_count}</span>`
|
|
523
592
|
: ''
|
|
593
|
+
const cronBadge = topic.cron_badge_html || ''
|
|
524
594
|
html += `<span class="topic-tag topic-archived${isActive}${hasNew}"
|
|
525
595
|
data-action="click->comments--topics#select"
|
|
526
596
|
data-id="${topic.id}">
|
|
527
|
-
#${topic.name}${unreadBadge}
|
|
528
|
-
${
|
|
597
|
+
#${topic.name}${cronBadge}${unreadBadge}
|
|
598
|
+
${archivedTopicControls(this, topic, canManage, ICON_RESTORE)}
|
|
529
599
|
</span>`
|
|
530
600
|
})
|
|
531
601
|
}
|
|
532
602
|
}
|
|
533
603
|
|
|
534
604
|
this.listTarget.innerHTML = html
|
|
605
|
+
this.restoreCronMessageDrafts(cronMessageDrafts)
|
|
535
606
|
// Which creative the chips now on screen belong to. A click can only
|
|
536
607
|
// ever be about this one, whatever this.creativeId has since become.
|
|
537
608
|
this._renderedCreativeId = sourceCreativeId
|
|
@@ -542,6 +613,46 @@ export default class extends Controller {
|
|
|
542
613
|
this.renderCreationContainer(canCreateTopic)
|
|
543
614
|
}
|
|
544
615
|
|
|
616
|
+
captureCronMessageDrafts() {
|
|
617
|
+
const drafts = new Map()
|
|
618
|
+
this.listTarget.querySelectorAll('[data-cron-key]').forEach(task => {
|
|
619
|
+
const input = task.querySelector('[data-cron-badge-target="messageInput"]')
|
|
620
|
+
const saveOperationId = task.dataset.cronSaveOperation
|
|
621
|
+
const deleteOperationId = task.dataset.cronDeleteOperation
|
|
622
|
+
const dirty = input && input.value !== input.dataset.cronSavedMessage
|
|
623
|
+
if (!input || (!dirty && !saveOperationId && !deleteOperationId)) return
|
|
624
|
+
|
|
625
|
+
drafts.set(task.dataset.cronKey, {
|
|
626
|
+
message: input.value,
|
|
627
|
+
dirty,
|
|
628
|
+
saveOperationId,
|
|
629
|
+
deleteOperationId,
|
|
630
|
+
})
|
|
631
|
+
})
|
|
632
|
+
return drafts
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
restoreCronMessageDrafts(drafts) {
|
|
636
|
+
this.listTarget.querySelectorAll('[data-cron-key]').forEach(task => {
|
|
637
|
+
if (!drafts.has(task.dataset.cronKey)) return
|
|
638
|
+
|
|
639
|
+
const input = task.querySelector('[data-cron-badge-target="messageInput"]')
|
|
640
|
+
if (!input) return
|
|
641
|
+
|
|
642
|
+
const draft = drafts.get(task.dataset.cronKey)
|
|
643
|
+
if (draft.dirty || draft.saveOperationId) input.value = draft.message
|
|
644
|
+
if (draft.saveOperationId) {
|
|
645
|
+
task.dataset.cronSaveOperation = draft.saveOperationId
|
|
646
|
+
input.disabled = true
|
|
647
|
+
task.querySelector('[data-action~="click->cron-badge#saveMessage"]').disabled = true
|
|
648
|
+
}
|
|
649
|
+
if (draft.deleteOperationId) {
|
|
650
|
+
task.dataset.cronDeleteOperation = draft.deleteOperationId
|
|
651
|
+
task.querySelector('[data-action~="click->cron-badge#destroy"]').disabled = true
|
|
652
|
+
}
|
|
653
|
+
})
|
|
654
|
+
}
|
|
655
|
+
|
|
545
656
|
// Write permission is sufficient for topic creation.
|
|
546
657
|
renderCreationContainer(canCreateTopic) {
|
|
547
658
|
if (!this.hasCreationContainerTarget) return
|
|
@@ -568,57 +679,36 @@ export default class extends Controller {
|
|
|
568
679
|
`<button class="add-topic-btn" data-action="click->comments--topics#showInput">+</button>`
|
|
569
680
|
}
|
|
570
681
|
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
if (agentJson) {
|
|
593
|
-
const agent = JSON.parse(agentJson)
|
|
594
|
-
const targetTopicId = event.currentTarget.dataset.id || this.mainTopicId
|
|
595
|
-
if (targetTopicId) {
|
|
596
|
-
await this.setTopicPrimaryAgent(targetTopicId, agent)
|
|
597
|
-
}
|
|
598
|
-
return
|
|
682
|
+
_registerDragDrop() {
|
|
683
|
+
this.dnd = createDragDropRegistry({ root: this.element, getKind: getDragKind, readData: readDragData })
|
|
684
|
+
this.dnd.registerDragSource({ selector: '.topic-tag[draggable="true"]',
|
|
685
|
+
onDragStart: this.handleTopicDragStart.bind(this),
|
|
686
|
+
onDragEnd: ({ el }) => { this.draggingTopicId = null; el.classList.remove('topic-dragging') } })
|
|
687
|
+
const selector = '.topic-drop-target:not([data-dnd-read-only="true"]), [data-comments--topics-target="creationContainer"]'
|
|
688
|
+
for (const kind of ['comments', 'agent']) {
|
|
689
|
+
this.dnd.registerDropZone({ selector, accepts: [kind], dropEffect: kind === 'agent' ? 'copy' : 'move',
|
|
690
|
+
preview: previewDrop,
|
|
691
|
+
onDrop: async ({ el, ids, payload }) => {
|
|
692
|
+
const agent = { ...payload, id: ids[0] }
|
|
693
|
+
if (el === this.creationContainerTarget) {
|
|
694
|
+
if (kind === 'comments') await this.createTopicAndMoveComments(ids)
|
|
695
|
+
else await this.createTopicWithAgent(agent)
|
|
696
|
+
} else {
|
|
697
|
+
const targetTopicId = el.dataset.id || this.mainTopicId
|
|
698
|
+
if (kind === 'agent') {
|
|
699
|
+
if (targetTopicId) await this.setTopicPrimaryAgent(targetTopicId, agent)
|
|
700
|
+
} else this.dispatch('move-to-topic', { detail: { commentIds: ids, targetTopicId } })
|
|
701
|
+
}
|
|
702
|
+
} })
|
|
599
703
|
}
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
const commentIds = JSON.parse(commentIdsJson)
|
|
606
|
-
if (!commentIds || commentIds.length === 0) return
|
|
607
|
-
|
|
608
|
-
const targetTopicId = event.currentTarget.dataset.id || this.mainTopicId
|
|
609
|
-
|
|
610
|
-
// Dispatch event for list_controller to handle the move
|
|
611
|
-
this.dispatch('move-to-topic', {
|
|
612
|
-
detail: {
|
|
613
|
-
commentIds,
|
|
614
|
-
targetTopicId
|
|
615
|
-
}
|
|
616
|
-
})
|
|
704
|
+
this.dnd.registerDropZone({ selector: '.topic-tag[draggable="true"]', accepts: ['topic'],
|
|
705
|
+
hitTest: ({ el, event }) => this.draggingTopicId && el.dataset.id !== this.draggingTopicId
|
|
706
|
+
? horizontalHit({ el, event }) : null,
|
|
707
|
+
preview: previewDrop, onDrop: this.handleTopicReorderDrop.bind(this) })
|
|
617
708
|
}
|
|
618
709
|
|
|
619
710
|
// Topic reorder drag & drop handlers
|
|
620
|
-
handleTopicDragStart(event) {
|
|
621
|
-
const topicEl = event.currentTarget
|
|
711
|
+
handleTopicDragStart({ event, el: topicEl }) {
|
|
622
712
|
const topicId = topicEl.dataset.id
|
|
623
713
|
if (!topicId) {
|
|
624
714
|
event.preventDefault()
|
|
@@ -626,69 +716,19 @@ export default class extends Controller {
|
|
|
626
716
|
}
|
|
627
717
|
|
|
628
718
|
this.draggingTopicId = topicId
|
|
629
|
-
event.dataTransfer
|
|
630
|
-
// Include topic move data so creative tree rows can accept this drop
|
|
631
|
-
event.dataTransfer.setData('application/x-topic-move', JSON.stringify({
|
|
632
|
-
topicId,
|
|
633
|
-
sourceCreativeId: this.creativeId
|
|
634
|
-
}))
|
|
719
|
+
writeDragData(event.dataTransfer, { kind: 'topic', ids: [topicId], payload: { sourceCreativeId: this.creativeId } })
|
|
635
720
|
event.dataTransfer.effectAllowed = 'move'
|
|
636
721
|
|
|
637
722
|
requestAnimationFrame(() => {
|
|
638
|
-
topicEl.classList.add('topic-dragging')
|
|
639
|
-
})
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
handleTopicDragEnd(event) {
|
|
643
|
-
this.draggingTopicId = null
|
|
644
|
-
event.currentTarget.classList.remove('topic-dragging')
|
|
645
|
-
this.listTarget.querySelectorAll('.topic-tag').forEach(el => {
|
|
646
|
-
el.classList.remove('topic-drag-over-left', 'topic-drag-over-right')
|
|
723
|
+
if (this.draggingTopicId === topicId) topicEl.classList.add('topic-dragging')
|
|
647
724
|
})
|
|
648
725
|
}
|
|
649
726
|
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
if (!
|
|
654
|
-
|
|
655
|
-
const targetEl = event.currentTarget
|
|
656
|
-
const targetId = targetEl.dataset.id
|
|
657
|
-
|
|
658
|
-
// Don't allow drop on self or Main
|
|
659
|
-
if (!targetId || targetId === this.draggingTopicId) return
|
|
660
|
-
|
|
661
|
-
event.preventDefault()
|
|
662
|
-
event.dataTransfer.dropEffect = 'move'
|
|
663
|
-
|
|
664
|
-
// Determine drop position (left or right) based on mouse position
|
|
665
|
-
const rect = targetEl.getBoundingClientRect()
|
|
666
|
-
const midpoint = rect.left + rect.width / 2
|
|
667
|
-
const isLeft = event.clientX < midpoint
|
|
668
|
-
|
|
669
|
-
targetEl.classList.toggle('topic-drag-over-left', isLeft)
|
|
670
|
-
targetEl.classList.toggle('topic-drag-over-right', !isLeft)
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
handleTopicReorderDragLeave(event) {
|
|
674
|
-
event.currentTarget.classList.remove('topic-drag-over-left', 'topic-drag-over-right')
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
async handleTopicReorderDrop(event) {
|
|
678
|
-
event.preventDefault()
|
|
679
|
-
|
|
680
|
-
const targetEl = event.currentTarget
|
|
681
|
-
targetEl.classList.remove('topic-drag-over-left', 'topic-drag-over-right')
|
|
682
|
-
|
|
683
|
-
const draggedTopicId = event.dataTransfer.getData('application/x-topic-id')
|
|
684
|
-
const targetTopicId = targetEl.dataset.id
|
|
685
|
-
|
|
686
|
-
if (!draggedTopicId || !targetTopicId || draggedTopicId === targetTopicId) return
|
|
687
|
-
|
|
688
|
-
// Determine drop position
|
|
689
|
-
const rect = targetEl.getBoundingClientRect()
|
|
690
|
-
const midpoint = rect.left + rect.width / 2
|
|
691
|
-
const insertBefore = event.clientX < midpoint
|
|
727
|
+
async handleTopicReorderDrop({ el, ids, hit }) {
|
|
728
|
+
const draggedTopicId = ids[0]
|
|
729
|
+
const targetTopicId = el.dataset.id
|
|
730
|
+
if (!draggedTopicId || !targetTopicId || String(draggedTopicId) === targetTopicId) return
|
|
731
|
+
const insertBefore = hit === 'left'
|
|
692
732
|
|
|
693
733
|
// Reorder topics array
|
|
694
734
|
const topics = [...this.topics]
|
|
@@ -774,15 +814,11 @@ export default class extends Controller {
|
|
|
774
814
|
// but this local removal should still reveal All Messages.
|
|
775
815
|
// A newer wheel/touch gesture always wins, though.
|
|
776
816
|
if (deletingSelectedTopic
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
}
|
|
817
|
+
&& this._topicScrollInterruptionVersion === scrollInterruptionVersion) this._topicScrollInterrupted = false
|
|
818
|
+
if (reloadDeletedReservedTopic(this, topicId)) return
|
|
780
819
|
if (String(this.currentTopicId) === String(topicId)) {
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
// of removeTopic, but the getter is the same one.
|
|
784
|
-
this.releaseDeepLinkSelection(topicId)
|
|
785
|
-
this.currentTopicId = "" // Switch to Main
|
|
820
|
+
// Release deep links before loadTopics restores selection.
|
|
821
|
+
this.fallbackFromRemovedTopic(topicId)
|
|
786
822
|
this.dispatch("change", { detail: { topicId: "", mainTopicId: this.mainTopicId } })
|
|
787
823
|
}
|
|
788
824
|
this.loadTopics()
|
|
@@ -882,10 +918,7 @@ export default class extends Controller {
|
|
|
882
918
|
}
|
|
883
919
|
|
|
884
920
|
openTopicListPopup(event) {
|
|
885
|
-
if (this.
|
|
886
|
-
this.cancelTopicListToggle()
|
|
887
|
-
return
|
|
888
|
-
}
|
|
921
|
+
if (this.topicListToggleGuard.consume()) return
|
|
889
922
|
|
|
890
923
|
const btnRect = event.currentTarget.getBoundingClientRect()
|
|
891
924
|
|
|
@@ -1037,43 +1070,23 @@ export default class extends Controller {
|
|
|
1037
1070
|
})
|
|
1038
1071
|
}
|
|
1039
1072
|
|
|
1040
|
-
|
|
1041
|
-
|
|
1073
|
+
get topicListToggleGuard() {
|
|
1074
|
+
this._topicListToggleGuard ||= new PopupToggleGuard()
|
|
1075
|
+
return this._topicListToggleGuard
|
|
1076
|
+
}
|
|
1042
1077
|
|
|
1078
|
+
prepareTopicListToggle(event) {
|
|
1043
1079
|
const modal = document.getElementById('topic-list-modal')
|
|
1044
1080
|
const popup = modal && this.application.getControllerForElementAndIdentifier(modal, 'topic-list')
|
|
1045
|
-
|
|
1046
|
-
// outside-click cleanup. If this popup was one of them, consume the
|
|
1047
|
-
// following click so it does not immediately reopen.
|
|
1048
|
-
if (popup?.popup?.isOpen()) {
|
|
1049
|
-
this.topicListTogglePointerDown = true
|
|
1050
|
-
this.topicListTogglePointerId = event.pointerId
|
|
1051
|
-
event.currentTarget.setPointerCapture(event.pointerId)
|
|
1052
|
-
}
|
|
1081
|
+
this.topicListToggleGuard.prepare(event, Boolean(popup?.popup?.isOpen()))
|
|
1053
1082
|
}
|
|
1054
1083
|
|
|
1055
1084
|
finishTopicListToggle(event) {
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
const rect = event.currentTarget.getBoundingClientRect()
|
|
1059
|
-
const releasedOutsideButton = event.clientX < rect.left || event.clientX > rect.right ||
|
|
1060
|
-
event.clientY < rect.top || event.clientY > rect.bottom
|
|
1061
|
-
if (releasedOutsideButton) {
|
|
1062
|
-
this.cancelTopicListToggle(event)
|
|
1063
|
-
} else {
|
|
1064
|
-
// A completed activation dispatches click before the next task. Clear a
|
|
1065
|
-
// canceled in-button gesture afterwards so it cannot consume a later click.
|
|
1066
|
-
this.topicListToggleClearTimeout = setTimeout(() => this.cancelTopicListToggle(event), 0)
|
|
1067
|
-
}
|
|
1085
|
+
this.topicListToggleGuard.finish(event)
|
|
1068
1086
|
}
|
|
1069
1087
|
|
|
1070
1088
|
cancelTopicListToggle(event = {}) {
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
clearTimeout(this.topicListToggleClearTimeout)
|
|
1074
|
-
this.topicListToggleClearTimeout = undefined
|
|
1075
|
-
this.topicListTogglePointerDown = false
|
|
1076
|
-
this.topicListTogglePointerId = undefined
|
|
1089
|
+
this.topicListToggleGuard.cancel(event)
|
|
1077
1090
|
}
|
|
1078
1091
|
|
|
1079
1092
|
handleTopicListClose() {
|
|
@@ -1127,6 +1140,7 @@ export default class extends Controller {
|
|
|
1127
1140
|
select(event) {
|
|
1128
1141
|
// Ignore if clicking on delete button (though stopPropagation should handle it)
|
|
1129
1142
|
if (event.target.closest('.delete-topic-btn')) return
|
|
1143
|
+
if (event.target.closest('.cron-badge-wrapper')) return
|
|
1130
1144
|
// Ignore if clicking on edit input
|
|
1131
1145
|
if (event.target.closest('.topic-edit-input')) return
|
|
1132
1146
|
|
|
@@ -1142,7 +1156,9 @@ export default class extends Controller {
|
|
|
1142
1156
|
const id = event.currentTarget.dataset.id
|
|
1143
1157
|
|
|
1144
1158
|
// If clicking on already active topic (not Main), show edit mode
|
|
1145
|
-
|
|
1159
|
+
const selectedTopic = [ ...(this.topics || []), ...(this.archivedTopics || []) ]
|
|
1160
|
+
.find(topic => String(topic.id) === String(id))
|
|
1161
|
+
if (id && String(this.currentTopicId) === String(id) && this.canManageTopics && !selectedTopic?.read_only) {
|
|
1146
1162
|
this.showEditInput(event.currentTarget, id)
|
|
1147
1163
|
return
|
|
1148
1164
|
}
|
|
@@ -1162,8 +1178,19 @@ export default class extends Controller {
|
|
|
1162
1178
|
if (id) {
|
|
1163
1179
|
this.clearNewMessageBadge(id)
|
|
1164
1180
|
}
|
|
1165
|
-
|
|
1166
|
-
|
|
1181
|
+
this.dispatch("change", { detail: this.changeDetail(id) })
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
changeDetail(id) {
|
|
1185
|
+
const topic = [ ...(this.topics || []), ...(this.archivedTopics || []) ]
|
|
1186
|
+
.find(candidate => String(candidate.id) === String(id))
|
|
1187
|
+
return {
|
|
1188
|
+
topicId: id,
|
|
1189
|
+
isInbox: this.isInbox,
|
|
1190
|
+
systemTopicId: this.systemTopicId,
|
|
1191
|
+
mainTopicId: this.mainTopicId,
|
|
1192
|
+
readOnly: topic?.read_only || false,
|
|
1193
|
+
}
|
|
1167
1194
|
}
|
|
1168
1195
|
|
|
1169
1196
|
showEditInput(topicEl, topicId) {
|
|
@@ -1321,7 +1348,7 @@ export default class extends Controller {
|
|
|
1321
1348
|
// If we were viewing the moved topic, switch to Main
|
|
1322
1349
|
if (String(this.currentTopicId) === String(topicId)) {
|
|
1323
1350
|
this._topicScrollInterrupted = false
|
|
1324
|
-
this.
|
|
1351
|
+
this.fallbackFromRemovedTopic(topicId)
|
|
1325
1352
|
this.dispatch("change", { detail: { topicId: "", mainTopicId: this.mainTopicId } })
|
|
1326
1353
|
}
|
|
1327
1354
|
this.loadTopics()
|
|
@@ -1436,6 +1463,25 @@ export default class extends Controller {
|
|
|
1436
1463
|
this.clearUrlTopicId(topicId)
|
|
1437
1464
|
}
|
|
1438
1465
|
|
|
1466
|
+
// Deletion and move tombstones mean "fall back to Main", not that the user
|
|
1467
|
+
// picked All Messages. Do not queue a blank preference save while the topic
|
|
1468
|
+
// reload is still pending, because the server records blank saves as an
|
|
1469
|
+
// explicit All Messages choice.
|
|
1470
|
+
fallbackFromRemovedTopic(topicId) {
|
|
1471
|
+
this.cancelPendingSaveLastTopic()
|
|
1472
|
+
if (String(this._pendingPick?.topicId) === String(topicId)) this._pendingPick = null
|
|
1473
|
+
// A link only protects a distinct saved preference behind it. If both
|
|
1474
|
+
// sources name the removed topic, releasing the link would otherwise
|
|
1475
|
+
// expose that same dead preference and select it again.
|
|
1476
|
+
const preservePreference = this.hasDeepLinkSelection &&
|
|
1477
|
+
String(this.serverLastTopicId) !== String(topicId)
|
|
1478
|
+
this.releaseDeepLinkSelection(topicId)
|
|
1479
|
+
if (!preservePreference) {
|
|
1480
|
+
this.serverLastTopicId = ""
|
|
1481
|
+
this._explicitAllMessagesSelection = false
|
|
1482
|
+
}
|
|
1483
|
+
}
|
|
1484
|
+
|
|
1439
1485
|
// Drop ?topic_id= when it names the topic being archived. It is a selection
|
|
1440
1486
|
// source in its own right and survives every reload, so leaving it would
|
|
1441
1487
|
// re-select the topic the user just archived out of. replaceState, not a
|
|
@@ -1469,6 +1515,10 @@ export default class extends Controller {
|
|
|
1469
1515
|
applySelection(id, { pick = true, persist = true, pending = false } = {}) {
|
|
1470
1516
|
if (persist) this.serverLastTopicId = id ? String(id) : ""
|
|
1471
1517
|
if (pick) {
|
|
1518
|
+
// selectTopic marks picks as pending; a blank direct setter is a
|
|
1519
|
+
// programmatic fallback after deletion/archive and should retain
|
|
1520
|
+
// the established Main fallback instead of becoming All Messages.
|
|
1521
|
+
if (id || pending) this._explicitAllMessagesSelection = !id
|
|
1472
1522
|
// Writing only the preference leaves the two sources that outrank it
|
|
1473
1523
|
// in the getter still naming the topic being left, so the getter
|
|
1474
1524
|
// keeps answering with it: the next renderTopics() lights the old
|
|
@@ -1478,15 +1528,11 @@ export default class extends Controller {
|
|
|
1478
1528
|
// resolved to the topic now being selected must keep outranking the
|
|
1479
1529
|
// stale server last_topic_id for the rest of the popup session.
|
|
1480
1530
|
this.releaseSelectionSourcesOtherThan(this.serverLastTopicId)
|
|
1481
|
-
this.
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
creativeId: this._pickCreativeId,
|
|
1487
|
-
topicId: this._pickTopicId,
|
|
1488
|
-
}
|
|
1489
|
-
}
|
|
1531
|
+
this.selectionState.recordPick(
|
|
1532
|
+
this._renderedCreativeId,
|
|
1533
|
+
this.serverLastTopicId,
|
|
1534
|
+
{ pending }
|
|
1535
|
+
)
|
|
1490
1536
|
}
|
|
1491
1537
|
if (persist) this.debounceSaveLastTopic(id)
|
|
1492
1538
|
}
|
|
@@ -1494,11 +1540,11 @@ export default class extends Controller {
|
|
|
1494
1540
|
// Bumped on every selection so an in-flight loadTopics() can tell whether
|
|
1495
1541
|
// its answer predates a pick the user has since made.
|
|
1496
1542
|
get selectionEpoch() {
|
|
1497
|
-
return this.
|
|
1543
|
+
return this.selectionState.epoch
|
|
1498
1544
|
}
|
|
1499
1545
|
|
|
1500
1546
|
set selectionEpoch(value) {
|
|
1501
|
-
this.
|
|
1547
|
+
this.selectionState.epoch = value
|
|
1502
1548
|
}
|
|
1503
1549
|
|
|
1504
1550
|
// Did a pick land after the load at `epoch` started, or is there still an
|
|
@@ -1516,17 +1562,7 @@ export default class extends Controller {
|
|
|
1516
1562
|
// made against a strip that predates a delete, and keeping it would fail the
|
|
1517
1563
|
// lookup in restoreSelection() and persist Main in its place.
|
|
1518
1564
|
pickOutranks(epoch, creativeId, topics, archivedTopics) {
|
|
1519
|
-
|
|
1520
|
-
const hasUnsavedPick = this._pendingPick &&
|
|
1521
|
-
String(this._pendingPick.creativeId) === String(creativeId)
|
|
1522
|
-
if (!hasNewerPick && !hasUnsavedPick) return false
|
|
1523
|
-
// creativeId is always truthy here — loadTopics() returns without it —
|
|
1524
|
-
// so a pick made before any strip was rendered fails this too.
|
|
1525
|
-
if (String(this._pickCreativeId) !== String(creativeId)) return false
|
|
1526
|
-
if (!this._pickTopicId) return true
|
|
1527
|
-
|
|
1528
|
-
return [ ...(topics || []), ...(archivedTopics || []) ]
|
|
1529
|
-
.some(t => String(t.id) === String(this._pickTopicId))
|
|
1565
|
+
return this.selectionState.outranks(epoch, creativeId, topics, archivedTopics)
|
|
1530
1566
|
}
|
|
1531
1567
|
|
|
1532
1568
|
releaseSelectionSourcesOtherThan(id) {
|
|
@@ -1588,172 +1624,18 @@ export default class extends Controller {
|
|
|
1588
1624
|
// sticks need not be the last one picked. Waiting for the one in
|
|
1589
1625
|
// flight is what makes the order they were picked in the order they
|
|
1590
1626
|
// are written.
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
const claimed = generation === this.subscriptionGenerationFor(effectiveCreativeId)
|
|
1597
|
-
if (claimed) {
|
|
1598
|
-
this.pendingSelfEchoes.push(clientId)
|
|
1599
|
-
this.pendingSelfEchoCreativeIds.set(clientId, String(effectiveCreativeId))
|
|
1600
|
-
this.pendingSelfEchoTopicIds.set(clientId, id ? String(id) : "")
|
|
1601
|
-
this.pendingSelfEchoPreviousTopicIds.set(
|
|
1602
|
-
clientId,
|
|
1603
|
-
this.lastKnownRemoteTopicIdFor(effectiveCreativeId) === undefined
|
|
1604
|
-
? (this.serverLastTopicId ? String(this.serverLastTopicId) : "")
|
|
1605
|
-
: this.lastKnownRemoteTopicIdFor(effectiveCreativeId)
|
|
1606
|
-
)
|
|
1607
|
-
// A save can wait behind another request while the popup closes. It
|
|
1608
|
-
// takes its claim only when the queue reaches it, after the close
|
|
1609
|
-
// handler has already marked the claims that existed then. Its echo
|
|
1610
|
-
// will also be sent into that closed gap, so mark it at creation.
|
|
1611
|
-
if (this._popupClosed && !this.topicsSubscription) {
|
|
1612
|
-
this.possiblyMissedPendingSelfEchoes.add(clientId)
|
|
1613
|
-
}
|
|
1614
|
-
}
|
|
1615
|
-
// A thrown fetch has an unknown outcome: the server may have saved
|
|
1616
|
-
// and broadcast before the connection failed, so keep its claim for
|
|
1617
|
-
// that delayed echo. An HTTP failure is definitive, however, and
|
|
1618
|
-
// update_last_topic returns before broadcasting in that case.
|
|
1619
|
-
const saveResult = await this.saveLastTopicWithTimeout(creativeId, id || null, clientId)
|
|
1620
|
-
const saved = saveResult === true || saveResult?.success === true
|
|
1621
|
-
const savedRevision = this.normalizeLastTopicRevision(saveResult?.lastTopicRevision)
|
|
1622
|
-
const savedRevisionIsCurrent = this.observeLastTopicRevision(
|
|
1623
|
-
effectiveCreativeId,
|
|
1624
|
-
savedRevision
|
|
1625
|
-
)
|
|
1626
|
-
const topicId = id ? String(id) : ""
|
|
1627
|
-
const saveRejected = saveResult === false || saveResult?.success === false
|
|
1628
|
-
const staleLastTopicSave = saveResult?.staleLastTopicSave === true
|
|
1629
|
-
if (claimed && saved) {
|
|
1630
|
-
// The Action Cable echo can arrive before this response. In that
|
|
1631
|
-
// case it has already consumed the claim and removed its metadata;
|
|
1632
|
-
// do not recreate an acknowledgement entry for a completed save.
|
|
1633
|
-
const hasPendingSelfEcho = this.pendingSelfEchoes.includes(clientId)
|
|
1634
|
-
if (hasPendingSelfEcho) {
|
|
1635
|
-
this.saveAcknowledgementVersion += 1
|
|
1636
|
-
this.pendingSelfEchoAcknowledgementVersions.set(
|
|
1637
|
-
clientId,
|
|
1638
|
-
this.saveAcknowledgementVersion
|
|
1639
|
-
)
|
|
1640
|
-
// The response can beat its Action Cable echo. Preserve the
|
|
1641
|
-
// server-issued revision now so a delayed GET can order this
|
|
1642
|
-
// acknowledged claim against a newer ABA snapshot.
|
|
1643
|
-
if (savedRevision) {
|
|
1644
|
-
this.pendingSelfEchoRemoteRevisions.set(clientId, savedRevision)
|
|
1645
|
-
}
|
|
1646
|
-
}
|
|
1647
|
-
const currentCreativeId = String(this.creativeId)
|
|
1648
|
-
const currentStreamIsResolved = this.element.dataset.effectiveCreativeId ||
|
|
1649
|
-
this.knownEffectiveCreativeIds.has(currentCreativeId)
|
|
1650
|
-
const subscribedToAnotherStream = this.topicsSubscription && currentStreamIsResolved &&
|
|
1651
|
-
String(this.effectiveCreativeId) !== String(effectiveCreativeId)
|
|
1652
|
-
const possiblyMissedDuringDisconnect =
|
|
1653
|
-
this.possiblyMissedPendingSelfEchoesDuringDisconnect.has(clientId)
|
|
1654
|
-
if ((this.possiblyMissedPendingSelfEchoes.has(clientId) && !this.topicsSubscription) ||
|
|
1655
|
-
subscribedToAnotherStream ||
|
|
1656
|
-
possiblyMissedDuringDisconnect) {
|
|
1657
|
-
// update_last_topic broadcasts before it returns. With the popup
|
|
1658
|
-
// closed, or after its stream was replaced, that echo was necessarily
|
|
1659
|
-
// sent somewhere this controller can no longer receive it and cannot
|
|
1660
|
-
// settle this claim.
|
|
1661
|
-
// This completed save is also the remote baseline for the next
|
|
1662
|
-
// queued save, which may have claimed after the popup closed.
|
|
1663
|
-
this.setLastKnownRemoteTopicId(effectiveCreativeId, topicId)
|
|
1664
|
-
if (possiblyMissedDuringDisconnect) {
|
|
1665
|
-
this.retirePendingSelfEcho(clientId)
|
|
1666
|
-
} else {
|
|
1667
|
-
this.releasePendingSelfEcho(clientId)
|
|
1668
|
-
}
|
|
1669
|
-
} else {
|
|
1670
|
-
// The replacement subscription may have been active before this
|
|
1671
|
-
// response beat the WebSocket message back to the browser. Keep the
|
|
1672
|
-
// id to consume that echo, but do not use this acknowledged claim to
|
|
1673
|
-
// override a later reopen snapshot.
|
|
1674
|
-
// A completed save establishes the server value that the
|
|
1675
|
-
// next claim was made from. Without moving this baseline,
|
|
1676
|
-
// a later closed save compares its reopen snapshot to a
|
|
1677
|
-
// value from before an earlier local save and mistakes the
|
|
1678
|
-
// legitimate previous value for another session's update.
|
|
1679
|
-
// Do not overwrite a newer Action Cable update after this
|
|
1680
|
-
// save's echo has already been consumed: that echo records
|
|
1681
|
-
// the baseline at broadcast time, and another message may
|
|
1682
|
-
// have advanced it before the HTTP response arrived.
|
|
1683
|
-
if (hasPendingSelfEcho && savedRevisionIsCurrent) {
|
|
1684
|
-
this.setLastKnownRemoteTopicId(effectiveCreativeId, topicId)
|
|
1685
|
-
}
|
|
1686
|
-
this.acknowledgePendingSelfEcho(clientId)
|
|
1687
|
-
}
|
|
1688
|
-
}
|
|
1689
|
-
if (claimed && saveRejected) this.releasePendingSelfEcho(clientId)
|
|
1690
|
-
if (claimed && saveResult === null) {
|
|
1691
|
-
this.scheduleAmbiguousPendingSelfEchoRetirement(clientId)
|
|
1692
|
-
}
|
|
1693
|
-
const rejectedPendingPick = staleLastTopicSave && this._pendingPick === pendingPick &&
|
|
1694
|
-
String(pendingPick?.creativeId) === String(creativeId) &&
|
|
1695
|
-
pendingPick?.topicId === topicId
|
|
1696
|
-
if (rejectedPendingPick) this._pendingPick = null
|
|
1697
|
-
if (saveResult !== null) this.retryDeferredLastTopicReconciliation(effectiveCreativeId)
|
|
1698
|
-
if (saveResult !== false && this._pendingPick === pendingPick &&
|
|
1699
|
-
String(pendingPick?.creativeId) === String(creativeId) &&
|
|
1700
|
-
pendingPick?.topicId === topicId) {
|
|
1701
|
-
this._pendingPick = null
|
|
1702
|
-
}
|
|
1703
|
-
})
|
|
1704
|
-
return this._saveChain
|
|
1705
|
-
}
|
|
1627
|
+
const context = {
|
|
1628
|
+
id, creativeId, effectiveCreativeId, clientId, pendingPick, generation,
|
|
1629
|
+
}
|
|
1630
|
+
return this.lastTopicSave.enqueue(context)
|
|
1631
|
+
}
|
|
1706
1632
|
|
|
1707
1633
|
// A timed-out fetch can still be running on Rails. Prefix each echo id with
|
|
1708
1634
|
// a controller-local session and monotonically increasing sequence so Rails
|
|
1709
1635
|
// can reject an older request if a later one from this controller commits
|
|
1710
1636
|
// first. The trailing nonce keeps the Action Cable echo identifier unique.
|
|
1711
1637
|
newLastTopicSaveClientId() {
|
|
1712
|
-
|
|
1713
|
-
this._lastTopicSaveSequence = this.nextLastTopicSaveSequence()
|
|
1714
|
-
return `${this._lastTopicSaveSessionId}.${this._lastTopicSaveSequence}.${newClientId()}`
|
|
1715
|
-
}
|
|
1716
|
-
|
|
1717
|
-
// A Turbo replacement creates a new controller while an earlier request can
|
|
1718
|
-
// still be running on Rails. Keep the fence identity and counter for this
|
|
1719
|
-
// browser tab so the server can reject that earlier request after the new
|
|
1720
|
-
// controller has saved a later selection.
|
|
1721
|
-
lastTopicSaveSessionId() {
|
|
1722
|
-
try {
|
|
1723
|
-
const sessionId = this.lastTopicSaveWindowSessionId()
|
|
1724
|
-
sessionStorage.setItem(LAST_TOPIC_SAVE_SESSION_STORAGE_KEY, sessionId)
|
|
1725
|
-
return sessionId
|
|
1726
|
-
} catch (_) {
|
|
1727
|
-
return newClientId()
|
|
1728
|
-
}
|
|
1729
|
-
}
|
|
1730
|
-
|
|
1731
|
-
// sessionStorage survives a reload, but browsers copy it into a duplicated
|
|
1732
|
-
// tab. window.name belongs to one top-level browsing context and also
|
|
1733
|
-
// survives reloads, so it keeps Turbo replacements on one fence while a
|
|
1734
|
-
// copied tab starts a separate ordering stream.
|
|
1735
|
-
lastTopicSaveWindowSessionId() {
|
|
1736
|
-
const currentName = window.name || ""
|
|
1737
|
-
if (currentName.startsWith(LAST_TOPIC_SAVE_WINDOW_NAME_PREFIX)) {
|
|
1738
|
-
const sessionId = currentName.slice(LAST_TOPIC_SAVE_WINDOW_NAME_PREFIX.length)
|
|
1739
|
-
if (/^[A-Za-z0-9-]+$/.test(sessionId)) return sessionId
|
|
1740
|
-
}
|
|
1741
|
-
|
|
1742
|
-
const sessionId = newClientId()
|
|
1743
|
-
window.name = `${LAST_TOPIC_SAVE_WINDOW_NAME_PREFIX}${sessionId}`
|
|
1744
|
-
return sessionId
|
|
1745
|
-
}
|
|
1746
|
-
|
|
1747
|
-
nextLastTopicSaveSequence() {
|
|
1748
|
-
try {
|
|
1749
|
-
const stored = Number(sessionStorage.getItem(LAST_TOPIC_SAVE_SEQUENCE_STORAGE_KEY))
|
|
1750
|
-
const previous = Number.isSafeInteger(stored) && stored >= 0 ? stored : 0
|
|
1751
|
-
const sequence = Math.max(this._lastTopicSaveSequence || 0, previous) + 1
|
|
1752
|
-
sessionStorage.setItem(LAST_TOPIC_SAVE_SEQUENCE_STORAGE_KEY, String(sequence))
|
|
1753
|
-
return sequence
|
|
1754
|
-
} catch (_) {
|
|
1755
|
-
return (this._lastTopicSaveSequence || 0) + 1
|
|
1756
|
-
}
|
|
1638
|
+
return this.saveOrderState.nextClientId()
|
|
1757
1639
|
}
|
|
1758
1640
|
|
|
1759
1641
|
// A request that never settles must not hold every later pick behind it.
|
|
@@ -1908,13 +1790,11 @@ export default class extends Controller {
|
|
|
1908
1790
|
}
|
|
1909
1791
|
|
|
1910
1792
|
get ambiguousPendingSelfEchoRetirements() {
|
|
1911
|
-
return this.
|
|
1912
|
-
(this._ambiguousPendingSelfEchoRetirements = new Map())
|
|
1793
|
+
return this.selfEchoState.ambiguousRetirementTimers
|
|
1913
1794
|
}
|
|
1914
1795
|
|
|
1915
1796
|
get retiredSelfEchoSequenceHighWaters() {
|
|
1916
|
-
return this.
|
|
1917
|
-
(this._retiredSelfEchoSequenceHighWaters = new Map())
|
|
1797
|
+
return this.selfEchoState.retiredSequenceHighWaters
|
|
1918
1798
|
}
|
|
1919
1799
|
|
|
1920
1800
|
// An early echo can be the only proof that an in-flight GET predates a
|
|
@@ -1937,15 +1817,15 @@ export default class extends Controller {
|
|
|
1937
1817
|
// time it arrives the user may have picked something else — applying it
|
|
1938
1818
|
// then reverts the newer pick and persists the older topic over it.
|
|
1939
1819
|
get pendingSelfEchoes() {
|
|
1940
|
-
return this.
|
|
1820
|
+
return this.selfEchoState.pendingIds
|
|
1941
1821
|
}
|
|
1942
1822
|
|
|
1943
1823
|
get pendingSelfEchoCreativeIds() {
|
|
1944
|
-
return this.
|
|
1824
|
+
return this.selfEchoState.creativeIds
|
|
1945
1825
|
}
|
|
1946
1826
|
|
|
1947
1827
|
get pendingSelfEchoTopicIds() {
|
|
1948
|
-
return this.
|
|
1828
|
+
return this.selfEchoState.topicIds
|
|
1949
1829
|
}
|
|
1950
1830
|
|
|
1951
1831
|
// The last preference observed from the server is the baseline for a save.
|
|
@@ -1961,50 +1841,41 @@ export default class extends Controller {
|
|
|
1961
1841
|
}
|
|
1962
1842
|
|
|
1963
1843
|
lastKnownRemoteTopicIdFor(creativeId) {
|
|
1964
|
-
return this.
|
|
1844
|
+
return this.saveOrderState.lastKnownTopicIdFor(creativeId)
|
|
1965
1845
|
}
|
|
1966
1846
|
|
|
1967
1847
|
setLastKnownRemoteTopicId(creativeId, value) {
|
|
1968
|
-
this.
|
|
1848
|
+
this.saveOrderState.setLastKnownTopicId(creativeId, value)
|
|
1969
1849
|
}
|
|
1970
1850
|
|
|
1971
1851
|
get lastKnownRemoteTopicIds() {
|
|
1972
|
-
return this.
|
|
1852
|
+
return this.saveOrderState.lastKnownRemoteTopicIds
|
|
1973
1853
|
}
|
|
1974
1854
|
|
|
1975
1855
|
// Action Cable is ordered only within a connection. A delayed older message
|
|
1976
1856
|
// can therefore arrive after a newer GET, response, or broadcast. Keep the
|
|
1977
1857
|
// server-issued revision per effective stream and never apply it backward.
|
|
1978
1858
|
observeLastTopicRevision(creativeId, revision) {
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
const streamCreativeId = String(creativeId)
|
|
1982
|
-
const previous = this.highestLastTopicRevisions.get(streamCreativeId)
|
|
1983
|
-
const comparison = this.compareLastTopicRevisions(revision, previous)
|
|
1984
|
-
if (comparison !== null && comparison < 0) return false
|
|
1985
|
-
if (comparison === null || comparison > 0) {
|
|
1986
|
-
this.highestLastTopicRevisions.set(streamCreativeId, revision)
|
|
1987
|
-
}
|
|
1988
|
-
return true
|
|
1859
|
+
return this.saveOrderState.observeRevision(creativeId, revision)
|
|
1989
1860
|
}
|
|
1990
1861
|
|
|
1991
1862
|
get highestLastTopicRevisions() {
|
|
1992
|
-
return this.
|
|
1863
|
+
return this.saveOrderState.highestRevisions
|
|
1993
1864
|
}
|
|
1994
1865
|
|
|
1995
1866
|
// The server resolves TopicsChannel subscriptions for linked shells to their
|
|
1996
1867
|
// origin stream. Keep that result separately from the popup-scoped dataset:
|
|
1997
1868
|
// the latter is deliberately cleared while a replacement load is pending.
|
|
1998
1869
|
get knownEffectiveCreativeIds() {
|
|
1999
|
-
return this.
|
|
1870
|
+
return this.saveOrderState.knownEffectiveCreativeIds
|
|
2000
1871
|
}
|
|
2001
1872
|
|
|
2002
1873
|
get pendingSelfEchoPreviousTopicIds() {
|
|
2003
|
-
return this.
|
|
1874
|
+
return this.selfEchoState.previousTopicIds
|
|
2004
1875
|
}
|
|
2005
1876
|
|
|
2006
1877
|
get pendingSelfEchoAcknowledgementVersions() {
|
|
2007
|
-
return this.
|
|
1878
|
+
return this.selfEchoState.acknowledgementVersions
|
|
2008
1879
|
}
|
|
2009
1880
|
|
|
2010
1881
|
// The preference row id distinguishes a record recreated after clearing the
|
|
@@ -2012,36 +1883,37 @@ export default class extends Controller {
|
|
|
2012
1883
|
// they are a server-issued ordering token, rather than an inference from a
|
|
2013
1884
|
// topic id that can repeat in an ABA change (Main -> Alpha -> Main).
|
|
2014
1885
|
normalizeLastTopicRevision(value) {
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
1886
|
+
return this.saveOrderState.normalizeRevision(value)
|
|
1887
|
+
}
|
|
1888
|
+
|
|
1889
|
+
isPersistedAllMessagesSelection(topicId, allMessages) {
|
|
1890
|
+
return !topicId && allMessages === true
|
|
2018
1891
|
}
|
|
2019
1892
|
|
|
2020
1893
|
compareLastTopicRevisions(left, right) {
|
|
2021
|
-
|
|
2022
|
-
return left[0] === right[0] ? left[1] - right[1] : left[0] - right[0]
|
|
1894
|
+
return this.saveOrderState.compareRevisions(left, right)
|
|
2023
1895
|
}
|
|
2024
1896
|
|
|
2025
1897
|
get pendingSelfEchoRemoteRevisions() {
|
|
2026
|
-
return this.
|
|
1898
|
+
return this.selfEchoState.remoteRevisions
|
|
2027
1899
|
}
|
|
2028
1900
|
|
|
2029
1901
|
// Echoes normally remove their claims. A short-lived tombstone retains the
|
|
2030
1902
|
// save order for GETs already in progress when the echo arrived.
|
|
2031
1903
|
get settledSelfEchoes() {
|
|
2032
|
-
return this.
|
|
1904
|
+
return this.selfEchoState.settledIds
|
|
2033
1905
|
}
|
|
2034
1906
|
|
|
2035
1907
|
get activeLoadAcknowledgementVersions() {
|
|
2036
|
-
return this.
|
|
1908
|
+
return this.saveOrderState.activeLoadAcknowledgementVersions
|
|
2037
1909
|
}
|
|
2038
1910
|
|
|
2039
1911
|
get saveAcknowledgementVersion() {
|
|
2040
|
-
return this.
|
|
1912
|
+
return this.saveOrderState.acknowledgementVersion
|
|
2041
1913
|
}
|
|
2042
1914
|
|
|
2043
1915
|
set saveAcknowledgementVersion(value) {
|
|
2044
|
-
this.
|
|
1916
|
+
this.saveOrderState.acknowledgementVersion = value
|
|
2045
1917
|
}
|
|
2046
1918
|
|
|
2047
1919
|
// These claims were already in flight when the popup unsubscribed. If their
|
|
@@ -2049,7 +1921,7 @@ export default class extends Controller {
|
|
|
2049
1921
|
// went into that gap. A replacement subscription can receive an echo when it
|
|
2050
1922
|
// reopens before the response arrives, though.
|
|
2051
1923
|
get possiblyMissedPendingSelfEchoes() {
|
|
2052
|
-
return this.
|
|
1924
|
+
return this.selfEchoState.possiblyMissedIds
|
|
2053
1925
|
}
|
|
2054
1926
|
|
|
2055
1927
|
// A broadcast sent after Action Cable disconnects is not replayed after the
|
|
@@ -2057,8 +1929,7 @@ export default class extends Controller {
|
|
|
2057
1929
|
// whether one could have been sent in that gap; acknowledged saves can be
|
|
2058
1930
|
// retired immediately because their broadcast has already been sent.
|
|
2059
1931
|
get possiblyMissedPendingSelfEchoesDuringDisconnect() {
|
|
2060
|
-
return this.
|
|
2061
|
-
(this._possiblyMissedPendingSelfEchoesDuringDisconnect = new Set())
|
|
1932
|
+
return this.selfEchoState.possiblyMissedDuringDisconnectIds
|
|
2062
1933
|
}
|
|
2063
1934
|
|
|
2064
1935
|
handleTopicsSubscriptionDisconnected() {
|
|
@@ -2120,7 +1991,7 @@ export default class extends Controller {
|
|
|
2120
1991
|
// open popup keeps its id long enough to consume an echo still in flight,
|
|
2121
1992
|
// without allowing it to override a later reopen snapshot.
|
|
2122
1993
|
get acknowledgedPendingSelfEchoes() {
|
|
2123
|
-
return this.
|
|
1994
|
+
return this.selfEchoState.acknowledgedIds
|
|
2124
1995
|
}
|
|
2125
1996
|
|
|
2126
1997
|
acknowledgePendingSelfEcho(clientId) {
|
|
@@ -2205,7 +2076,7 @@ export default class extends Controller {
|
|
|
2205
2076
|
}
|
|
2206
2077
|
|
|
2207
2078
|
get deferredLastTopicReconciliations() {
|
|
2208
|
-
return this.
|
|
2079
|
+
return this.saveOrderState.deferredReconciliations
|
|
2209
2080
|
}
|
|
2210
2081
|
|
|
2211
2082
|
retryDeferredLastTopicReconciliation(creativeId) {
|
|
@@ -2222,38 +2093,29 @@ export default class extends Controller {
|
|
|
2222
2093
|
// subscription must not prevent a queued save for the original stream from
|
|
2223
2094
|
// claiming its own echo when the user returns to it.
|
|
2224
2095
|
subscriptionGenerationFor(creativeId) {
|
|
2225
|
-
|
|
2226
|
-
if (!this.subscriptionGenerations.has(streamCreativeId)) {
|
|
2227
|
-
this.subscriptionGenerations.set(streamCreativeId, 0)
|
|
2228
|
-
}
|
|
2229
|
-
return this.subscriptionGenerations.get(streamCreativeId)
|
|
2096
|
+
return this.saveOrderState.subscriptionGenerationFor(creativeId)
|
|
2230
2097
|
}
|
|
2231
2098
|
|
|
2232
2099
|
bumpSubscriptionGenerationFor(creativeId) {
|
|
2233
|
-
|
|
2234
|
-
this.subscriptionGenerations.set(
|
|
2235
|
-
streamCreativeId,
|
|
2236
|
-
this.subscriptionGenerationFor(streamCreativeId) + 1
|
|
2237
|
-
)
|
|
2100
|
+
this.saveOrderState.bumpSubscriptionGeneration(creativeId)
|
|
2238
2101
|
}
|
|
2239
2102
|
|
|
2240
2103
|
get subscriptionGenerations() {
|
|
2241
|
-
return this.
|
|
2104
|
+
return this.saveOrderState.subscriptionGenerations
|
|
2242
2105
|
}
|
|
2243
2106
|
|
|
2244
2107
|
// The legacy key is adopted only as a stand-in for a preference the server
|
|
2245
|
-
// does not hold yet. A winning empty pick
|
|
2246
|
-
//
|
|
2247
|
-
//
|
|
2248
|
-
//
|
|
2108
|
+
// does not hold yet. A winning empty pick or a revisioned cleared preference
|
|
2109
|
+
// is an All Messages selection — it just names no topic, so adopting the
|
|
2110
|
+
// legacy value would hand the user back a topic they did not ask for and
|
|
2111
|
+
// persist it. The caller knows whether the empty value is intentional.
|
|
2249
2112
|
//
|
|
2250
|
-
// The key still goes
|
|
2251
|
-
//
|
|
2252
|
-
|
|
2253
|
-
migrateLocalStorage({ keepEmptyPick = false } = {}) {
|
|
2113
|
+
// The key still goes either way: an intentional empty selection supersedes
|
|
2114
|
+
// it, so leaving it behind would only re-apply a value the user moved off.
|
|
2115
|
+
migrateLocalStorage({ keepEmptySelection = false } = {}) {
|
|
2254
2116
|
const key = `collavre_creative_${this.creativeId}_last_topic`
|
|
2255
2117
|
const localValue = localStorage.getItem(key)
|
|
2256
|
-
if (localValue && !this.serverLastTopicId && !
|
|
2118
|
+
if (localValue && !this.serverLastTopicId && !keepEmptySelection) {
|
|
2257
2119
|
this.serverLastTopicId = localValue
|
|
2258
2120
|
// The migration is a save like any other. Giving it a client id
|
|
2259
2121
|
// prevents its broadcast from being mistaken for another session's
|
|
@@ -2316,7 +2178,7 @@ export default class extends Controller {
|
|
|
2316
2178
|
...this.settledSelfEchoes,
|
|
2317
2179
|
].filter(clientId => this.pendingSelfEchoCreativeIds.get(clientId) === streamCreativeId))
|
|
2318
2180
|
|
|
2319
|
-
this.
|
|
2181
|
+
this.selfEchoState.pendingIds = this.pendingSelfEchoes.filter(clientId => !clientIds.has(clientId))
|
|
2320
2182
|
for (const clientId of clientIds) this.discardSelfEchoMetadata(clientId)
|
|
2321
2183
|
this.bumpSubscriptionGenerationFor(streamCreativeId)
|
|
2322
2184
|
}
|
|
@@ -2365,9 +2227,16 @@ export default class extends Controller {
|
|
|
2365
2227
|
|
|
2366
2228
|
const action = data.action || "created"
|
|
2367
2229
|
|
|
2230
|
+
if (action === "cron_changed" || data.cron_changed) {
|
|
2231
|
+
invalidateCreativeTree()
|
|
2232
|
+
this.loadTopics()
|
|
2233
|
+
return
|
|
2234
|
+
}
|
|
2235
|
+
|
|
2368
2236
|
if (action === "last_topic_changed") {
|
|
2369
2237
|
// Broadcast is already scoped to the current user via user-specific channel
|
|
2370
2238
|
const newTopicId = data.last_topic_id ? String(data.last_topic_id) : ""
|
|
2239
|
+
const allMessages = data.last_topic_all_messages === true
|
|
2371
2240
|
const lastTopicRevision = this.normalizeLastTopicRevision(data.last_topic_revision)
|
|
2372
2241
|
// A retired ambiguous save remains non-actionable, but it can still have
|
|
2373
2242
|
// committed after the request failed. Its revision must advance this
|
|
@@ -2403,7 +2272,9 @@ export default class extends Controller {
|
|
|
2403
2272
|
// session still established that preference, so the queued one-shot link
|
|
2404
2273
|
// must not write itself back over it.
|
|
2405
2274
|
if (this.hasDeepLinkSelection) this.cancelPendingSaveLastTopic()
|
|
2406
|
-
|
|
2275
|
+
const explicitSelectionChanged = allMessages !== this._explicitAllMessagesSelection
|
|
2276
|
+
this._explicitAllMessagesSelection = allMessages
|
|
2277
|
+
if (newTopicId !== this.serverLastTopicId || explicitSelectionChanged) {
|
|
2407
2278
|
this.serverLastTopicId = newTopicId
|
|
2408
2279
|
// Another session moved the preference; nobody clicked in this
|
|
2409
2280
|
// popup. A deep link outranks the preference in the getter, so
|
|
@@ -2523,10 +2394,28 @@ export default class extends Controller {
|
|
|
2523
2394
|
}
|
|
2524
2395
|
|
|
2525
2396
|
removeTopic(topicId) {
|
|
2526
|
-
if (!topicId) return
|
|
2397
|
+
if (!topicId || reloadDeletedReservedTopic(this, topicId)) return
|
|
2527
2398
|
|
|
2399
|
+
// loadTopics clears its cache before awaiting the response. If a
|
|
2400
|
+
// deletion arrives in that window, the local filter has nothing to
|
|
2401
|
+
// retain and the old response must not rebuild the deleted chip. A
|
|
2402
|
+
// replacement load both invalidates that response and refills the strip.
|
|
2403
|
+
const topicLoadInFlight = this.activeLoadAcknowledgementVersions.has(this._loadTopicsVersion)
|
|
2528
2404
|
const topics = this.topics || []
|
|
2529
2405
|
const archivedTopics = this.archivedTopics || []
|
|
2406
|
+
const removedCurrentSelection = String(this.currentTopicId) === String(topicId)
|
|
2407
|
+
if (topicLoadInFlight) {
|
|
2408
|
+
if (removedCurrentSelection) {
|
|
2409
|
+
this.fallbackFromRemovedTopic(topicId)
|
|
2410
|
+
this.dispatch("change", { detail: { topicId: "", mainTopicId: this.mainTopicId } })
|
|
2411
|
+
}
|
|
2412
|
+
// The cache is intentionally incomplete while loadTopics awaits.
|
|
2413
|
+
// Restoring against it can replace a distinct preference hidden
|
|
2414
|
+
// behind the removed deep link with Main. Let the replacement
|
|
2415
|
+
// response provide the authoritative list before restoring.
|
|
2416
|
+
this.loadTopics()
|
|
2417
|
+
return
|
|
2418
|
+
}
|
|
2530
2419
|
const nextTopics = topics.filter((topic) => String(topic.id) !== String(topicId))
|
|
2531
2420
|
// An archived topic is deletable and now selectable, so the "deleted"
|
|
2532
2421
|
// broadcast has to reach this cache too — nothing else does. It is the
|
|
@@ -2534,14 +2423,14 @@ export default class extends Controller {
|
|
|
2534
2423
|
// from here would keep an openable chip and, through pruneArchivedBadges
|
|
2535
2424
|
// never running, a lit toggle for a conversation that no longer exists.
|
|
2536
2425
|
const nextArchivedTopics = archivedTopics.filter((topic) => String(topic.id) !== String(topicId))
|
|
2537
|
-
if (nextTopics.length === topics.length && nextArchivedTopics.length === archivedTopics.length
|
|
2426
|
+
if (nextTopics.length === topics.length && nextArchivedTopics.length === archivedTopics.length &&
|
|
2427
|
+
!removedCurrentSelection) return
|
|
2538
2428
|
|
|
2539
2429
|
this.topics = nextTopics
|
|
2540
2430
|
this.archivedTopics = nextArchivedTopics
|
|
2541
2431
|
this.pruneArchivedBadges()
|
|
2542
|
-
if (
|
|
2543
|
-
this.
|
|
2544
|
-
this.currentTopicId = ""
|
|
2432
|
+
if (removedCurrentSelection) {
|
|
2433
|
+
this.fallbackFromRemovedTopic(topicId)
|
|
2545
2434
|
this.dispatch("change", { detail: { topicId: "", mainTopicId: this.mainTopicId } })
|
|
2546
2435
|
}
|
|
2547
2436
|
|
|
@@ -2549,37 +2438,6 @@ export default class extends Controller {
|
|
|
2549
2438
|
this.restoreSelection()
|
|
2550
2439
|
}
|
|
2551
2440
|
|
|
2552
|
-
handleAddButtonDragOver(event) {
|
|
2553
|
-
const isAgent = event.dataTransfer.types.includes('application/x-agent-drop')
|
|
2554
|
-
const isComment = event.dataTransfer.types.includes('application/x-comment-ids')
|
|
2555
|
-
if (!isAgent && !isComment) return
|
|
2556
|
-
event.preventDefault()
|
|
2557
|
-
event.dataTransfer.dropEffect = isAgent ? 'copy' : 'move'
|
|
2558
|
-
event.currentTarget.classList.add('drag-over')
|
|
2559
|
-
}
|
|
2560
|
-
|
|
2561
|
-
async handleAddButtonDrop(event) {
|
|
2562
|
-
event.preventDefault()
|
|
2563
|
-
event.currentTarget.classList.remove('drag-over')
|
|
2564
|
-
|
|
2565
|
-
// Handle comment drop → create new topic + move
|
|
2566
|
-
const commentIdsJson = event.dataTransfer.getData('application/x-comment-ids')
|
|
2567
|
-
if (commentIdsJson) {
|
|
2568
|
-
const commentIds = JSON.parse(commentIdsJson)
|
|
2569
|
-
if (commentIds && commentIds.length > 0) {
|
|
2570
|
-
await this.createTopicAndMoveComments(commentIds)
|
|
2571
|
-
}
|
|
2572
|
-
return
|
|
2573
|
-
}
|
|
2574
|
-
|
|
2575
|
-
// Handle agent drop (existing logic)
|
|
2576
|
-
const agentJson = event.dataTransfer.getData('application/x-agent-drop')
|
|
2577
|
-
if (!agentJson) return
|
|
2578
|
-
|
|
2579
|
-
const agent = JSON.parse(agentJson)
|
|
2580
|
-
await this.createTopicWithAgent(agent)
|
|
2581
|
-
}
|
|
2582
|
-
|
|
2583
2441
|
async createTopicAndMoveComments(commentIds, topicName = null) {
|
|
2584
2442
|
if (!this.creativeId) return
|
|
2585
2443
|
|