mirror of
https://github.com/zed-industries/zed.git
synced 2026-11-19 15:10:34 +01:00
9a8ab54db4
# Objective The objective of this PR is to add a configuration option to disable automatic title generation for agent threads. This feature is desirable for users (e.g. as discussed in #63701) with token-based or compute constraints as it can prevent unnecessary (for some) overhead from title generation in addition to unnecessary large cache misses. My personal motivation is that automatic title generation pushes my entire context to my compute backend, which is a complete cache miss because (it appears) the prefix to the prompt is different. Whether it is intentional or not, automatic title generation can fire concurrent to actual generation (see Misc Notes [1]), slowing down my machine (and the output) considerably. ## Solution This PR adds a configuration option, which is exposed in the UI as well as through the standard settings.json channels, to disable automatic title generation. It's worth noting that manual title generation, as well as manual thread renaming, is still preserved. The configuration merely disables the _automatic_ title generation when the option is enabled. Ignoring the code for setting up the configuration option, this PR effectively adds a single condition to the `generate_title` call in `thread.rs` (in `run_turn_internal` that constitutes the automatic title generation. To my knowledge, this is what constitutes the "automatic title generation" and in the situation where I've seen it triggered reliably, it is no longer triggered when the disabling option is set. ## Testing - Did you test these changes? If so, how? - _Yes. I tested the functionality manually through disabling the "Auto-Generate Thread Titles" option in the Settings UI and triggering the condition where I knew automatic title generation would fire (described in Misc Notes [1]). I also tested manual title renaming and the "Regenerate thread title" function to ensure those functions were not affected. I also ran `cargo test --workspace`, which succeeded, and did UI regression tests (although it appears that my settings menu changes were not covered by them, since they did not fail when I didn't update the baseline)_ - _I also added automated tests for the feature, as well as tests to ensure that manual title generation is not affected._ - Are there any parts that need more testing? - _I was unable to fully test "Regenerate thread title" because it seems incompatible with my local LLM (it gets updated to a blank string after the compute backend returns). This is the case with the latest stable Zed (v1.19.2) and does not constitute a regression in my eyes. The automated tests I wrote should cover any regressions for users with a fully functional "Regenerate thread title" button._ - How can other people (reviewers) test your changes? Is there anything specific they need to know? - _Try to trigger automatic title generation with "Auto-Generate Thread Titles" enabled and disabled. You can verify that manual title generation ("Regenerate Thread Title") and manual title renaming also works._ - _It's worth noting that hosting my own compute backend (oMLX) was crucial in discovering and diagnosing this problem. If a tester does not have access to this, they will need to find another method of knowing if the `generate_title` method fires (such as a simple `println!`)._ - If relevant, what platforms did you test these changes on, and are there any important ones you can't test? - _**I only tested my changes on macOS 27 beta**, although the change set should be platform agnostic._ ## Self-Review Checklist: - [X] I've reviewed my own diff for quality, security, and reliability - [X] Unsafe blocks (if any) have justifying comments - [X] The content adheres to Zed's UI standards ([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) and [icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md) guidelines) - [X] Tests cover the new/changed behavior - [X] Performance impact has been considered and is acceptable ## Showcase I have provided a screenshot of the location of the new toggle below <details> <summary>Click to view screenshot of Settings page</summary> <img width="1012" height="863" alt="Screenshot 2026-09-09 at 9 41 27 PM" src="https://github.com/user-attachments/assets/5dd14f38-8cd1-46d1-b5bf-f2a6fb68c628" /> Above is a screenshot of the placement of the new Settings Menu item ("Auto-Generate Thread Titles"). It is disabled, which is not the default. </details> ## Misc Notes [1]: My "sure fire" way of triggering the automatic title generation (at an inconvenient time) is to stop a prefill request after sending a message in an existing thread (which will trigger the automatic title generation) then resend the message. Perhaps a healthier behaviour would be to cancel in-progress title generation if another generation request come in, but I think it is advantageous to give users an option to disable automatic title generation regardless. **LLM-Use Disclosure:** I used an LLM to assist in isolating the part of the code responsible for automatic title generation triggering and generating a portion of the code I am posting here. I have thoroughly understood, checked, and tested the code which I am submitting manually, and take full professional responsibility for its quality. I have added a `Signed-off-by` section to my commit message to indicate my signing off, and a `Co-Authored-By` section to indicate LLM use. **No LLM was used in the writing of this PR text or commit message.** Thank you! Please let me know if you want me to change anything. --- Release Notes: - Feature: Added a configuration option to disable automatic title generation for agent threads --------- Signed-off-by: Frederick Morlock <me@freddy.us> Co-authored-by: Hennadii Chernyshchyk <genaloner@gmail.com> Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>