Skip to content

Commit ab63149

Browse files
committed
implemented copilot proposed changes
1 parent 6dd0ac9 commit ab63149

5 files changed

Lines changed: 11 additions & 5 deletions

File tree

src/ai_agent/agent/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from typing import List, Optional, Any, Dict
44
from pydantic import BaseModel, Field
55

6-
from ai_agent.generator.schema import ToolChoice, ToolSelection, Conversation, ConversationStatus, CandidateDoc
6+
from ai_agent.generator.schema import ToolSelection, CandidateDoc
77

88
class ToolRunLog(BaseModel):
99
tool: str

src/ai_agent/cli.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ def run_chat():
6565
ok = pipe.reload_index()
6666
if ok:
6767
log.info("[startup-refresh] reloaded FAISS index")
68+
refresh_ui_docs_from_index()
6869
else:
6970
log.warning("[startup-refresh] reload failed; serving previous index")
7071
else:

src/ai_agent/ui/components.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,8 @@ def handle_chat(message: str, history: List[dict], files: List, state_dict: dict
288288
)
289289

290290
# Remove thinking indicator
291-
history.pop()
291+
if history and history[-1] == thinking_msg:
292+
history.pop()
292293

293294
# Add assistant response with rich media
294295
# Build text content first

src/ai_agent/ui/handlers.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,12 @@ def respond(
168168
if state.last_preview_path:
169169
try:
170170
data_url = _to_supported_png_dataurl(state.last_preview_path)
171-
except Exception:
172-
pass
171+
except Exception as e:
172+
log.debug(
173+
"Failed to build PNG data URL from preview %r: %r",
174+
state.last_preview_path,
175+
e,
176+
)
173177

174178
# Extract original formats
175179
original_formats = []

src/ai_agent/ui/state.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
import json
4+
import os
45
from typing import List, Dict, Any, Optional, Tuple
56
from dataclasses import dataclass, field
67

@@ -69,7 +70,6 @@ def to_markdown(self) -> str:
6970

7071
# Render file links
7172
for file_path, label in self.files:
72-
import os
7373
if os.path.exists(file_path):
7474
parts.append(f"\n📎 [{label}]({file_path})")
7575

0 commit comments

Comments
 (0)