[broken work lowk]
This commit is contained in:
@@ -24,12 +24,12 @@ MODULE_ORDER = [
|
||||
os.path.join(SRC_DIR, "providers", "custom.py"),
|
||||
os.path.join(SRC_DIR, "providers", "builtin.py"),
|
||||
os.path.join(SRC_DIR, "providers", "dispatcher.py"),
|
||||
os.path.join(SRC_DIR, "services", "summary_db.py"),
|
||||
os.path.join(SRC_DIR, "services", "summary_injector.py"),
|
||||
os.path.join(SRC_DIR, "services", "message_fetcher.py"),
|
||||
os.path.join(SRC_DIR, "ui", "thinking_sheet.py"),
|
||||
os.path.join(SRC_DIR, "ui", "summary_dialog.py"),
|
||||
os.path.join(SRC_DIR, "ui", "settings.py"),
|
||||
os.path.join(SRC_DIR, "ui", "pre_request.py"),
|
||||
os.path.join(SRC_DIR, "ui", "progress_widget.py"),
|
||||
os.path.join(SRC_DIR, "hooks", "pinned_hook.py"),
|
||||
os.path.join(SRC_DIR, "hooks", "unread_hook.py"),
|
||||
]
|
||||
@@ -38,12 +38,12 @@ HEADER_CODE = '''"""
|
||||
AI Chat Summaries Plugin for exteraGram (v3.0.1)
|
||||
================================================
|
||||
Advanced AI chat summarizer with ChatGPT OAuth, Custom Providers,
|
||||
animated progress widget, live thinking stream viewer, and dual triggers.
|
||||
dual triggers.
|
||||
"""
|
||||
|
||||
__id__ = "ai_chat_summaries"
|
||||
__name__ = "AI Chat Summaries"
|
||||
__description__ = "Advanced AI chat summarizer with ChatGPT OAuth, Custom Providers, animated progress, thinking stream preview, and dual triggers."
|
||||
__description__ = "Advanced AI chat summarizer with ChatGPT OAuth, Custom Providers, and dual triggers."
|
||||
__author__ = "@exteraGramDev"
|
||||
__version__ = "3.0.1"
|
||||
__icon__ = "msg_bot"
|
||||
@@ -161,9 +161,9 @@ class AIChatSummariesPlugin(BasePlugin):
|
||||
self.custom_handler = CustomAIHandler(self)
|
||||
self.dispatcher = UnifiedDispatcher(self)
|
||||
self.message_fetcher = MessageFetcher(self)
|
||||
self.progress_manager = PinnedProgressManager(self)
|
||||
self.pinned_hook = PinnedHeaderHook(self)
|
||||
self.unread_hook = UnreadBadgeHook(self)
|
||||
self.summary_injector = ChatSummaryInjector(self)
|
||||
self.is_processing = False
|
||||
|
||||
def on_plugin_load(self) -> None:
|
||||
@@ -181,29 +181,18 @@ class AIChatSummariesPlugin(BasePlugin):
|
||||
on_click=self.on_menu_click,
|
||||
)
|
||||
)
|
||||
record_fact("plugin.menu_item", "registered")
|
||||
|
||||
# Second entry so diagnostics can be copied immediately after a
|
||||
# failed trigger, without leaving the chat.
|
||||
self.add_menu_item(
|
||||
MenuItemData(
|
||||
menu_type=MenuItemType.CHAT_ACTION_MENU,
|
||||
text=locali.get("SETTINGS_COPY_DIAGNOSTICS"),
|
||||
icon="msg_data",
|
||||
on_click=self.on_diagnostics_menu_click,
|
||||
)
|
||||
)
|
||||
record_fact("plugin.diagnostics_menu_item", "registered")
|
||||
except Exception as exc:
|
||||
record_error("on_plugin_load:add_menu_item", exc)
|
||||
|
||||
self.pinned_hook.install_hook()
|
||||
self.unread_hook.install_hook()
|
||||
self.summary_injector.install_hook()
|
||||
record_fact(
|
||||
"plugin.hooks_installed",
|
||||
"pinned=%d unread=%d" % (
|
||||
"pinned=%d unread=%d injector=%d" % (
|
||||
len(self.pinned_hook.unhook_refs),
|
||||
len(self.unread_hook.unhook_refs),
|
||||
len(self.summary_injector.unhook_refs),
|
||||
),
|
||||
)
|
||||
|
||||
@@ -211,8 +200,7 @@ class AIChatSummariesPlugin(BasePlugin):
|
||||
"""Called when plugin is disabled or uninstalled."""
|
||||
self.pinned_hook.uninstall_hook()
|
||||
self.unread_hook.uninstall_hook()
|
||||
self.progress_manager.hide_progress()
|
||||
self.is_processing = False
|
||||
self.summary_injector.uninstall_hook()
|
||||
uninstall_uncaught_exception_hooks()
|
||||
|
||||
# Aliases for alternate SDK lifecycle naming
|
||||
@@ -306,9 +294,6 @@ class AIChatSummariesPlugin(BasePlugin):
|
||||
self.is_processing = True
|
||||
chat_act = get_last_fragment()
|
||||
|
||||
if chat_act:
|
||||
self.progress_manager.show_progress(chat_act, dialog_id, chat_title)
|
||||
|
||||
try:
|
||||
BulletinHelper.show_info(locali.get("PROGRESS_FETCHING"))
|
||||
except Exception:
|
||||
@@ -372,27 +357,40 @@ class AIChatSummariesPlugin(BasePlugin):
|
||||
|
||||
def _render_result():
|
||||
if response.success:
|
||||
full_debug_data = (
|
||||
f"=== Assembled Chat Transcript ({len(messages)} messages) ===\\n\\n"
|
||||
f"{budgeted_transcript}\\n\\n"
|
||||
f"=== Custom Prompt ===\\n{custom_prompt or '<none>'}\\n\\n"
|
||||
f"=== System Prompt ===\\n{global_prompt or '<standard>'}\\n"
|
||||
)
|
||||
latest_id = messages[-1].id if messages else 0
|
||||
show_summary_result_dialog(
|
||||
plugin=self,
|
||||
chat_activity=chat_act,
|
||||
summary_text=response.text,
|
||||
provider_name=response.provider_name,
|
||||
model_name=response.model,
|
||||
message_count=len(messages),
|
||||
elapsed_time=elapsed,
|
||||
dialog_id=dialog_id,
|
||||
topic_id=topic_id,
|
||||
full_debug_data=full_debug_data,
|
||||
latest_msg_id=latest_id,
|
||||
auto_jump=auto_jump_latest,
|
||||
)
|
||||
|
||||
# 1. Save in local SQLite DB and inject rich client-side message directly into chat
|
||||
try:
|
||||
if latest_id:
|
||||
self.summary_injector.save_and_inject_summary(
|
||||
dialog_id=dialog_id,
|
||||
anchor_msg_id=latest_id,
|
||||
count=len(messages),
|
||||
offset=offset,
|
||||
summary_text=response.text,
|
||||
provider_name=response.provider_name,
|
||||
model_name=response.model,
|
||||
topic_id=topic_id,
|
||||
chat_activity=chat_act,
|
||||
)
|
||||
except Exception as exc:
|
||||
record_error("pipeline.inject_summary", exc)
|
||||
|
||||
# 2. Show native success bulletin notification and jump to latest analyzed message
|
||||
try:
|
||||
BulletinHelper.show_success(
|
||||
locali.get("RESULT_HEADER_INFO", provider=response.provider_name, model=response.model, count=len(messages), time=elapsed),
|
||||
chat_act,
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Scroll to the latest message in summary
|
||||
try:
|
||||
if latest_id and chat_act:
|
||||
scroll_to_message_in_chat(chat_act, latest_id, topic_id)
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
show_error_dialog(
|
||||
title=locali.get("ERROR_TITLE"),
|
||||
@@ -416,14 +414,14 @@ class AIChatSummariesPlugin(BasePlugin):
|
||||
self._finish_pipeline()
|
||||
record_error("pipeline.fetch_history", exc)
|
||||
def _finish_pipeline(self) -> None:
|
||||
"""Cleans up in-progress state and resets pinned header layout."""
|
||||
"""Cleans up in-progress state, sender cache, and pinned header layout."""
|
||||
self.is_processing = False
|
||||
def _ui_clean():
|
||||
self.progress_manager.hide_progress()
|
||||
run_on_ui_thread(_ui_clean)
|
||||
try:
|
||||
self.message_fetcher.clear_sender_cache()
|
||||
except Exception as exc:
|
||||
record_error("pipeline.clear_sender_cache", exc)
|
||||
|
||||
'''
|
||||
|
||||
|
||||
def clean_module_code(code: str) -> str:
|
||||
"""Strips package imports, __all__, and docstrings for single-file bundling."""
|
||||
lines = code.splitlines()
|
||||
|
||||
Reference in New Issue
Block a user