collavre 0.24.1 → 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 -11
- 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 +668 -165
- data/app/assets/stylesheets/collavre/creatives.css +1165 -155
- 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 +241 -0
- data/app/assets/stylesheets/collavre/gnb.css +64 -3
- data/app/assets/stylesheets/collavre/image_lightbox.css +12 -0
- data/app/assets/stylesheets/collavre/landing.css +130 -106
- data/app/assets/stylesheets/collavre/llm_usages.css +67 -0
- data/app/assets/stylesheets/collavre/mention_menu.css +50 -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 +29 -18
- data/app/assets/stylesheets/collavre/print.css +0 -1
- data/app/assets/stylesheets/collavre/search_popup.css +1 -35
- data/app/assets/stylesheets/collavre/secret_fields.css +3 -0
- 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 +310 -0
- data/app/channels/collavre/agent_channel.rb +61 -43
- data/app/channels/collavre/comments_presence_channel.rb +181 -21
- data/app/channels/collavre/inbox_badge_channel.rb +7 -1
- 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/components/collavre/inbox/badge_component.rb +6 -13
- data/app/components/collavre/progress_filter_component.html.erb +2 -2
- data/app/components/collavre/progress_filter_component.rb +20 -0
- data/app/controllers/collavre/admin/orchestration_controller.rb +59 -32
- data/app/controllers/collavre/admin/settings_controller.rb +80 -8
- data/app/controllers/collavre/agent_connections_controller.rb +153 -0
- data/app/controllers/collavre/agent_gateways_controller.rb +132 -0
- data/app/controllers/collavre/agent_models_controller.rb +55 -0
- data/app/controllers/collavre/agent_provisioning_controller.rb +88 -0
- data/app/controllers/collavre/api/v1/agents_controller.rb +81 -249
- data/app/controllers/collavre/api/v1/task_suspensions_controller.rb +60 -0
- data/app/controllers/collavre/application_controller.rb +13 -2
- data/app/controllers/collavre/attachments_controller.rb +12 -12
- data/app/controllers/collavre/comment_read_pointers_controller.rb +69 -40
- 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 +104 -139
- data/app/controllers/collavre/concerns/creative_history_trackable.rb +31 -0
- data/app/controllers/collavre/concerns/shareable.rb +9 -3
- 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 +186 -276
- data/app/controllers/collavre/crons_controller.rb +48 -0
- data/app/controllers/collavre/desktop_gateway_registrations_controller.rb +156 -0
- data/app/controllers/collavre/desktop_setup_controller.rb +102 -0
- data/app/controllers/collavre/desktop_sidecar_health_controller.rb +23 -0
- data/app/controllers/collavre/features_controller.rb +57 -0
- 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/invites_controller.rb +12 -1
- data/app/controllers/collavre/llm_models_controller.rb +8 -0
- data/app/controllers/collavre/llm_usages_controller.rb +51 -0
- data/app/controllers/collavre/notices_controller.rb +20 -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/tasks_controller.rb +40 -6
- data/app/controllers/collavre/topics_controller.rb +136 -74
- data/app/controllers/collavre/user_creative_preferences_controller.rb +182 -31
- 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 +16 -4
- data/app/controllers/concerns/collavre/comments/comment_scoping.rb +4 -2
- data/app/controllers/concerns/collavre/comments/conversion.rb +1 -1
- 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 +182 -32
- data/app/controllers/concerns/collavre/users_controller/contact_management.rb +31 -18
- data/app/controllers/concerns/collavre/users_controller/profile_and_settings.rb +15 -15
- data/app/controllers/concerns/collavre/users_controller/registration.rb +9 -13
- 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/errors/collavre/turn_deadline_error.rb +20 -0
- data/app/helpers/collavre/activity_logs_helper.rb +26 -0
- data/app/helpers/collavre/application_helper.rb +45 -41
- data/app/helpers/collavre/creative_move_helper.rb +15 -0
- data/app/helpers/collavre/creatives_helper.rb +158 -72
- data/app/helpers/collavre/navigation_helper.rb +134 -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 +4 -2
- 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 +29 -78
- 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_parent_id.test.js +32 -2
- data/app/javascript/components/__tests__/creative_tree_row_progress_toggle.test.js +255 -0
- 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 +96 -99
- 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 +625 -0
- 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__/desktop_proxy_setup_controller.test.js +96 -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 +48 -0
- data/app/javascript/controllers/__tests__/inline_creative_picker_controller.test.js +232 -0
- data/app/javascript/controllers/__tests__/last_visited_creative_controller.test.js +103 -0
- data/app/javascript/controllers/__tests__/link_creative_controller.test.js +354 -2
- 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__/progress_filter_controller.test.js +134 -0
- data/app/javascript/controllers/__tests__/search_popup_controller.test.js +324 -0
- 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 +125 -0
- data/app/javascript/controllers/__tests__/workspace_tree_controller.test.js +1746 -0
- data/app/javascript/controllers/agent_auth_controller.js +245 -0
- data/app/javascript/controllers/agent_connection_controller.js +197 -0
- data/app/javascript/controllers/agent_vendor_controller.js +69 -0
- data/app/javascript/controllers/comment_agent_model_controller.js +87 -0
- data/app/javascript/controllers/comment_controller.js +34 -75
- 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 +223 -0
- data/app/javascript/controllers/comments/__tests__/form_controller_default_placeholder.test.js +83 -0
- 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 +2254 -0
- data/app/javascript/controllers/comments/__tests__/form_controller_ime_send.test.js +324 -0
- data/app/javascript/controllers/comments/__tests__/form_controller_review.test.js +377 -2
- data/app/javascript/controllers/comments/__tests__/form_controller_search_submit.test.js +106 -0
- data/app/javascript/controllers/comments/__tests__/form_controller_stashed_draft.test.js +134 -0
- data/app/javascript/controllers/comments/__tests__/form_controller_stashed_draft_creative_switch.test.js +166 -0
- data/app/javascript/controllers/comments/__tests__/form_controller_stashed_draft_failure.test.js +183 -0
- 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_deep_link_topic.test.js +467 -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 +168 -0
- 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 +217 -1
- data/app/javascript/controllers/comments/__tests__/list_controller_read_pointer.test.js +288 -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__/list_controller_stream_archived.test.js +221 -0
- data/app/javascript/controllers/comments/__tests__/list_controller_stream_search.test.js +104 -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__/placeholder_controller.test.js +79 -0
- data/app/javascript/controllers/comments/__tests__/popup_controller.test.js +1070 -3
- 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 +775 -15
- 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_action_errors.test.js +6 -0
- data/app/javascript/controllers/comments/__tests__/topics_controller_archived.test.js +924 -0
- data/app/javascript/controllers/comments/__tests__/topics_controller_creation_container.test.js +165 -0
- data/app/javascript/controllers/comments/__tests__/topics_controller_creation_scroll.test.js +92 -0
- data/app/javascript/controllers/comments/__tests__/topics_controller_delete.test.js +361 -0
- data/app/javascript/controllers/comments/__tests__/topics_controller_dnd.test.js +120 -0
- data/app/javascript/controllers/comments/__tests__/topics_controller_docked.test.js +32 -0
- data/app/javascript/controllers/comments/__tests__/topics_controller_last_topic_echo.test.js +1938 -0
- data/app/javascript/controllers/comments/__tests__/topics_controller_primary_agent.test.js +112 -2
- data/app/javascript/controllers/comments/__tests__/topics_controller_scroll.test.js +199 -0
- data/app/javascript/controllers/comments/__tests__/topics_controller_selection_race.test.js +1253 -0
- data/app/javascript/controllers/comments/__tests__/topics_controller_topic_list.test.js +313 -0
- 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 +83 -0
- data/app/javascript/controllers/comments/form_controller.js +375 -175
- 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 +283 -186
- 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/placeholder_controller.js +30 -0
- data/app/javascript/controllers/comments/popup_controller.js +379 -473
- 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 +598 -183
- 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 +1723 -240
- data/app/javascript/controllers/common_popup_controller.js +2 -2
- 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 +250 -0
- data/app/javascript/controllers/creatives/__tests__/tree_controller.test.js +1210 -2
- data/app/javascript/controllers/creatives/__tests__/workflow_rule_controller.test.js +322 -0
- data/app/javascript/controllers/creatives/__tests__/write_access_request_controller.test.js +125 -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 +38 -6
- data/app/javascript/controllers/creatives/tree_controller.js +260 -59
- 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/creatives/write_access_request_controller.js +58 -0
- data/app/javascript/controllers/cron_badge_controller.js +187 -0
- data/app/javascript/controllers/desktop_proxy_setup_controller.js +51 -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 +34 -0
- 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 +106 -8
- data/app/javascript/controllers/inline_creative_picker_controller.js +110 -0
- data/app/javascript/controllers/last_visited_creative_controller.js +58 -0
- data/app/javascript/controllers/link_creative_controller.js +102 -28
- 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/progress_filter_controller.js +12 -22
- data/app/javascript/controllers/search_popup_controller.js +72 -50
- 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 +3 -13
- 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 +42 -31
- data/app/javascript/controllers/topic_search_controller.js +2 -4
- data/app/javascript/controllers/workspace_tree_controller.js +803 -0
- 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 +195 -0
- 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__/drop_completion_empty_state.test.js +98 -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__/topic_move_released_agent.test.js +125 -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 +291 -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 +132 -40
- data/app/javascript/creatives/tree_view_state.js +87 -0
- data/app/javascript/lib/__tests__/chat_drafts.test.js +1458 -0
- data/app/javascript/lib/__tests__/common_popup_bounds.test.js +8 -3
- data/app/javascript/lib/__tests__/common_popup_placement.test.js +374 -0
- data/app/javascript/lib/__tests__/common_popup_reshow.test.js +131 -0
- data/app/javascript/lib/__tests__/creative_link_prefetch.test.js +46 -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__/last_visited_creative.test.js +87 -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__/skill_html_entities.test.js +23 -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 +218 -0
- 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 +94 -0
- data/app/javascript/lib/api/__tests__/csrf_fetch.test.js +27 -0
- 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/__tests__/topics_save_last_topic.test.js +112 -0
- data/app/javascript/lib/api/creatives.js +35 -13
- data/app/javascript/lib/api/csrf_fetch.js +6 -4
- 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/api/topics.js +63 -5
- data/app/javascript/lib/chat_drafts.js +786 -0
- data/app/javascript/lib/common_popup.js +164 -25
- data/app/javascript/lib/creative_link_prefetch.js +27 -0
- 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/last_visited_creative.js +97 -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 +212 -0
- data/app/javascript/lib/lexical/__tests__/creative_link_trigger.test.js +133 -0
- data/app/javascript/lib/lexical/__tests__/file_drop.test.js +288 -0
- data/app/javascript/lib/lexical/__tests__/link_toolbar.test.js +62 -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 +127 -0
- data/app/javascript/lib/lexical/creative_link_trigger.js +98 -0
- data/app/javascript/lib/lexical/file_drop.js +106 -0
- data/app/javascript/lib/lexical/link_toolbar.js +23 -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 +41 -16
- 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 +226 -0
- data/app/javascript/lib/utils/__tests__/focus.test.js +144 -0
- data/app/javascript/lib/utils/__tests__/markdown.test.js +44 -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 +114 -0
- 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_creative_picker.test.js +62 -0
- data/app/javascript/modules/__tests__/command_menu_details.test.js +199 -0
- data/app/javascript/modules/__tests__/command_menu_typeahead.test.js +267 -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_link_picker.test.js +85 -0
- data/app/javascript/modules/__tests__/creative_row_editor_archive.test.js +391 -0
- data/app/javascript/modules/__tests__/creative_row_editor_background_create.test.js +2147 -0
- data/app/javascript/modules/__tests__/creative_row_editor_delegated_clicks.test.js +158 -0
- data/app/javascript/modules/__tests__/creative_row_editor_empty_state_recovery.test.js +214 -0
- data/app/javascript/modules/__tests__/creative_row_editor_empty_state_removal.test.js +468 -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_row_editor_session.test.js +144 -0
- data/app/javascript/modules/__tests__/creative_save_state.test.js +165 -0
- data/app/javascript/modules/__tests__/creative_tree_dom.test.js +30 -0
- data/app/javascript/modules/__tests__/creative_tree_empty_state.test.js +186 -0
- data/app/javascript/modules/__tests__/creative_type_editor.test.js +203 -0
- data/app/javascript/modules/__tests__/dom_listener_registry.test.js +67 -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 +183 -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 +30 -40
- data/app/javascript/modules/command_menu.js +171 -55
- 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_link_picker.js +56 -0
- data/app/javascript/modules/creative_removal.js +39 -0
- data/app/javascript/modules/creative_row_editor.js +818 -634
- data/app/javascript/modules/creative_row_editor_delegated_clicks.js +87 -0
- data/app/javascript/modules/creative_save_state.js +141 -0
- data/app/javascript/modules/creative_tree_dom.js +4 -0
- data/app/javascript/modules/creative_tree_empty_state.js +80 -0
- data/app/javascript/modules/creative_type_editor.js +139 -0
- data/app/javascript/modules/dom_listener_registry.js +23 -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 +36 -25
- 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/javascript/utils/__tests__/caret_anchor.test.js +75 -0
- data/app/javascript/utils/__tests__/chevron_icons.test.js +15 -0
- data/app/javascript/utils/caret_position.js +10 -0
- data/app/javascript/utils/chevron_icons.js +7 -0
- data/app/jobs/collavre/agent_provisioning_sync_job.rb +79 -0
- data/app/jobs/collavre/ai_agent_job.rb +346 -135
- 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 +34 -106
- 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_badges_broadcast_job.rb +28 -0
- data/app/jobs/collavre/comment_link_preview_job.rb +33 -0
- data/app/jobs/collavre/comment_notification_job.rb +14 -0
- data/app/jobs/collavre/comment_push_delivery_sweep_job.rb +25 -0
- data/app/jobs/collavre/compress_job.rb +36 -49
- data/app/jobs/collavre/creative_broadcast_job.rb +166 -56
- 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 +55 -20
- data/app/jobs/collavre/cron_scheduler_job.rb +44 -3
- data/app/jobs/collavre/drop_trigger_job.rb +54 -35
- 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 +37 -44
- 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 +65 -20
- data/app/jobs/collavre/recover_interrupted_tasks_job.rb +79 -0
- data/app/jobs/collavre/restore_dropped_dispatches_job.rb +17 -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/stuck_detector_job.rb +1 -1
- data/app/jobs/collavre/touch_creative_subtree_job.rb +14 -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 +276 -0
- data/app/models/collavre/agent_subscription.rb +4 -4
- data/app/models/collavre/agent_workspace.rb +245 -0
- 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 +40 -52
- 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 +157 -79
- data/app/models/collavre/comment/suspension_notice.rb +20 -0
- data/app/models/collavre/comment/topic_membership.rb +61 -0
- data/app/models/collavre/comment/trigger_loop_resume.rb +77 -0
- data/app/models/collavre/comment.rb +350 -121
- data/app/models/collavre/comment_notification_delivery.rb +72 -0
- data/app/models/collavre/comment_presence_store/cache_batches.rb +64 -0
- data/app/models/collavre/comment_presence_store.rb +272 -12
- data/app/models/collavre/comment_read_pointer.rb +9 -15
- 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 +42 -27
- 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 +23 -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 +55 -114
- 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 +128 -4
- data/app/models/collavre/current.rb +9 -1
- data/app/models/collavre/llm_model.rb +63 -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 +72 -9
- 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 +194 -29
- 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 +89 -0
- data/app/models/collavre/user/ai_capabilities.rb +38 -0
- data/app/models/collavre/user.rb +114 -50
- data/app/models/collavre/user_creative_preference.rb +27 -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_provisioning/archive.rb +108 -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 +38 -7
- data/app/services/collavre/ai_agent/agent_lifecycle_manager.rb +78 -6
- 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 +20 -5
- 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 +67 -11
- 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/merged_trigger_comments.rb +164 -0
- data/app/services/collavre/ai_agent/message_builder.rb +217 -83
- 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/session_provisioner.rb +3 -7
- data/app/services/collavre/ai_agent/task_claim_service.rb +84 -18
- data/app/services/collavre/ai_agent/task_reply_service.rb +90 -0
- 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 +113 -50
- 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 +175 -136
- 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 +190 -0
- data/app/services/collavre/cli_proxy/endpoint_policy.rb +81 -0
- 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/identity.rb +47 -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/cli_proxy/safe_net_http_adapter.rb +19 -0
- data/app/services/collavre/command_menu_service.rb +18 -14
- data/app/services/collavre/comment_move_service.rb +100 -7
- 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 +27 -15
- data/app/services/collavre/comments/action_executor.rb +45 -27
- 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 -1
- 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 +161 -0
- data/app/services/collavre/comments/read_pointer_writer.rb +210 -0
- data/app/services/collavre/comments/read_receipt_broadcaster.rb +157 -0
- data/app/services/collavre/comments/read_receipt_index.rb +152 -0
- data/app/services/collavre/comments/topic_command.rb +68 -18
- data/app/services/collavre/comments/topic_mutation.rb +20 -0
- 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/breadcrumb_resolver.rb +1 -1
- 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/comment_badge_index.rb +299 -27
- 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 +140 -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 +41 -14
- data/app/services/collavre/creatives/tree_formatter.rb +6 -7
- 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_path_resolver.rb +50 -0
- data/app/services/collavre/creatives/workspace_tree_builder.rb +100 -0
- 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/crons/recurring_topic_tasks.rb +23 -0
- data/app/services/collavre/decision_questions.rb +125 -0
- data/app/services/collavre/home_page_path.rb +55 -0
- data/app/services/collavre/html_text.rb +64 -0
- data/app/services/collavre/http_client.rb +52 -7
- data/app/services/collavre/inbox_reply_service.rb +2 -1
- 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 -29
- 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 +488 -144
- data/app/services/collavre/orchestration/agent_recovery_trigger.rb +16 -0
- data/app/services/collavre/orchestration/arbiter.rb +57 -7
- data/app/services/collavre/orchestration/deferred_trigger_scope.rb +64 -0
- data/app/services/collavre/orchestration/delivery_record.rb +740 -0
- 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 +20 -9
- data/app/services/collavre/orchestration/matcher.rb +232 -44
- data/app/services/collavre/orchestration/offline_task_grace.rb +50 -0
- data/app/services/collavre/orchestration/policy_resolver.rb +110 -11
- 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 +19 -6
- data/app/services/collavre/orchestration/scheduling_hooks.rb +10 -0
- data/app/services/collavre/orchestration/selection.rb +76 -0
- data/app/services/collavre/orchestration/solid_queue_retry_recovery.rb +54 -0
- data/app/services/collavre/orchestration/stuck_detector.rb +25 -112
- data/app/services/collavre/orchestration/task_coalescer.rb +385 -0
- data/app/services/collavre/orchestration/task_resumer.rb +408 -0
- data/app/services/collavre/orchestration/topic_slot.rb +73 -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 +105 -15
- data/app/services/collavre/system_events/dispatcher.rb +67 -12
- data/app/services/collavre/system_events/envelope.rb +73 -0
- data/app/services/collavre/system_events/vocabulary.rb +48 -0
- 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 +101 -32
- 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/id_list.rb +38 -0
- 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 +62 -8
- data/app/services/collavre/tools/topic_branch_service.rb +85 -0
- data/app/services/collavre/tools/topic_create_service.rb +117 -0
- data/app/services/collavre/tools/topic_list_service.rb +101 -0
- data/app/services/collavre/tools/topic_message_create_service.rb +210 -0
- data/app/services/collavre/tools/topic_messages_service.rb +346 -0
- data/app/services/collavre/tools/topic_move_service.rb +107 -0
- data/app/services/collavre/tools/topic_selection.rb +59 -0
- data/app/services/collavre/tools/topic_tasks_service.rb +42 -0
- data/app/services/collavre/tools/topic_update_service.rb +165 -0
- data/app/services/collavre/topic_branch_service.rb +40 -10
- data/app/services/collavre/topics/active_topic_snapshot.rb +30 -0
- data/app/services/collavre/topics/agent_resolver.rb +93 -0
- data/app/services/collavre/topics/char_budget.rb +70 -0
- data/app/services/collavre/topics/cron_badge_decorator.rb +32 -0
- data/app/services/collavre/topics/last_topic_preference_payload.rb +19 -0
- data/app/services/collavre/topics/message_page.rb +380 -0
- data/app/services/collavre/topics/message_page_markdown.rb +102 -0
- data/app/services/collavre/topics/message_scope.rb +61 -0
- data/app/services/collavre/topics/message_stats.rb +92 -0
- data/app/services/collavre/topics/move_blocker.rb +47 -0
- data/app/services/collavre/topics/next_name.rb +35 -0
- data/app/services/collavre/topics/orphaned_cron_notifier.rb +33 -14
- data/app/services/collavre/topics/pin_rejection.rb +39 -0
- data/app/services/collavre/topics/read_pointer_relocator.rb +71 -0
- data/app/services/collavre/topics/reserved_name.rb +24 -0
- data/app/services/collavre/topics/serializer.rb +99 -0
- data/app/services/collavre/topics/topic_destroy.rb +30 -0
- data/app/services/collavre/topics/topic_move.rb +99 -0
- data/app/services/collavre/topics/topic_move_effects.rb +35 -0
- data/app/services/collavre/topics/topic_mutation.rb +27 -0
- 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/integrations/_setting_row.html.erb +5 -8
- data/app/views/collavre/admin/settings/_system_tab.html.erb +56 -11
- data/app/views/collavre/agent_connections/show.html.erb +84 -0
- data/app/views/collavre/agent_gateways/_form.html.erb +85 -0
- data/app/views/collavre/agent_gateways/edit.html.erb +4 -0
- data/app/views/collavre/agent_gateways/index.html.erb +51 -0
- data/app/views/collavre/agent_gateways/new.html.erb +4 -0
- 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 +105 -29
- data/app/views/collavre/comments/_creative_quote_review.html.erb +29 -0
- data/app/views/collavre/comments/_empty_state.html.erb +33 -0
- data/app/views/collavre/comments/_empty_state_minimal.html.erb +7 -0
- data/app/views/collavre/comments/_feature_card.html.erb +35 -0
- data/app/views/collavre/comments/_list.html.erb +3 -2
- data/app/views/collavre/comments/_loading.html.erb +7 -0
- data/app/views/collavre/comments/_no_search_results.html.erb +3 -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/_add_button.html.erb +17 -19
- data/app/views/collavre/creatives/_empty_state.html.erb +109 -0
- data/app/views/collavre/creatives/_import_upload_zone.html.erb +1 -1
- data/app/views/collavre/creatives/_inline_edit_form.html.erb +18 -6
- 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/_tree_loading_placeholder.html.erb +16 -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 +36 -0
- data/app/views/collavre/creatives/edit.html.erb +7 -4
- data/app/views/collavre/creatives/index.html.erb +149 -25
- 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/desktop_setup/show.html.erb +114 -0
- data/app/views/collavre/features/index.html.erb +42 -0
- data/app/views/collavre/features/show.html.erb +52 -0
- data/app/views/collavre/inline_agent_logins/show.html.erb +31 -0
- data/app/views/collavre/invitation_mailer/invite.html.erb +1 -1
- data/app/views/collavre/invitation_mailer/invite.text.erb +1 -1
- data/app/views/collavre/invites/show.html.erb +14 -1
- data/app/views/collavre/landing/show.html.erb +5 -1
- 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 +6 -1
- data/app/views/collavre/shared/navigation/_help_button.html.erb +22 -1
- data/app/views/collavre/shared/navigation/_panels.html.erb +1 -8
- data/app/views/collavre/shared/navigation/_search_form.html.erb +27 -3
- data/app/views/collavre/user_themes/index.html.erb +1 -1
- data/app/views/collavre/users/_llm_fields.html.erb +60 -0
- data/app/views/collavre/users/_model_picker.html.erb +36 -0
- data/app/views/collavre/users/_org_chart_node.html.erb +1 -1
- 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 +60 -53
- data/app/views/collavre/users/index.html.erb +96 -80
- data/app/views/collavre/users/new.html.erb +4 -2
- data/app/views/collavre/users/new_ai.html.erb +17 -53
- data/app/views/collavre/users/show.html.erb +19 -24
- data/app/views/layouts/collavre/landing.html.erb +23 -4
- 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 +78 -0
- data/config/initializers/screening_integration_settings.rb +5 -0
- data/config/initializers/task_recovery.rb +30 -0
- data/config/locales/admin.en.yml +21 -3
- data/config/locales/admin.ko.yml +21 -3
- data/config/locales/agent_gateway.en.yml +221 -0
- data/config/locales/agent_gateway.ko.yml +221 -0
- data/config/locales/ai_agent.en.yml +11 -1
- data/config/locales/ai_agent.ko.yml +11 -1
- 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 +146 -48
- data/config/locales/comments.ko.yml +146 -48
- 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 +51 -52
- data/config/locales/creatives.ko.yml +49 -45
- 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 +155 -0
- data/config/locales/features.ko.yml +155 -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/invites.en.yml +3 -0
- data/config/locales/invites.ko.yml +3 -0
- 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 +4 -7
- data/config/locales/landing.ko.yml +4 -7
- 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 +46 -0
- data/config/locales/tools.ko.yml +46 -0
- data/config/locales/users.en.yml +33 -36
- data/config/locales/users.ko.yml +32 -35
- 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 +35 -38
- data/db/migrate/20250911084338_backfill_creative_in_comment_inbox_items.rb +9 -1
- data/db/migrate/20251204161133_set_default_routing_expression_for_ai_agents.rb +10 -3
- data/db/migrate/20260724000000_add_creative_id_index_to_comments.rb +34 -0
- data/db/migrate/20260724000001_add_creative_private_id_index_to_comments.rb +50 -0
- data/db/migrate/20260724090000_add_async_comment_notification_state.rb +64 -0
- data/db/migrate/20260727000000_add_waiting_notice_scope_to_comments.rb +30 -0
- data/db/migrate/20260727010000_add_waiting_notice_scope_to_tasks.rb +26 -0
- data/db/migrate/20260805000000_add_creative_workspace_enabled_to_users.rb +5 -0
- data/db/migrate/20260807050000_add_dismissed_notices_to_users.rb +5 -0
- data/db/migrate/20260809000000_change_creative_workspace_enabled_default_to_true.rb +18 -0
- data/db/migrate/20260809000001_create_llm_models.rb +64 -0
- data/db/migrate/20260809000002_create_agent_gateways_and_workspaces.rb +35 -0
- data/db/migrate/20260809000003_hash_agent_workspace_callback_tokens.rb +44 -0
- data/db/migrate/20260809000004_encrypt_agent_workspace_manifest_tokens.rb +59 -0
- data/db/migrate/20260810000000_split_agent_workspace_identity_axes.rb +58 -0
- data/db/migrate/20260810000001_seed_codex_custom_proxy_llm_models.rb +28 -0
- data/db/migrate/20260810010000_add_last_visited_creative_to_users.rb +8 -0
- data/db/migrate/20260810020000_add_last_visited_creative_at_to_users.rb +5 -0
- data/db/migrate/20260810030000_add_last_visited_creative_navigation_order_to_users.rb +6 -0
- data/db/migrate/20260810060000_add_last_visited_creative_issued_sequence_to_users.rb +5 -0
- data/db/migrate/20260810100000_add_desktop_managed_to_agent_gateways.rb +40 -0
- data/db/migrate/20260810100001_add_desktop_preset_adapter_to_users.rb +38 -0
- data/db/migrate/20260811000000_make_agent_gateway_completion_key_nullable.rb +7 -0
- data/db/migrate/20260812000000_remove_workflow_columns_from_tasks.rb +101 -0
- data/db/migrate/20260812000001_remove_android_devices.rb +24 -0
- data/db/migrate/20260812010000_drop_inbox_items.rb +22 -0
- data/db/migrate/20260813000000_clear_claude_channel_presence_routing_expressions.rb +16 -0
- data/db/migrate/20260813000001_add_last_topic_revision_to_user_creative_preferences.rb +5 -0
- data/db/migrate/20260813000002_add_last_topic_save_order_to_user_creative_preferences.rb +6 -0
- data/db/migrate/20260813000003_add_last_topic_save_sequences_to_user_creative_preferences.rb +5 -0
- data/db/migrate/20260813000004_add_last_topic_save_fences_to_user_creative_preferences.rb +6 -0
- data/db/migrate/20260814000000_add_topic_to_comment_read_pointers.rb +79 -0
- data/db/migrate/20260814000001_add_creative_topic_private_id_index_to_comments.rb +37 -0
- data/db/migrate/20260816000000_add_watermark_index_to_comment_read_pointers.rb +27 -0
- data/db/migrate/20260816000001_add_private_recipient_topic_index_to_comments.rb +48 -0
- data/db/migrate/20260820000000_add_topic_assigned_at_to_comments.rb +13 -0
- 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 +4 -70
- data/lib/collavre/bulk_job_enqueue.rb +145 -0
- data/lib/collavre/engine.rb +119 -7
- data/lib/collavre/feature_card_registry.rb +174 -0
- data/lib/collavre/hashed_access_token_lookup.rb +22 -0
- 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/sensitive_request_silencer.rb +23 -0
- data/lib/collavre/stylesheets_helper.rb +72 -0
- data/lib/collavre/user_extensions.rb +0 -2
- data/lib/collavre/version.rb +1 -1
- data/lib/collavre.rb +13 -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 +207 -0
- data/skills/collavre/package.json +8 -0
- data/skills/collavre/references/tool-authoring.md +121 -0
- data/skills/collavre/references/tool-reference.md +445 -0
- data/skills/collavre/scripts/collavre +653 -0
- data/skills/collavre/scripts/html_entities.js +24 -0
- metadata +995 -36
- data/app/controllers/collavre/api/v1/mobile/agent_events_controller.rb +0 -224
- data/app/controllers/collavre/api/v1/mobile/base_controller.rb +0 -95
- data/app/controllers/collavre/api/v1/mobile/devices_controller.rb +0 -31
- data/app/controllers/collavre/api/v1/mobile/voice_commands_controller.rb +0 -25
- data/app/controllers/collavre/inbox_items_controller.rb +0 -70
- data/app/controllers/collavre/typo_corrections_controller.rb +0 -39
- data/app/javascript/lib/__tests__/typo_correction.test.js +0 -192
- data/app/javascript/lib/typo_correction.js +0 -146
- data/app/javascript/modules/__tests__/typo_corrector.test.js +0 -365
- data/app/javascript/modules/creative_guide.js +0 -67
- data/app/javascript/modules/typo_corrector.js +0 -534
- data/app/jobs/collavre/inbox_summary_job.rb +0 -24
- data/app/mailers/collavre/inbox_mailer.rb +0 -19
- data/app/models/collavre/inbox_item.rb +0 -89
- data/app/services/collavre/comments/concerns/workflow_support.rb +0 -115
- data/app/services/collavre/comments/work_command.rb +0 -161
- data/app/services/collavre/comments/workflow_executor.rb +0 -276
- data/app/services/collavre/gemini_parent_recommender.rb +0 -77
- data/app/services/collavre/mobile/event_summarizer.rb +0 -40
- data/app/services/collavre/typo_corrector.rb +0 -188
- data/app/views/collavre/inbox_items/_item.html.erb +0 -18
- data/app/views/collavre/inbox_items/_items.html.erb +0 -3
- data/app/views/collavre/inbox_items/_list.html.erb +0 -7
- data/app/views/collavre/inbox_items/index.html.erb +0 -1
- data/app/views/collavre/inbox_mailer/daily_summary.html.erb +0 -11
- data/app/views/collavre/inbox_mailer/daily_summary.text.erb +0 -8
- data/app/views/collavre/users/typo_correction.html.erb +0 -50
- data/config/locales/mobile.en.yml +0 -16
- data/config/locales/mobile.ko.yml +0 -16
- 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
|
@@ -12,62 +12,260 @@ module Collavre
|
|
|
12
12
|
# AgentOrchestrator.dispatch("comment_created", context)
|
|
13
13
|
#
|
|
14
14
|
class AgentOrchestrator
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
include WorkflowDispatch
|
|
16
|
+
include JobEnqueue
|
|
17
|
+
def self.dispatch(event_name, context, records: nil, **options)
|
|
18
|
+
new(event_name: event_name, context: context, records: records).dispatch(**options)
|
|
17
19
|
end
|
|
18
20
|
|
|
21
|
+
def self.dispatch_with_outcome(event_name, context, records: nil, **options)
|
|
22
|
+
new(event_name: event_name, context: context, records: records).dispatch_with_outcome(**options)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def self.select(event_name, context) = new(event_name: event_name, context: context).select
|
|
26
|
+
|
|
27
|
+
def self.prepare_selection(event_name, context, **options) = new(event_name: event_name, context: context).prepare_selection(**options)
|
|
28
|
+
|
|
19
29
|
def self.dequeue_next_for_topic(topic_id, creative_id = nil)
|
|
20
|
-
task =
|
|
21
|
-
|
|
30
|
+
task = claim_next_waiter(topic_id, creative_id)
|
|
31
|
+
promote_claimed!(task, topic_id, creative_id) if task
|
|
32
|
+
rescue StandardError
|
|
33
|
+
# Whatever failed after the claim — the refresh, the enqueue — left the
|
|
34
|
+
# row pending with no job behind it, holding the slot where no recovery
|
|
35
|
+
# looks. Back in the queue, orphan recovery promotes it again.
|
|
36
|
+
Task.where(id: task.id, status: "pending").update_all(status: "queued", updated_at: Time.current) if task
|
|
37
|
+
raise
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def self.promote_claimed!(task, topic_id, creative_id)
|
|
41
|
+
# Fold the waiters left behind this one into it. dequeue promotes the
|
|
42
|
+
# oldest *eligible* queued task, so its same-agent siblings are all
|
|
43
|
+
# newer — they would each be promoted in turn and, because
|
|
44
|
+
# refresh_deferred_context! points every one of them at the same
|
|
45
|
+
# latest comment, replay the same answer. Absorb them here instead;
|
|
46
|
+
# the refresh below then moves the anchor forward and keeps the
|
|
47
|
+
# absorbed triggers in "merged_comment_ids".
|
|
48
|
+
coalesce_promoted!(task)
|
|
22
49
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
50
|
+
# `task` is the snapshot claim_next_waiter took, and the row can be
|
|
51
|
+
# cancelled from outside between that claim and here: deleting the
|
|
52
|
+
# comment it answers cancels a `pending` task through
|
|
53
|
+
# Comment#cancel_pending_tasks, which holds no lock this path waits
|
|
54
|
+
# on. TaskCoalescer re-reads the survivor under its own lock and
|
|
55
|
+
# declines to fold onto a cancelled row — but declining leaves this
|
|
56
|
+
# object still saying `pending`, and everything below reads it: the
|
|
57
|
+
# refresh would write a payload onto a dead row and the check at the
|
|
58
|
+
# bottom would enqueue it, where AiAgentJob reloads and returns
|
|
59
|
+
# without draining. Re-read once, here, rather than at each of them.
|
|
60
|
+
unless task.reload.status == "cancelled"
|
|
61
|
+
WaitingNoticeManager.cleanup_waiting_notices_if_drained!(task)
|
|
27
62
|
refresh_deferred_context!(task)
|
|
63
|
+
revalidate_waiting_task!(task) unless task.status == "cancelled"
|
|
64
|
+
end
|
|
28
65
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
66
|
+
if task.status == "cancelled"
|
|
67
|
+
# The anchor was deleted under it, refresh_deferred_context! found
|
|
68
|
+
# no eligible comment, or revalidate_waiting_task! rejected the assigned
|
|
69
|
+
# agent. Try the next queued task.
|
|
70
|
+
dequeue_next_for_topic(topic_id, creative_id)
|
|
71
|
+
else
|
|
72
|
+
job = AiAgentJob.perform_later(task)
|
|
73
|
+
# A rejected enqueue would leave the row pending with no job behind
|
|
74
|
+
# it, holding the slot where no recovery looks. Back in the queue,
|
|
75
|
+
# orphan recovery promotes it again.
|
|
76
|
+
if job.respond_to?(:successfully_enqueued?) && !job.successfully_enqueued?
|
|
77
|
+
Task.where(id: task.id, status: "pending").update_all(status: "queued", updated_at: Time.current)
|
|
35
78
|
end
|
|
36
79
|
end
|
|
37
80
|
end
|
|
81
|
+
private_class_method :promote_claimed!
|
|
38
82
|
|
|
39
|
-
#
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
83
|
+
# Promote the oldest waiter this topic can actually run, moving it
|
|
84
|
+
# queued -> pending (a status that occupies the slot) so the claim is
|
|
85
|
+
# visible to every other admission the moment it commits.
|
|
86
|
+
#
|
|
87
|
+
# Promotion is a slot hand-out just like AiAgentJob's admission, so it
|
|
88
|
+
# takes the same lock and asks the same question. Without that, a caller
|
|
89
|
+
# that merely observed *a* task finish would promote into a topic that is
|
|
90
|
+
# still full (every terminal task in the topic calls here, including ones
|
|
91
|
+
# that never held this slot), or hand a second concurrent turn to an agent
|
|
92
|
+
# that is already running one — which TaskCoalescer, folding only `queued`
|
|
93
|
+
# rows, could never merge after the fact.
|
|
94
|
+
#
|
|
95
|
+
# The oldest waiter is not always eligible: with topic_max > 1 the head of
|
|
96
|
+
# the queue may belong to a busy agent while a later waiter can run now.
|
|
97
|
+
# Stopping at the queue head would strand the whole queue behind it, so
|
|
98
|
+
# scan in order for the first waiter that fits.
|
|
99
|
+
def self.claim_next_waiter(topic_id, creative_id)
|
|
100
|
+
claimed = nil
|
|
101
|
+
|
|
102
|
+
Task.transaction do
|
|
103
|
+
TopicSlot.lock!(topic_id, creative_id)
|
|
104
|
+
|
|
105
|
+
candidate = Task.queued_for_topic(topic_id, creative_id).find do |waiter|
|
|
106
|
+
TopicSlot.available_for?(
|
|
107
|
+
waiter.agent_id, topic_id, creative_id, waiter.trigger_event_payload
|
|
108
|
+
)
|
|
109
|
+
end
|
|
110
|
+
next if candidate.nil?
|
|
111
|
+
|
|
112
|
+
updated = Task.where(id: candidate.id, status: "queued").update_all(status: "pending", updated_at: Time.current)
|
|
113
|
+
claimed = candidate.reload if updated > 0
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
claimed
|
|
117
|
+
end
|
|
118
|
+
private_class_method :claim_next_waiter
|
|
119
|
+
|
|
120
|
+
def self.coalesce_promoted!(task)
|
|
121
|
+
return unless PolicyResolver.new(task.trigger_event_payload || {})
|
|
122
|
+
.coalesce_pending_tasks_for?(task.agent)
|
|
123
|
+
|
|
124
|
+
TaskCoalescer.coalesce!(task, scope: :all)
|
|
125
|
+
end
|
|
126
|
+
private_class_method :coalesce_promoted!
|
|
127
|
+
|
|
128
|
+
# Fold one last time, at the moment execution actually begins.
|
|
129
|
+
#
|
|
130
|
+
# Promotion claims the slot (queued -> pending) and folds the waiters that
|
|
131
|
+
# exist at that instant, but the task then sits `pending` until its
|
|
132
|
+
# AiAgentJob runs. A comment arriving in that gap parks a waiter that
|
|
133
|
+
# enqueue-time coalescing cannot reach: TaskCoalescer supersedes only
|
|
134
|
+
# `queued` rows, and the claimed task has already left that status. Both
|
|
135
|
+
# turns were still un-started — which is the invariant coalescing is
|
|
136
|
+
# defined over, not "present when the slot was claimed" — so the last
|
|
137
|
+
# un-started moment has to fold too.
|
|
138
|
+
#
|
|
139
|
+
# Serialized on the row admission locks. A concurrent dispatch either
|
|
140
|
+
# commits its waiter before this reads the siblings, and is folded, or
|
|
141
|
+
# after, and keeps its own turn against a task that is by then executing.
|
|
142
|
+
# The re-anchor runs inside the same lock for the same reason: outside it,
|
|
143
|
+
# the refresh could move the anchor onto a comment whose waiter is still
|
|
144
|
+
# queued, and that comment would be answered twice.
|
|
145
|
+
#
|
|
146
|
+
# Only a `pending` task qualifies. That is the claimed-but-not-started
|
|
147
|
+
# status; a resumed pending_approval task has already delivered its
|
|
148
|
+
# trigger and run part of its turn, so folding new comments into it would
|
|
149
|
+
# swallow them rather than answer them.
|
|
150
|
+
def self.coalesce_at_start!(task)
|
|
151
|
+
return Workflow::FixedAnchor.validate!(task) if task.workflow?
|
|
152
|
+
return unless task.status == "pending"
|
|
153
|
+
|
|
154
|
+
context = task.trigger_event_payload || {}
|
|
155
|
+
return unless context.key?("topic")
|
|
156
|
+
return unless PolicyResolver.new(context).coalesce_pending_tasks_for?(task.agent)
|
|
157
|
+
|
|
158
|
+
absorbed = []
|
|
159
|
+
Task.transaction do
|
|
160
|
+
TopicSlot.lock!(task.topic_id, task.creative_id)
|
|
161
|
+
absorbed = TaskCoalescer.coalesce!(task, scope: :all)
|
|
162
|
+
refresh_deferred_context!(task, absorbed_only: true) if absorbed.any?
|
|
53
163
|
end
|
|
164
|
+
return if absorbed.empty?
|
|
165
|
+
|
|
166
|
+
# The folded waiters may have been everything the topic's "⏳" notice
|
|
167
|
+
# described, and nothing else will take it down: removal happens when a
|
|
168
|
+
# promotion drains a *queued* waiter, and this fold left none.
|
|
169
|
+
WaitingNoticeManager.cleanup_waiting_notices_if_drained!(task)
|
|
54
170
|
end
|
|
55
|
-
private_class_method :cleanup_waiting_notices!
|
|
56
171
|
|
|
57
172
|
# Refresh trigger_event_payload so the deferred agent sees the latest
|
|
58
173
|
# conversation state instead of the stale snapshot from enqueue time.
|
|
59
174
|
# Skips AI agent's own comments to prevent self-response loops.
|
|
60
175
|
# Cancels the task if no eligible comment remains.
|
|
61
|
-
|
|
176
|
+
#
|
|
177
|
+
# `absorbed_only` narrows the destination to the comments this turn is
|
|
178
|
+
# actually answering — its anchor plus what coalescing folded into it.
|
|
179
|
+
# A comment commits in its own transaction and its AiAgentJob creates the
|
|
180
|
+
# queued task afterwards, so a comment can be visible here with no task
|
|
181
|
+
# behind it yet: the topic lock orders task creation, not comment
|
|
182
|
+
# visibility. Moving the anchor onto one of those has this turn answer a
|
|
183
|
+
# comment it never absorbed, and when that job does run it parks a waiter
|
|
184
|
+
# against the now-claimed task — the same comment answered twice.
|
|
185
|
+
#
|
|
186
|
+
# Only coalesce_at_start! passes it. Promotion's refresh has always taken
|
|
187
|
+
# the newest comment in the topic ("the latest state, not the enqueue-time
|
|
188
|
+
# snapshot" is the whole reason it exists) and that is a wider question
|
|
189
|
+
# than this call site.
|
|
190
|
+
def self.refresh_deferred_context!(task, absorbed_only: false)
|
|
62
191
|
context = task.trigger_event_payload
|
|
63
192
|
creative_id = context&.dig("creative", "id")
|
|
64
193
|
return unless creative_id && context&.key?("topic")
|
|
65
194
|
|
|
195
|
+
# Keeping a review out of TaskCoalescer is only half the boundary: the
|
|
196
|
+
# refresh is the other door onto the anchor, and moving it forward turns
|
|
197
|
+
# the in-place revision into a plain reply just as surely. A review
|
|
198
|
+
# answers the comment it quotes or nothing at all, so leave it alone.
|
|
199
|
+
#
|
|
200
|
+
# "Not moved" is not "not checked", though. An ordinary anchor is
|
|
201
|
+
# revalidated by having to be re-selected through the eligibility scope
|
|
202
|
+
# below; a review that skips straight past it keeps whatever
|
|
203
|
+
# trigger_event_payload cached, and the anchor is the one part of the
|
|
204
|
+
# payload MessageBuilder renders without a filter. ReviewHandler#eligible?
|
|
205
|
+
# only asks whether the *quoted* comment is private, so a review request
|
|
206
|
+
# the user withdrew — or that was moved out of this turn's scope — while
|
|
207
|
+
# it waited would still be delivered, and still drive an in-place
|
|
208
|
+
# revision of the agent's comment.
|
|
209
|
+
if fixed_reply_anchor?(task, context)
|
|
210
|
+
task.update!(status: "cancelled") unless anchor_still_in_turn?(context)
|
|
211
|
+
return
|
|
212
|
+
end
|
|
213
|
+
|
|
66
214
|
topic_id = context.dig("topic", "id")
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
215
|
+
previous_anchor_id = context.dig("comment", "id")
|
|
216
|
+
delivered_ids = delivered_comment_ids(task, context)
|
|
217
|
+
|
|
218
|
+
# ...and a review is no better as a *destination* than as an anchor. The
|
|
219
|
+
# coalescer leaves a queued review alone, so an ordinary waiter promoted
|
|
220
|
+
# first would re-anchor onto it and run ReviewHandler over a comment it
|
|
221
|
+
# was never asked to revise — then the real review task repeats the
|
|
222
|
+
# revision later. Skip reviews and take the newest ordinary comment,
|
|
223
|
+
# which in the worst case is the waiter's own anchor (a no-op refresh)
|
|
224
|
+
# rather than nothing, so this cannot strand a live waiter.
|
|
225
|
+
scope = DeferredTriggerScope.for(task, context)
|
|
226
|
+
|
|
227
|
+
# Narrowing the destination closes the door this call site opens, but the
|
|
228
|
+
# promotion door still moves the anchor onto the newest comment in the
|
|
229
|
+
# topic — deliberately, since that is the reason the refresh exists. So
|
|
230
|
+
# ask the question from the delivery side as well: a comment already
|
|
231
|
+
# handed to this agent is not handed to it again, whichever door moved
|
|
232
|
+
# the anchor onto it. Asking here rather than at dispatch is what keeps
|
|
233
|
+
# it loss-free — by promotion time the covering turn's status says
|
|
234
|
+
# whether it actually delivered anything.
|
|
235
|
+
scope = scope.where.not(id: delivered_ids) if delivered_ids.any?
|
|
236
|
+
|
|
237
|
+
# When the filter above removed the waiter's *own* anchor, falling back
|
|
238
|
+
# to an older comment is not a rescue.
|
|
239
|
+
#
|
|
240
|
+
# The refresh's worst case used to be a no-op: the waiter's own anchor
|
|
241
|
+
# was always among the candidates, so "the newest eligible comment" was
|
|
242
|
+
# never older than the comment the waiter was dispatched for. Delivery
|
|
243
|
+
# filtering can now take that anchor away, and what is next is older —
|
|
244
|
+
# a comment this waiter was not dispatched for, that predates the one it
|
|
245
|
+
# was, and that the covering turn had in view when it answered the
|
|
246
|
+
# anchor. Answering it is a second reply to settled conversation.
|
|
247
|
+
#
|
|
248
|
+
# Scoped to exactly that cause rather than a blanket "never move
|
|
249
|
+
# backwards": an anchor that has left the turn for some other reason
|
|
250
|
+
# (moved to another creative, made private) is a different question with
|
|
251
|
+
# its own answer, and widening the floor to cover it would change what
|
|
252
|
+
# promotion does to waiters this feature never touched.
|
|
253
|
+
#
|
|
254
|
+
# With nothing at or above the anchor left, `latest_comment` is nil and
|
|
255
|
+
# the branch below cancels the waiter — which is the right outcome:
|
|
256
|
+
# everything it could have said has been said.
|
|
257
|
+
if previous_anchor_id && delivered_ids.include?(previous_anchor_id.to_i)
|
|
258
|
+
scope = scope.where("id >= ?", previous_anchor_id)
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
if absorbed_only
|
|
262
|
+
candidate_ids = (Array(context[TaskCoalescer::PAYLOAD_KEY]) + [ previous_anchor_id ])
|
|
263
|
+
.compact.map(&:to_i).uniq
|
|
264
|
+
return if candidate_ids.empty?
|
|
265
|
+
|
|
266
|
+
scope = scope.where(id: candidate_ids)
|
|
267
|
+
end
|
|
268
|
+
|
|
71
269
|
latest_comment = scope.first
|
|
72
270
|
|
|
73
271
|
unless latest_comment
|
|
@@ -75,99 +273,276 @@ module Collavre
|
|
|
75
273
|
return
|
|
76
274
|
end
|
|
77
275
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
276
|
+
# Moving the anchor forward must not drop what the task was originally
|
|
277
|
+
# going to answer. A session-backed agent only receives the :trigger
|
|
278
|
+
# message (SessionContextResolver#incremental_payload), so a silently
|
|
279
|
+
# replaced anchor is a comment the agent never sees at all.
|
|
280
|
+
#
|
|
281
|
+
# reanchor_payload also records the move when it is one, which is what
|
|
282
|
+
# delivered_comment_ids reads below: a comment this turn was handed
|
|
283
|
+
# without having been created for it.
|
|
284
|
+
context = DeferredTriggerScope.reanchor_payload(task, context, latest_comment)
|
|
285
|
+
# absorb_into_payload also drops the new anchor from the merged list, so
|
|
286
|
+
# a comment promoted from "merged" back to "trigger" is not sent twice.
|
|
287
|
+
context = TaskCoalescer.absorb_into_payload(context, [ previous_anchor_id ].compact)
|
|
288
|
+
# The merged list is rendered into the trigger exactly like the anchor, so
|
|
289
|
+
# keeping the anchor off a delivered comment is only half of it: the
|
|
290
|
+
# comment the refresh just displaced can itself be one an earlier turn
|
|
291
|
+
# already answered.
|
|
292
|
+
if delivered_ids.any?
|
|
293
|
+
context[TaskCoalescer::PAYLOAD_KEY] = Array(context[TaskCoalescer::PAYLOAD_KEY]) - delivered_ids
|
|
294
|
+
end
|
|
84
295
|
task.update!(trigger_event_payload: context)
|
|
85
296
|
end
|
|
86
297
|
private_class_method :refresh_deferred_context!
|
|
87
298
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
299
|
+
# Statuses that mean this agent was actually handed the task's trigger.
|
|
300
|
+
#
|
|
301
|
+
# `queued` and `pending` are excluded because nothing has been delivered
|
|
302
|
+
# yet — those are the un-started rows TaskCoalescer folds, and treating a
|
|
303
|
+
# merely claimed task as an answer is what would make this lossy.
|
|
304
|
+
# `failed`, `cancelled` and `escalated` are excluded deliberately: a turn
|
|
305
|
+
# that died may never have delivered anything, so the comments it held
|
|
306
|
+
# stay answerable. That direction trades a possible duplicate after a
|
|
307
|
+
# failure for never silencing a comment no task is left to answer.
|
|
308
|
+
#
|
|
309
|
+
# The in-flight three would be unsound here if they were reachable: a
|
|
310
|
+
# `running` turn's record says it assembled, not that it handed anything
|
|
311
|
+
# over, and this reader *cancels a waiter* — the one removal this feature
|
|
312
|
+
# makes that writes nothing down, so a later failure has no row to undo it
|
|
313
|
+
# with. They are inert instead, and TopicSlot is why: an agent that
|
|
314
|
+
# occupies a slot in this scope may not be promoted into a second turn, so
|
|
315
|
+
# at the moment the refresh runs this agent has no running, delegated,
|
|
316
|
+
# pending or pending_approval task here — and `others` is scoped to this
|
|
317
|
+
# agent, so a concurrent turn (necessarily another agent's, for the same
|
|
318
|
+
# reason) is not read at all. The only covering turn this ever decides
|
|
319
|
+
# against is one that has already ended, which is what makes the decision
|
|
320
|
+
# sound. DeliveredHistoryDispatchTest holds both halves; relax TopicSlot's
|
|
321
|
+
# per-agent exclusion and they fail rather than this quietly losing a
|
|
322
|
+
# comment.
|
|
323
|
+
DELIVERED_STATUSES = %w[running delegated pending_approval done].freeze
|
|
324
|
+
|
|
325
|
+
# Comment ids this agent has already been given in this topic by a turn that
|
|
326
|
+
# was not created to answer them. MessageBuilder renders merged blocks into
|
|
327
|
+
# the trigger exactly like the anchor, so both count as delivery.
|
|
328
|
+
#
|
|
329
|
+
# The distinction matters more than the delivery: the ordinary history of a
|
|
330
|
+
# topic is one comment answered by its own turn, and *that* must silence
|
|
331
|
+
# nothing, or every waiter standing behind an answered comment would be
|
|
332
|
+
# cancelled. Two shapes say "this turn was not created for that comment",
|
|
333
|
+
# and neither needs anything new recorded:
|
|
334
|
+
#
|
|
335
|
+
# - it sits in the turn's merged list — coalescing put it there, and the
|
|
336
|
+
# task it belonged to was superseded, so this turn is its only delivery;
|
|
337
|
+
# - it is the anchor, and the payload records that the anchor was moved
|
|
338
|
+
# onto it — the refresh acquired it, which is the window this closes.
|
|
339
|
+
#
|
|
340
|
+
# An anchor a task was created for is that task's original trigger and is
|
|
341
|
+
# deliberately not counted. Which of the two it is comes from the payload
|
|
342
|
+
# (TaskCoalescer::ACQUIRED_ANCHOR_KEY, written by whichever door moved it)
|
|
343
|
+
# rather than from comparing the comment's clock with the task's.
|
|
344
|
+
#
|
|
345
|
+
# Scoped by topic and creative so a delivery is only ever matched against
|
|
346
|
+
# comments in the same conversation. Same trigger_event_name for the same
|
|
347
|
+
# reason TaskCoalescer folds only within one — a different event over the
|
|
348
|
+
# same comment is a different question.
|
|
349
|
+
def self.delivered_comment_ids(task, context)
|
|
350
|
+
others = Task.where(
|
|
351
|
+
agent_id: task.agent_id,
|
|
352
|
+
topic_id: context.dig("topic", "id"),
|
|
353
|
+
creative_id: context.dig("creative", "id"),
|
|
354
|
+
trigger_event_name: task.trigger_event_name,
|
|
355
|
+
status: DELIVERED_STATUSES
|
|
356
|
+
).where.not(id: task.id).select(:id, :trigger_event_payload).to_a
|
|
357
|
+
|
|
358
|
+
# A resumed turn can carry both records legitimately: an earlier
|
|
359
|
+
# attempt handed off, then a later attempt failed before handoff. The
|
|
360
|
+
# failure invalidates inferred turn-wide delivery, but not the comment
|
|
361
|
+
# ids the earlier successful attempt recorded explicitly.
|
|
362
|
+
handed_off = others.flat_map { |other|
|
|
363
|
+
DeliveryRecord.handed_off_ids_in(other.trigger_event_payload)
|
|
364
|
+
}
|
|
365
|
+
delivered_turns = others.reject { |other|
|
|
366
|
+
# `done` is in DELIVERED_STATUSES because a finished turn delivered
|
|
367
|
+
# what it read — except when the request never reached the provider,
|
|
368
|
+
# which AiClient#chat swallows and AiAgentJob still finishes as
|
|
369
|
+
# `done`. Such a turn silences nothing, for the same reason `failed`
|
|
370
|
+
# is left out of the list; it just cannot be recognised by status.
|
|
371
|
+
DeliveryRecord.handoff_failed?(other.trigger_event_payload)
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
acquired_anchors = delivered_turns.filter_map { |other| acquired_anchor_id_in(other) }
|
|
375
|
+
merged = delivered_turns.flat_map { |other|
|
|
376
|
+
Array(other.trigger_event_payload&.dig(TaskCoalescer::PAYLOAD_KEY)).compact.map(&:to_i)
|
|
377
|
+
}
|
|
378
|
+
# The third shape, and the one the dispatch doors cannot catch: a
|
|
379
|
+
# non-session turn re-reads the topic when it assembles its payload, so
|
|
380
|
+
# a comment that landed after that turn was dispatched can be swept into
|
|
381
|
+
# its history window without ever being merged or re-anchored. A waiter
|
|
382
|
+
# parked before the covering turn assembled is only discoverable here.
|
|
383
|
+
swallowed = delivered_turns.flat_map { |other|
|
|
384
|
+
DeliveryRecord.ids_in(other.trigger_event_payload)
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
(acquired_anchors + merged + swallowed + handed_off).uniq
|
|
93
388
|
end
|
|
389
|
+
private_class_method :delivered_comment_ids
|
|
94
390
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
391
|
+
# The anchor of `other`, but only when `other` acquired it rather than
|
|
392
|
+
# being created for it. The recorded id is compared against the anchor as
|
|
393
|
+
# it stands now: a payload moved on again since carries the older id in
|
|
394
|
+
# its merged list, which is counted separately.
|
|
395
|
+
def self.acquired_anchor_id_in(other)
|
|
396
|
+
payload = other.trigger_event_payload
|
|
397
|
+
acquired = payload&.dig(TaskCoalescer::ACQUIRED_ANCHOR_KEY)
|
|
398
|
+
anchor = payload&.dig("comment", "id")
|
|
399
|
+
return nil if acquired.nil? || anchor.nil?
|
|
99
400
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
401
|
+
anchor.to_i if acquired.to_i == anchor.to_i
|
|
402
|
+
end
|
|
403
|
+
private_class_method :acquired_anchor_id_in
|
|
103
404
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
405
|
+
# May this turn still deliver the comment it is anchored on?
|
|
406
|
+
#
|
|
407
|
+
# Asked through MergedTriggerComments.in_turn — the same predicate the
|
|
408
|
+
# renderer uses for the merged list and Matcher.permits_assignment? for the
|
|
409
|
+
# mention — so an anchor cannot be delivered under rules the rest of the
|
|
410
|
+
# payload is filtered by: public_only, no approval surface, and still in
|
|
411
|
+
# this turn's creative/topic.
|
|
412
|
+
def self.fixed_reply_anchor?(task, context)
|
|
413
|
+
KeepLoop.dispatch?(context) ||
|
|
414
|
+
task.trigger_event_name.in?(%w[claude_channel_approval async_approval]) || review_anchor?(context)
|
|
415
|
+
end
|
|
416
|
+
private_class_method :fixed_reply_anchor?
|
|
107
417
|
|
|
108
|
-
|
|
109
|
-
|
|
418
|
+
def self.anchor_still_in_turn?(context)
|
|
419
|
+
anchor_id = context.dig("comment", "id")
|
|
420
|
+
return false if anchor_id.blank?
|
|
421
|
+
|
|
422
|
+
AiAgent::MergedTriggerComments.in_turn([ anchor_id ], context).exists?
|
|
110
423
|
end
|
|
424
|
+
private_class_method :anchor_still_in_turn?
|
|
111
425
|
|
|
112
|
-
|
|
426
|
+
def self.review_anchor?(context)
|
|
427
|
+
anchor_id = context.dig("comment", "id")
|
|
428
|
+
anchor_id.present? && Comment.own_turn_message_ids([ anchor_id ]).any?
|
|
429
|
+
end
|
|
430
|
+
private_class_method :review_anchor?
|
|
431
|
+
|
|
432
|
+
# Cancel a promoted waiter whose agent the topic's primary-agent assignment
|
|
433
|
+
# now excludes. A queued task keeps the agent chosen when it was dispatched,
|
|
434
|
+
# so a pin created or moved while it waited would otherwise be bypassed by
|
|
435
|
+
# the very work it is supposed to silence.
|
|
436
|
+
#
|
|
437
|
+
# Runs AFTER refresh_deferred_context! so the check judges what the agent is
|
|
438
|
+
# about to answer, not the stale snapshot: if the latest comment @mentions
|
|
439
|
+
# this agent, the mention outranks the assignment and the task survives.
|
|
440
|
+
# That refresh replaces the whole "chat" hash, dropping the resolved
|
|
441
|
+
# mentioned_user, so rebuild the context to recompute it from the content.
|
|
442
|
+
def self.revalidate_waiting_task!(task)
|
|
443
|
+
context = task.trigger_event_payload
|
|
444
|
+
return unless context&.key?("topic")
|
|
113
445
|
|
|
114
|
-
|
|
115
|
-
|
|
446
|
+
agent = task.agent
|
|
447
|
+
return unless agent
|
|
448
|
+
# AiAgentJob handles Claude Channel suspension for the specific session.
|
|
449
|
+
# Quota-blocked turns reach the execution guard, which suspends them for retry.
|
|
450
|
+
if !agent.claude_channel_agent? && !Quota::Recovery.window_blocked?(agent) && !agent.agent_online?
|
|
451
|
+
Rails.logger.info("[AgentOrchestrator] Cancelling queued task #{task.id}: agent #{agent.id} is offline")
|
|
452
|
+
return unless Workflow::FixedAnchor.validate!(task)
|
|
453
|
+
|
|
454
|
+
task.cancel_if_active!(statuses: %w[pending])
|
|
455
|
+
return
|
|
456
|
+
end
|
|
457
|
+
|
|
458
|
+
return if Matcher.prepare_waiting_task!(task)
|
|
459
|
+
|
|
460
|
+
Rails.logger.info(
|
|
461
|
+
"[AgentOrchestrator] Cancelling queued task #{task.id}: topic #{task.topic_id} " \
|
|
462
|
+
"no longer permits the recorded agent (agent=#{agent.id})"
|
|
463
|
+
)
|
|
464
|
+
return unless Workflow::FixedAnchor.validate!(task)
|
|
465
|
+
task.update!(status: "cancelled")
|
|
116
466
|
end
|
|
467
|
+
private_class_method :revalidate_waiting_task!
|
|
117
468
|
|
|
118
|
-
|
|
119
|
-
|
|
469
|
+
# `records` carries what the caller has already read (see
|
|
470
|
+
# DispatchRecords.for_comment); without it this dispatch still reads
|
|
471
|
+
# each record once, shared by every component that decides it.
|
|
472
|
+
def initialize(event_name:, context:, records: nil)
|
|
473
|
+
@event_name = event_name
|
|
474
|
+
@records = records || DispatchRecords.new
|
|
475
|
+
# Build context ONCE here - no more duplicate builds
|
|
476
|
+
@context = SystemEvents::ContextBuilder.new(context).build(records: @records)
|
|
477
|
+
@context["event_name"] = event_name
|
|
120
478
|
end
|
|
121
479
|
|
|
122
|
-
def
|
|
123
|
-
|
|
480
|
+
def select
|
|
481
|
+
prepare_selection.commit!.agents
|
|
124
482
|
end
|
|
125
483
|
|
|
126
|
-
def
|
|
127
|
-
|
|
484
|
+
def prepare_selection(**options) = Selection.new(@context, policy_resolver: policy_resolver, records: @records, **options).call
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+
private
|
|
488
|
+
|
|
489
|
+
def policy_resolver = @policy_resolver ||= PolicyResolver.new(@context, records: @records)
|
|
490
|
+
|
|
491
|
+
def scheduler = @scheduler ||= Scheduler.new(@context, policy_resolver: policy_resolver)
|
|
492
|
+
|
|
493
|
+
def context_for_agent(agent, context_for)
|
|
494
|
+
override = context_for&.call(agent)
|
|
495
|
+
override.present? ? @context.deep_merge(override.deep_stringify_keys) : @context
|
|
128
496
|
end
|
|
129
497
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
498
|
+
# Park this dispatch as a queued waiter and fold the earlier ones into it.
|
|
499
|
+
#
|
|
500
|
+
# A burst of comments queues one waiter each, and every one of them would
|
|
501
|
+
# answer the same latest comment on promotion. Fold them — merged, not
|
|
502
|
+
# dropped, so a session-backed agent still receives their content.
|
|
503
|
+
#
|
|
504
|
+
# Creating the row and folding its predecessors is ONE step, under the
|
|
505
|
+
# lock AiAgentJob#admit_or_defer! already takes for the other enqueue
|
|
506
|
+
# door. TaskCoalescer supersedes by `id < keep.id`, which reads as
|
|
507
|
+
# "everything already parked" only while id order and commit order agree.
|
|
508
|
+
# An unserialized insert lets them diverge: the higher-id waiter can
|
|
509
|
+
# commit and fold first, seeing nothing, and the lower-id one then folds
|
|
510
|
+
# nothing either because the survivor is newer than its guard allows.
|
|
511
|
+
# Both are still folded at promotion (scope: :all) and again at execution
|
|
512
|
+
# (coalesce_at_start!), so this is not a duplicate turn — but two doors
|
|
513
|
+
# onto one queue should not disagree about when a burst becomes one
|
|
514
|
+
# waiter, and only the serialized one holds without those later passes.
|
|
515
|
+
def park_waiter(agent, context)
|
|
516
|
+
topic_id = context.dig("topic", "id")
|
|
517
|
+
creative_id = context.dig("creative", "id")
|
|
518
|
+
coalescing = policy_resolver.coalesce_pending_tasks_for?(agent)
|
|
519
|
+
waiter = nil
|
|
134
520
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
if comment_id && Task.duplicate_running_for_comment?(agent.id, comment_id)
|
|
138
|
-
Rails.logger.warn(
|
|
139
|
-
"[AgentOrchestrator] Skipping enqueue: agent #{agent.id} already has a running task " \
|
|
140
|
-
"for comment #{comment_id}"
|
|
141
|
-
)
|
|
142
|
-
next
|
|
143
|
-
end
|
|
521
|
+
Task.transaction do
|
|
522
|
+
next unless TopicSlot.matches_context?(TopicSlot.lock!(topic_id, creative_id), topic_id, creative_id)
|
|
144
523
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
)
|
|
165
|
-
post_waiting_notice(agent, decision)
|
|
166
|
-
agent
|
|
167
|
-
when :rejected
|
|
168
|
-
nil
|
|
169
|
-
end
|
|
524
|
+
next unless Workflow::TaskAdmission.permitted?(context, agent)
|
|
525
|
+
waiter = Task.create!(
|
|
526
|
+
**Workflow::TaskAdmission.attributes(context, agent),
|
|
527
|
+
name: "Response to #{@event_name}",
|
|
528
|
+
status: "queued",
|
|
529
|
+
trigger_event_name: @event_name,
|
|
530
|
+
trigger_event_payload: context,
|
|
531
|
+
agent: agent,
|
|
532
|
+
topic_id: topic_id,
|
|
533
|
+
creative_id: creative_id,
|
|
534
|
+
# Which notice speaks for this waiter, written with the row rather
|
|
535
|
+
# than inferred from the notices afterwards. post_waiting_notice
|
|
536
|
+
# decides it from the same policy answer, but posts in a later
|
|
537
|
+
# transaction: between the two, this waiter is queued with no notice
|
|
538
|
+
# naming it, and a shared notice deleted in that window would read it
|
|
539
|
+
# as one of its own and cancel work that was only ever deferred.
|
|
540
|
+
waiting_notice_scope: coalescing ? Comment::WAITING_NOTICE_TOPIC : Comment::WAITING_NOTICE_TASK
|
|
541
|
+
)
|
|
542
|
+
TaskCoalescer.coalesce!(waiter) if coalescing
|
|
170
543
|
end
|
|
544
|
+
|
|
545
|
+
waiter
|
|
171
546
|
end
|
|
172
547
|
|
|
173
548
|
def log_decision(decision)
|
|
@@ -181,46 +556,15 @@ module Collavre
|
|
|
181
556
|
)
|
|
182
557
|
end
|
|
183
558
|
|
|
184
|
-
def post_waiting_notice(agent, decision)
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
creative.comments.create!(
|
|
195
|
-
content: I18n.t("collavre.orchestration.waiting_notice", reason: reason_text),
|
|
196
|
-
topic_id: topic_id,
|
|
197
|
-
private: false,
|
|
198
|
-
skip_default_user: true,
|
|
199
|
-
# Only :deferred queues a topic waiter; mark it so its stop button can
|
|
200
|
-
# target the blocker. :delayed (busy / rate_limited) notices stay false.
|
|
201
|
-
topic_concurrency_defer: decision[:timing] == :deferred
|
|
202
|
-
)
|
|
203
|
-
end
|
|
204
|
-
|
|
205
|
-
# Human-readable reason for the "⏳" waiting notice. For topic-concurrency
|
|
206
|
-
# deferrals, name the agent(s) actually holding the topic's running slot so
|
|
207
|
-
# a waiting user can see *who* is blocking them (and reach that task's stop
|
|
208
|
-
# button) rather than an anonymous "another task is running" dead end.
|
|
209
|
-
def waiting_reason_text(reason_key, topic_id, creative_id)
|
|
210
|
-
if reason_key == :topic_concurrency && topic_id
|
|
211
|
-
names = Task.running_for_topic(topic_id, creative_id)
|
|
212
|
-
.includes(:agent).filter_map { |t| t.agent&.name }.uniq
|
|
213
|
-
if names.any?
|
|
214
|
-
return I18n.t(
|
|
215
|
-
"collavre.orchestration.waiting_reasons.topic_concurrency_with_agent",
|
|
216
|
-
agent: names.join(", ")
|
|
217
|
-
)
|
|
218
|
-
end
|
|
219
|
-
end
|
|
220
|
-
|
|
221
|
-
I18n.t(
|
|
222
|
-
"collavre.orchestration.waiting_reasons.#{reason_key}",
|
|
223
|
-
default: reason_key.to_s.humanize
|
|
559
|
+
def post_waiting_notice(agent, decision, waiter: nil)
|
|
560
|
+
WaitingNoticeManager.post(
|
|
561
|
+
@context.dig("creative", "id"), @context.dig("topic", "id"),
|
|
562
|
+
decision[:reason] || :unknown,
|
|
563
|
+
deferred: decision[:timing] == :deferred,
|
|
564
|
+
waiter: waiter,
|
|
565
|
+
# No waiter to read the scope off means :delayed, which never parks
|
|
566
|
+
# one; ask the policy the same question park_waiter asked.
|
|
567
|
+
shared_without_waiter: -> { policy_resolver.coalesce_pending_tasks_for?(agent) }
|
|
224
568
|
)
|
|
225
569
|
end
|
|
226
570
|
end
|