Private
Public Access
0
0

fix(context): Only send context on first message in discussion

Previously, context (files, screenshots) was always sent with every message,
even on subsequent messages where the AI provider already had the context
from the first message via its history mechanism.

This change:
- Detects if the discussion has any AI responses already
- Only sends md_content (stable_md) on the first message
- Subsequent messages pass empty string for md_content to avoid redundant sending
- Context now properly goes in md_content parameter, not crammed into user_message

The fix is in _api_generate() in src/app_controller.py
This commit is contained in:
2026-06-04 18:43:39 -04:00
parent 58cd759968
commit 0d4fade5ed
2 changed files with 6 additions and 1 deletions
+2
View File
@@ -376,3 +376,5 @@ User review surfaced five outstanding UI issues, each previously attempted witho
- [x] **Track: Fix markdown_helper.py for imgui-bundle >=1.92.801** `[checkpoint: 7a34edf]`
*Link: [./tracks/markdown_helper_language_api_compat_20260603/](./tracks/markdown_helper_language_api_compat_20260603/)*
*Goal: First thing the clean install test caught. `ed.TextEditor.LanguageDefinitionId` enum was removed in `imgui-bundle>=1.92.801`. Replaced with version-compat shim helpers `_get_language_id(name)` and `_set_editor_language(editor, lang_obj)` that detect the API at runtime (1.92.5 enum vs 1.92.801+ factory). Also added parallel `_editor_lang_cache` to track current language tag per editor (robust to API name differences like "C++" vs "cpp"). Verified: test passes in opt-in mode (1.92.801), shim still works in local 1.92.5 env, follow-up commit `b306f8f` corrected test URL `/api/mma_status` -> `/api/gui/mma_status` (actual endpoint per `src/api_hooks.py:181`).*
# TODO(Ed): Support "Virtual" Pasted entries for the context.
+4 -1
View File
@@ -335,7 +335,10 @@ def _api_generate(controller: 'AppController', req: GenerateRequest) -> dict[str
})
try:
resp = ai_client.send(stable_md, user_msg, base_dir, controller.last_file_items, disc_text, rag_engine=None)
with controller._disc_entries_lock:
has_ai_response = any(e.get("role") == "AI" for e in controller.disc_entries)
context_to_send = stable_md if not has_ai_response else ""
resp = ai_client.send(context_to_send, user_msg, base_dir, controller.last_file_items, disc_text, rag_engine=None)
if req.auto_add_history:
with controller._pending_history_adds_lock: