Skip to content

Commit 2279bdc

Browse files
codewizdaveclaude
andcommitted
feat: add multi-step loader with progress icons
- Show searching, fetching, thinking, tool usage stages - Use emojis to indicate current step Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e487233 commit 2279bdc

10 files changed

Lines changed: 26 additions & 1 deletion
-229 Bytes
Binary file not shown.
8 KB
Binary file not shown.
-4.11 KB
Binary file not shown.
-15 KB
Binary file not shown.
603 Bytes
Binary file not shown.
8.55 KB
Binary file not shown.
1.3 KB
Binary file not shown.
8.41 KB
Binary file not shown.

websearch/core/agent/claude_client.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ async def ask_with_search(
5555
model: str = "MiniMax-M2.7",
5656
max_turns: int = 10,
5757
verbose: bool = False,
58+
progress_callback=None,
5859
) -> AskResult:
5960
"""Ask a question using web search and Claude Agent synthesis.
6061
@@ -77,6 +78,8 @@ async def ask_with_search(
7778

7879
try:
7980
# Perform web search
81+
if progress_callback:
82+
progress_callback("searching", "Searching the web...")
8083
results, cache_hit = await search.search(query, count=count)
8184

8285
if results.is_nothing():
@@ -85,6 +88,8 @@ async def ask_with_search(
8588
search_results = results.just_value()
8689

8790
# Fetch content from top results
91+
if progress_callback:
92+
progress_callback("fetching", f"Reading {len(search_results)} sources...")
8893
sources = []
8994
for r in search_results:
9095
content = await search.fetch(r.url)
@@ -133,7 +138,15 @@ async def ask_with_search(
133138
Format your response in clear Markdown."""
134139

135140
answer = ""
141+
if progress_callback:
142+
progress_callback("thinking", "Synthesizing answer...")
136143
async for message in sdk_query(prompt=prompt, options=options):
144+
if isinstance(message, AssistantMessage):
145+
for block in message.content:
146+
if isinstance(block, TextBlock):
147+
answer += block.text
148+
elif progress_callback and hasattr(block, 'name'):
149+
progress_callback("tool", f"Using tool: {block.name}")
137150
if isinstance(message, AssistantMessage):
138151
for block in message.content:
139152
if isinstance(block, TextBlock):

websearch/main.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,14 +201,26 @@ async def _ask():
201201
console.print(f"[dim]Using model: {model} (max {max_turns} turns)[/dim]\n")
202202

203203
with Progress(auto_refresh=True, console=console) as progress:
204-
task = progress.add_task("[dim]Searching and processing...[/dim]", total=None)
204+
task = progress.add_task("[dim]Starting...[/dim]", total=None)
205+
206+
def update_progress(step: str, message: str):
207+
step_icons = {
208+
"searching": "🔍",
209+
"fetching": "📖",
210+
"thinking": "🤔",
211+
"tool": "🔧",
212+
}
213+
icon = step_icons.get(step, "⏳")
214+
progress.update(task, description=f"[dim]{icon} {message}[/dim]")
215+
205216
result = await ask_with_search(
206217
query=query,
207218
count=count,
208219
cache_enabled=not no_cache,
209220
model=model,
210221
max_turns=max_turns,
211222
verbose=verbose,
223+
progress_callback=update_progress,
212224
)
213225
progress.remove_task(task)
214226

0 commit comments

Comments
 (0)