Fix cargo fmt formatting issues#1
Conversation
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Summary of ChangesHello @Hmbown, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses and resolves automated code formatting issues identified by Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request correctly applies cargo fmt to resolve formatting issues. The changes look good. I've added one suggestion in src/commands/note.rs to improve the consistency of the note formatting, which is a minor logic improvement related to the changed code.
I am having trouble creating individual review comments. Click here to see my feedback.
src/commands/note.rs (48-53)
The current logic for writing notes can lead to inconsistent formatting. Specifically, it always prepends \n---\n, which results in an unnecessary leading newline and separator for the very first note in an empty file. A better approach is to check if the file is empty. If so, write the note content directly. Otherwise, prepend the separator. This ensures notes are always formatted consistently without leading whitespace in new files.
// Write separator and note content
let is_empty = match file.metadata() {
Ok(md) => md.len() == 0,
Err(e) => return CommandResult::error(format!("Failed to read file metadata: {e}")),
};
let format_string = if is_empty { "{}" } else { "\n---\n{}" };
if let Err(e) = writeln!(file, format_string, note_content) {
return CommandResult::error(format!("Failed to write note: {e}"));
}
Sub-area #1 of the v0.6.6 UI redesign (issue #121). User cells now lead with `▎` (solid bar, no animation — input is finished). Assistant cells lead with `●`. While streaming, the bullet pulses on a 2-second cycle between 30%..100% brightness via `palette::pulse_brightness`; once a turn completes the bullet sits at full DEEPSEEK_SKY so finished history reads as solid. Honors `low_motion`: the pulse is suppressed and the glyph holds full brightness regardless of streaming state. Pager / clipboard exports (`transcript_lines`) also skip the pulse so screenshots are stable. Existing pager titles in `ui.rs` (`history_cell_to_text`) keep the literal "You" / "Assistant" wording — those drive the modal title bar and read better as words than as glyphs. Tests: glyphs replace the literal labels in both User and Assistant cells; streaming pulse demonstrably dips below source brightness; idle and low_motion both pin to source. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sub-area Hmbown#1 of the v0.6.6 UI redesign (issue Hmbown#121). User cells now lead with `▎` (solid bar, no animation — input is finished). Assistant cells lead with `●`. While streaming, the bullet pulses on a 2-second cycle between 30%..100% brightness via `palette::pulse_brightness`; once a turn completes the bullet sits at full DEEPSEEK_SKY so finished history reads as solid. Honors `low_motion`: the pulse is suppressed and the glyph holds full brightness regardless of streaming state. Pager / clipboard exports (`transcript_lines`) also skip the pulse so screenshots are stable. Existing pager titles in `ui.rs` (`history_cell_to_text`) keep the literal "You" / "Assistant" wording — those drive the modal title bar and read better as words than as glyphs. Tests: glyphs replace the literal labels in both User and Assistant cells; streaming pulse demonstrably dips below source brightness; idle and low_motion both pin to source. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
🔴 Fix Hmbown#1 (Embedder blocks async runtime): - Pre-warm embedder in init_vector_db() via warmup_embedder() - Model downloaded during startup, not first retrieval - Eliminates 5-10s UI freeze on first embed call 🔴 Fix Hmbown#2 (Compaction summary pollution): - store_compaction_summary_to_vector_db() now extracts only the summary section from the SystemPrompt, stripping boilerplate headers and workflow context - Uses regex extraction between ## Summary and ## Workflow markers 🔴 Fix Hmbown#3 (No vector index → full table scan): - New ensure_vector_index() in LanceDbBackend - Checks list_indices() for existing IVF-PQ index on embedding column - Creates missing index via table.create_index(["embedding"], Index::Auto) - Called from ensure_tables() for all three tables 🔴 Fix Hmbown#4 (Compaction threshold regression for non-vector users): - Added MINIMUM_AUTO_COMPACTION_TOKENS_WITHOUT_VECTOR = 500K - should_compact() now accepts vector_db_enabled: bool - Non-vector users keep 500K floor; vector users use 50K floor - auto_floor_tokens=0 (explicit disable by tests) bypasses both floors - token_threshold default restored to 800K (fallback only; real values come from compaction_threshold_for_model_and_effort) 🟡 Fix Hmbown#7 (No score threshold → noise injection): - search_memories() and search_summaries() now filter results where score < 0.4 before returning - Prevents low-quality retrieval from polluting system prompt Tests: 62/62 compaction ✓, 17/17 vector_db ✓
🔴 Hmbown#1 Embedder blocks async runtime: - Pre-warm embedder in init_vector_db() via warmup_embedder() - Model downloaded at startup, eliminating 5-10s UI freeze 🔴 Hmbown#2 Compaction summary boilerplate pollution: - store_compaction_summary_to_vector_db() now extracts only the actual summary section using regex, stripping headers and workflow context from embeddings 🔴 Hmbown#3 No vector index → full table scan: - New ensure_vector_index() checks list_indices() for IVF-PQ - Creates missing index via create_index(["embedding"], Auto) - Called from ensure_tables() for all 3 tables 🔴 Hmbown#4 Compaction threshold regression: - Added MINIMUM_AUTO_COMPACTION_TOKENS_WITHOUT_VECTOR = 500K - should_compact() accepts vector_db_enabled: bool - Non-vector users keep 500K floor; vector users get 50K - auto_floor_tokens=0 bypasses both (test compatibility) - token_threshold default restored to 800K 🟡 Hmbown#7 Score threshold filtering added: - search_memories() and search_summaries() filter score < 0.4 Tests: 62/62 compaction ✓, 17/17 vector_db ✓, 99/100 engine ✓
) When an OpenAI-compatible backend (vLLM, Ollama, LM Studio, Together AI, self-hosted vLLM/SGLang, etc.) streams an assistant message containing multiple tool_calls in a single round, only the **last** tool's `Event::ToolCallStarted` was firing. The preceding N-1 tool calls executed and produced tool_result events, but never announced their start to consumers (TUI / runtime API / embedder bridges), leaving them with N orphan tool_result blocks and no matching tool_use blocks in the assistant history. ## Reproduction ```text backend dispatches: 7 × write_file + 1 × exec_shell log shows: 7 × ApprovalRequired events ✓ listeners receive: 1 × chat:tool_start, 7 × chat:tool_end session history: 1 tool_use + 7 tool_result (6 orphans) ``` Tested against vLLM 0.7 + Qwen3.6-35B-A3B with a "scaffold 7-file Tauri template" prompt. Any model+backend combo that emits batch tool_calls trips this — typical when a single LLM round asks for multiple parallel file writes or edits. ## Root cause `run_turn` tracked the currently-streaming tool block with a single `current_tool_index: Option<usize>`. The Anthropic-style adapter (non-streaming response → events at `chat.rs::L1807`) emits Start/Stop pairs in lockstep so the slot never overlaps. But the OpenAI streaming parser (`chat.rs::L1954-2064`) emits every `ContentBlockStart::ToolUse` as soon as a tool_call delta lands, then batches every `ContentBlockStop` at `finish_reason`: ```text Start { index: 0 } // tool #1 Delta { index: 0, .. } Start { index: 1 } // tool #2 — overwrites current_tool_index Delta { index: 1, .. } … Start { index: 6 } // current_tool_index = Some(6) Delta { index: 6, .. } Stop { index: 0 } // take() returns Some(6) ← wrong tool! Stop { index: 1 } // take() returns None Stop { index: 2 } // take() returns None … ``` The first `Stop` consumes the last index and emits `ToolCallStarted` for the wrong `tool_uses` entry; every subsequent `Stop` finds the slot already `None` and skips the entire `if let Some(index) = …` branch, dropping the announcement. ## Fix Replace the single slot with `HashMap<u32 block_index, usize tool_uses_idx>`: - `ContentBlockStart::ToolUse` and `::ServerToolUse` insert the `(event.index → tool_uses.len())` mapping. - `InputJsonDelta` looks up by the `ContentBlockDelta` outer index. - `ContentBlockStop` removes by the stop's index, so each Stop routes to its own `tool_uses` entry regardless of arrival order. Routing no longer depends on `current_block_kind` (which has the same single-slot overwrite problem); `current_tool_indices.remove(&index)` returning `Some(_)` already proves the Stop belongs to a tool block. ## Tests Added `batch_tool_calls_preserve_all_tool_use_indices` in `core/engine/turn_loop.rs::tests` — feeds 7 Starts and 7 Stops through the same `HashMap` API used by `run_turn`, asserts every index round-trips. Manual end-to-end verification: vLLM + Qwen3.6-35B + 7-file Tauri template prompt → frontend `messages` history now contains all 7 `write_file` tool_use blocks paired with their tool_result blocks. Co-authored-by: hexin <he.xin@h3c.com>
…trol, verify fast-path, naming - combined_hash now hashes full tool JSON (name + description + schema), not just tool names, so schema/description changes are detected (Hmbown#1). - build_messages preserves cache_control from SystemPrompt::Blocks so DeepSeek context-cache breakpoints are not lost (Hmbown#2). - FrozenPrefix::verify() compares raw text before hashing to avoid redundant SHA-256 computation (Hmbown#3). - build_messages uses self.message_count() for vector capacity (Hmbown#4). - Strict-mode error message no longer references nonexistent /prefix-unfreeze command — suggests restart or config toggle (Hmbown#5).
Six fixes for the bot review comments landed on PR #2864 head 649d399. See phase2-playbook.md §7 for the triage rationale. * persistence.rs: oversized state file now surfaces an InvalidData error instead of silently returning a default. The old behaviour would let the next save overwrite the oversized file and destroy the user's data. Test updated to expect the error. * persistence.rs: PersistedDelegation gains a `status` field so in-flight `InProgress` delegations aren't silently demoted to `Pending` on restart. The snapshot now writes the live status and restore_from_snapshot honours it. Adds a regression test. * mention.rs: resolve_tab_mention no longer sorts its input — tab mentions (@tab2) must map to the visual order in the tab bar, not to an arbitrary ID sort. Test updated. * manager.rs: `pending_tasks` renamed to `completed_delegations` because the getter returns completed DelegationResults, not in-flight tasks. Docstring points to the in-flight getter `pending_delegations` to avoid the same confusion recurring. * manager.rs: delegate_task and start_meeting now validate that the from/to tab IDs (or all participant IDs) currently exist in the manager. Returns `None` on any unknown ID, preventing orphaned tasks / meetings with stale tab references. Two new regression tests cover both methods. Local CI matrix (Windows runner, flags matching ci.yml): - cargo fmt --all -- --check: exit 0 - cargo clippy --workspace --all-features --locked -- -D warnings: exit 0 - cargo test --workspace --all-features --locked: 4282 pass, 6 fail (the 6 failures are pre-existing on the baseline; not caused by this PR) - git diff --exit-code -- Cargo.lock: exit 0 The three deferred threads (#1 close_tab cleanup, #5 cross_tab_links snapshot, #8 TabGroup::new collision risk) are explicitly out of scope here; they belong to the follow-up collab/UI PR per the narrow-harvest promise to Hmbown. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Summary
Test plan
cargo fmt --all -- --checkpasses🤖 Generated with Claude Code