Skip to content

Fix cargo fmt formatting issues#1

Merged
Hmbown merged 1 commit into
mainfrom
Hmbown/fix-cargo-fmt
Jan 20, 2026
Merged

Fix cargo fmt formatting issues#1
Hmbown merged 1 commit into
mainfrom
Hmbown/fix-cargo-fmt

Conversation

@Hmbown

@Hmbown Hmbown commented Jan 20, 2026

Copy link
Copy Markdown
Owner

Summary

  • Fix cargo fmt CI failure in src/commands/note.rs and src/settings.rs

Test plan

  • cargo fmt --all -- --check passes

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@Hmbown Hmbown merged commit f279531 into main Jan 20, 2026
1 check passed
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @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 cargo fmt in the CI pipeline. The changes ensure that the codebase adheres to the defined style guidelines, preventing future CI failures related to formatting and maintaining code consistency.

Highlights

  • CI Fix: Resolved cargo fmt CI failures in src/commands/note.rs and src/settings.rs.
  • Code Formatting: Applied consistent formatting by reordering use statements and adjusting format! macro calls in src/commands/note.rs.
  • Settings Formatting: Adjusted the formatting of the auto_rlm setting description in src/settings.rs for cargo fmt compliance.

🧠 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 Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

medium

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}"));
    }

@Hmbown Hmbown deleted the Hmbown/fix-cargo-fmt branch January 21, 2026 00:07
Hmbown added a commit that referenced this pull request Feb 19, 2026
Hmbown added a commit that referenced this pull request Apr 28, 2026
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>
MMMarcinho pushed a commit to MMMarcinho/DeepSeek-TUI that referenced this pull request May 6, 2026
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>
YaYII added a commit to YaYII/DeepSeek-TUI that referenced this pull request May 9, 2026
🔴 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 ✓
YaYII added a commit to YaYII/DeepSeek-TUI that referenced this pull request May 9, 2026
🔴 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 ✓
@Hmbown Hmbown mentioned this pull request May 10, 2026
8 tasks
Yourdaylight added a commit to Yourdaylight/DeepSeek-TUI that referenced this pull request May 15, 2026
… precision

- resolve_path: normalise .. components; reject workspace escapes (Hmbown#1,Hmbown#5)
- tool_read_file: clamp start_line >= 1 to prevent underflow panic (Hmbown#4)
- tool_edit_file: use replacen(.., 1) to avoid mass-replacement bugs (Hmbown#6,Hmbown#8)
Hmbown pushed a commit that referenced this pull request May 15, 2026
)

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>
encyc added a commit to encyc/DeepSeek-TUI that referenced this pull request May 31, 2026
…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).
Hmbown pushed a commit that referenced this pull request Jun 6, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant