Commit Graph

33507 Commits

Author SHA1 Message Date
Nathan Sobo
9a2a95e321 Fix TestScheduler lock ordering between rng and state 2025-12-14 14:28:13 -07:00
Nathan Sobo
3d387f4bcf Store element arena on App and route element allocations through draw scope 2025-12-14 14:28:10 -07:00
Nathan Sobo
99eb28785f Fix collab tests for scheduler timing and ordering 2025-12-14 14:28:07 -07:00
Nathan Sobo
e007b3227f Use per-app element arena only and scope test draws 2025-12-14 14:27:25 -07:00
Nathan Sobo
550da8756f Add STATUS.md for next agent 2025-12-14 11:02:25 -07:00
Nathan Sobo
1acd3a72c4 Remove unused RunnableVariant imports on Linux 2025-12-14 10:49:09 -07:00
Nathan Sobo
064ec8c52c Fix Linux build: add explicit type annotation and rename probability() to weight() 2025-12-14 10:42:08 -07:00
Nathan Sobo
280cf662a1 Fix formatting across the branch 2025-12-14 10:34:47 -07:00
Nathan Sobo
76e8715434 Phase 6 & 7: Restore realtime priority support and delete dead code
- Restore Priority::Realtime handling in BackgroundExecutor::spawn_with_priority
  - Spawns dedicated OS thread via dispatcher.spawn_realtime()
  - Uses flume channel to send runnables to the dedicated thread
  - Includes profiler timing integration for consistency with other dispatchers
- Delete orphaned crates/gpui/src/platform/platform_scheduler.rs (dead code)
- Fix test_parking_panics expected panic message
2025-12-14 10:28:01 -07:00
Nathan Sobo
be0444e039 Update integration plan with code review findings
- Add Phase 6: Restore Realtime Priority Support (regression)
- Add Phase 7: Delete dead platform/platform_scheduler.rs
- Fix architecture diagram to accurately reflect struct relationships
- Fix Phase 3 description (BackgroundExecutor holds Arc<dyn Scheduler> directly)
- Fix incorrect claim about macOS profiling (it does use task timing)
- Document intentional removals (spawn_labeled, deprioritize, start_waiting)
- Add code quality notes (lock ordering, dispatch_after behavior)
- Reference @as-cii approval for TaskLabel removal
2025-12-14 10:02:25 -07:00
Nathan Sobo
aa2ecef1cf Phase 5 Complete: Scheduler integration finished
- All tests pass (GPUI, scheduler, editor)
- Clippy passes with no warnings
- Updated integration plan to mark all phases complete

Key outcomes:
- GPUI executors now use scheduler crate internally
- TestDispatcher simplified to ~70 lines (delegates to TestScheduler)
- PlatformScheduler implements Scheduler trait for production
- Blocking logic consolidated in Scheduler::block()
- Session IDs prevent foreground reentrancy when blocking

Design decisions documented:
- Foreground priority parameter kept for API compatibility but ignored
- Profiler integration unchanged (works through dispatcher layer)
- Runtime scheduler selection based on dispatcher type
2025-12-14 09:46:37 -07:00
Nathan Sobo
a22bc65573 Phase 5 (WIP): Simplify block_internal and remove unparkers
Changes:
- Removed debug logging infrastructure from executor.rs
- Simplified block_internal to use waker_fn without Parker
- Removed unparkers mechanism from TestDispatcher
- TestDispatcher now just holds session_id and scheduler (~70 lines)

BROKEN: 3 editor tests fail:
- element::tests::test_soft_wrap_editor_width_auto_height_editor
- inlays::inlay_hints::tests::test_no_hint_updates_for_unrelated_language_files
- inlays::inlay_hints::tests::test_inside_char_boundary_range_hints

See crates/scheduler/full_integration_plan.md for investigation notes.
2025-12-14 08:51:15 -07:00
Nathan Sobo
328b5cb969 Phase 4: Remove TaskLabel
- Removed TaskLabel struct and its impl from gpui/src/executor.rs
- Removed spawn_labeled method from BackgroundExecutor
- Updated callers (buffer_diff, fs, language) to use regular spawn
- Removed label parameter from PlatformDispatcher::dispatch() trait
- Updated all dispatcher implementations (Mac, Linux, Windows, Test, PlatformScheduler)
- Fixed pre-existing dead code issues found during clippy
2025-12-14 08:08:09 -07:00
Nathan Sobo
d02575cf2b Phase 3: Delegate simulate_random_delay to scheduler.yield_random()
- TestDispatcher::simulate_random_delay() now delegates to TestScheduler::yield_random()
- Removed custom YieldNow future implementation (~20 lines)
- Cleaned up unused rand imports from gpui/src/executor.rs
- Fixed clippy warning about redundant async block in timer()
- Updated integration plan with next steps (Phase 4: Remove TaskLabel)
2025-12-14 07:57:55 -07:00
Nathan Sobo
fc620bba43 Update scheduler integration plan with Phase 2 investigation notes
Attempted to delegate GPUI's block_internal to scheduler.block() but
encountered an issue with the blocked_sessions mechanism interfering
with user code calling tick() from within a blocked future.

Updated the plan to document this finding and possible solutions to
investigate. The current workaround (GPUI using tick() directly) works
but is not the final desired state.
2025-12-14 07:47:20 -07:00
Nathan Sobo
a788c91de9 Update plan: mark Phase 1 (SharedRng) as complete 2025-12-14 07:00:46 -07:00
Nathan Sobo
7676004a96 Add SharedRng wrapper for ergonomic random number generation
- Create SharedRng type that wraps Arc<Mutex<StdRng>> and provides
  convenient methods (random_range, random_bool, random, random_ratio)
  that handle locking internally
- Update TestScheduler::rng() and BackgroundExecutor::rng() to return SharedRng
- SharedRng::lock() still available for cases needing &mut Rng
  (e.g., slice::choose, Oid::random)
- Update call sites to use the cleaner API without explicit .lock() calls
2025-12-14 07:00:26 -07:00
Nathan Sobo
e248cb14e5 Fix rng() usage to lock mutex, update plan with SharedRng wrapper
- Fix collab tests to call .lock() on rng() before using Rng methods
- Update integration plan to add Phase 1: Create SharedRng wrapper type
  that handles locking internally for better ergonomics
2025-12-14 06:58:00 -07:00
Nathan Sobo
7b08b685a2 Use scheduler's native timer() and simplify TestDispatcher
- BackgroundExecutor::timer() now uses Scheduler::timer() directly in tests
  instead of dispatch_after with an empty task body
- Removed the 'delayed' queue from TestDispatcher entirely
- dispatch_after() now panics in tests (should never be called)
- is_main_thread() now delegated to TestScheduler
- advance_clock() and tick() are simple delegations to scheduler
- Removed start_waiting/finish_waiting methods (no longer needed)
- Added set_block_on_ticks() for test timeout control
- Made advance_clock_to_next_timer() public on TestScheduler
- Deleted situation.md (outdated investigation doc)
- Updated integration plan to reflect current state

TestDispatcher is now ~170 lines, down from 242, and mostly just
implements PlatformDispatcher by delegating to TestScheduler.
2025-12-14 06:50:44 -07:00
Nathan Sobo
1fe806a34c Update integration plan with complete state and instructions for full scheduler migration
The plan now documents:
- All completed work (unified types, delegated queues, removed deprioritization, etc.)
- Current architecture with TestDispatcher as thin PlatformDispatcher wrapper
- Detailed strategy for eliminating PlatformDispatcher abstraction
- Phase-by-phase migration guide:
  1. Add schedule_after to Scheduler trait
  2. Move is_main_thread tracking into TestScheduler
  3. Move unparker mechanism into TestScheduler
  4. Create thin PlatformDispatcher impl for TestScheduler
  5. Delete TestDispatcher
  6-8. Longer term unification of Task/Executor types

The goal is to have GPUI use Scheduler trait directly and minimize
GPUI-specific scheduling code.
2025-12-14 06:30:10 -07:00
Nathan Sobo
8d4ac155e2 Remove wrapper methods from TestDispatcher - access scheduler() directly
TestDispatcher no longer wraps scheduler methods like rng(), parking_allowed(),
allow_parking(), forbid_parking(). Callers now access these via scheduler() directly.

Removed methods:
- rng() -> use scheduler().rng()
- parking_allowed() -> use scheduler().parking_allowed()
- allow_parking() -> use scheduler().allow_parking()
- forbid_parking() -> use scheduler().forbid_parking()

TestDispatcher is now 242 lines (down from 263).
2025-12-14 06:26:14 -07:00
Nathan Sobo
31270d41c8 Remove waiting_hint/waiting_backtrace and debug logging from TestDispatcher
Further simplification of TestDispatcher:
- Remove waiting_hint and waiting_backtrace (scheduler has PENDING_TRACES)
- Remove start_waiting/finish_waiting/set_waiting_hint methods
- Remove block_on_ticks (use rng directly for timeout ticks)
- Remove all dispatcher_log! debug logging infrastructure
- Remove set_block_on_ticks from BackgroundExecutor

TestDispatcher is now 263 lines (down from 493).

TestDispatcherState now only contains:
- delayed: Vec<(Instant, RunnableVariant)> - for dispatch_after
- is_main_thread: bool - for PlatformDispatcher API
- unparkers: Vec<Unparker> - for block_on wakeup
2025-12-14 06:22:39 -07:00
Nathan Sobo
f0e1a76877 Delegate TestDispatcher task queues to TestScheduler (Phase 2b)
This completes the major scheduler integration work:

**Task Queue Delegation**
- TestDispatcher now delegates foreground/background task scheduling to TestScheduler
- Each TestDispatcher instance gets a unique SessionId from TestScheduler
- dispatch() calls scheduler.schedule_background_with_priority()
- dispatch_on_main_thread() calls scheduler.schedule_foreground()
- Only the delayed queue remains local in TestDispatcher for dispatch_after()

**Unified Priority Types**
- Added RealtimePriority enum to scheduler crate
- Added Realtime(RealtimePriority) variant to scheduler's Priority enum
- GPUI now reexports Priority and RealtimePriority from scheduler
- Removed duplicate definitions from gpui/executor.rs

**Removed Deprioritization**
- Removed deprioritized_background queue from TestDispatcherState
- Removed deprioritize() from TestDispatcher and BackgroundExecutor
- Updated tests that relied on deprioritization

**New TestScheduler APIs**
- allocate_session_id(): Allocate session IDs for GPUI dispatcher instances
- tick(): Public interface to run one scheduler step
- tick_background_only(): Run only background tasks (no foreground)
- has_pending_tasks(): Check if work remains
- pending_task_counts(): Get (foreground, background) task counts

**Other Changes**
- executor.rng() now returns Arc<Mutex<StdRng>> instead of cloning
- Updated fake_git_repo.rs to use new rng() API
2025-12-14 06:13:54 -07:00
Nathan Sobo
56493370a4 Simplify RunnableVariant to type alias
- Changed RunnableVariant from single-variant enum to type alias:
  pub type RunnableVariant = Runnable<RunnableMeta>
- Removed all RunnableVariant::Meta(...) wrapping at spawn sites
- Removed all 'let RunnableVariant::Meta(runnable) = runnable;' destructuring
- Updated all platform dispatchers (Mac, Linux, Windows, Test, Wayland, X11, Headless)
- Updated executor.rs, platform_scheduler.rs, and REPL's ZedDispatcher
- Removed unused imports throughout
- Updated plan.md -> full_integration_plan.md with completed status
2025-12-14 06:00:07 -07:00
Nathan Sobo
5e41d48512 Update integration plans to reflect completed phases 2025-12-14 05:50:20 -07:00
Nathan Sobo
5c3b5a1d60 Eliminate RunnableVariant::Compat - all runnables now have source location metadata
- Remove RunnableVariant::Compat variant entirely
- Update PlatformScheduler::timer() to use async_task::Builder with RunnableMeta
- Update REPL's ZedDispatcher to wrap external Runnable with metadata
- Simplify all platform dispatchers (Mac, Linux, Windows, Test):
  - Remove Compat match arms
  - Use let-binding pattern for single-variant enum
- Remove unused trampoline_compat function from Mac dispatcher

All tasks now carry source location information for better debugging
and profiling. The RunnableVariant enum is now single-variant and
could be simplified further in a future change.
2025-12-14 05:49:25 -07:00
Nathan Sobo
02925409f0 Add is_ready() to GPUI Task for API parity with scheduler
Both GPUI and scheduler Task types now have identical APIs:
- ready(val) - create a task with an immediate value
- is_ready() - check if task has completed
- detach() - run task to completion in background

The only difference is GPUI's detach_and_log_err() which requires App context.
2025-12-14 05:41:36 -07:00
Nathan Sobo
c39581d52e Remove unused execution tracking from TestScheduler and TestDispatcher
The execution_hash/execution_count tracking was added speculatively but
has no actual consumers. Removing to reduce complexity.
2025-12-14 05:40:03 -07:00
Nathan Sobo
52e2650270 Unify RunnableMeta and add execution tracking to TestScheduler
Phase 2a partial - Unified RunnableMeta:
- Re-export RunnableMeta from scheduler crate in gpui/src/platform.rs
- Remove GPUI's duplicate RunnableMeta struct definition
- Remove RunnableVariant::Scheduler variant (now uses Meta for both)
- Update all platform dispatchers to remove Scheduler variant handling
- Update PlatformScheduler to use RunnableVariant::Meta

Phase 3c - Execution tracking:
- Add execution_hash and execution_count to TestScheduler state
- Add execution_hash(), execution_count(), reset_execution_tracking() methods
- Update step() to track execution order via location hashing
- Enables determinism verification in tests

Note: Waiting hints (Phase 3b) skipped - TestScheduler already has
superior pending_traces system with TracingWaker that automatically
captures backtraces for all pending futures.
2025-12-14 05:36:42 -07:00
Nathan Sobo
d5e1509b53 Fix formatting 2025-12-14 05:21:40 -07:00
Nathan Sobo
5b07e2b242 WIP: scheduler integration debugging 2025-12-14 04:56:42 -07:00
Nathan Sobo
9272b90672 WIP: Integrate scheduler crate into GPUI TestDispatcher
This commit integrates the scheduler crate's TestScheduler into GPUI's
TestDispatcher for deterministic testing. The TestDispatcher now uses
TestScheduler for:
- Clock/timing (via scheduler.clock())
- Random number generation (via scheduler.rng())
- Block-on tick configuration

GPUI's TestDispatcher maintains its own task queues (foreground, background,
delayed) because it needs to handle RunnableVariant with multiple variants
(Meta, Compat, Scheduler) that TestScheduler cannot process directly.

Key changes:
- TestDispatcher::new() now takes a seed (u64) instead of StdRng
- Clock and RNG are delegated to TestScheduler
- Added RunnableVariant::Scheduler for scheduler-based runnables
- Updated all platform dispatchers to handle the new variant

KNOWN ISSUE: Tests hang after completion. After running the collab
'workspace' tests, the test process hangs indefinitely after these pass:
  - test_contact_requests
  - test_server_restarts
  - test_random_channel_buffers
  - test_random_project_collaboration

The hang likely relates to teardown/cleanup when TestDispatcher shares
state with TestScheduler. Need to investigate:
1. Whether blocked_sessions in TestScheduler is properly cleaned up
2. Whether there are threads being parked that never get unparked
3. Whether the test macro teardown sequence interacts badly with scheduler
2025-12-14 04:56:04 -07:00
Nathan Sobo
8d714f0bc4 Fix race condition in test_collaborating_with_completion
The test had a race condition where LSP request handlers were registered
AFTER typing the trigger character. Whether this worked depended on task
scheduling order, which varies by seed.

Changes:
- Move handler setup BEFORE typing the trigger character in the test
- Make TestDispatcher::spawn_realtime panic to prevent future non-determinism
  from real OS threads escaping the deterministic test scheduler
- Add execution_hash() and execution_count() to TestDispatcher for debugging
- Add DEBUG_SCHEDULER=1 logging for task execution tracing
- Document the investigation in situation.md
2025-12-14 04:51:22 -07:00
John Tur
6cc947f654 Update cc and cmake crates (#44797)
This fixes the build when Visual Studio 2026 is installed.

Release Notes:

- N/A
2025-12-14 07:45:54 +00:00
Will Garrison
f2cc24c5fa docs: Add clarifying note about Vim subword motion (#44535)
Clarify the docs regarding how operators are affected when subword
motion in Vim is activated.

Ref:
https://github.com/zed-industries/zed/issues/23344#issuecomment-3186025873.

Release Notes:

- N/A

---------

Co-authored-by: Kunall Banerjee <hey@kimchiii.space>
2025-12-14 02:20:33 -05:00
Michael Benfield
488fa02547 Streaming tool use for inline assistant (#44751)
Depends on: https://github.com/zed-industries/zed/pull/44753

Release Notes:

- N/A

---------

Co-authored-by: Mikayla Maki <mikayla.c.maki@gmail.com>
2025-12-14 03:22:20 +00:00
Cole Miller
dad6481e02 Disambiguate branch name in title bar (#44793)
Add the repository name when:

- there's more than one repository, and
- the name of the active repository doesn't match the name of the
project (to avoid stuttering with the adjacent project switcher button)

Release Notes:

- The branch name in the title bar now includes the name of the current
repository when needed to disambiguate.
2025-12-14 02:51:58 +00:00
Danilo Leal
0283bfb049 Enable configuring edit prediction providers through the settings UI (#44505)
- Edit prediction providers can now be configured through the settings
UI
- Cleaned up the status bar menu to only show _configured_ providers
- Added to the status bar icon button tooltip the name of the active
provider
- Only display the data collection functionality under "Privacy" for the
Zed models
- Moved the Codestral edit prediction provider out of the Mistral
section in the agent panel into the settings UI
- Refined and improved UI and states for configuring GitHub Copilot as
both an agent and edit prediction provider

#### Todos before merge:

- [x] UI: Unify with settings UI style and tidy it all up
- [x] Unify Copilot modal `impl`s to use separate window
- [x] Remove stop light icons from GitHub modal
- [x] Make dismiss events work on GitHub modal
- [ ] Investigate workarounds to tell if Copilot authenticated even when
LSP not running


Release Notes:

- settings_ui: Added a section for configuring edit prediction providers
under AI > Edit Predictions, including Codestral and GitHub Copilot.
Once you've updated you can use the following link to open it:
zed://settings/edit_predictions.providers

---------

Co-authored-by: Ben Kunkle <ben@zed.dev>
2025-12-13 11:06:30 -05:00
Michael Benfield
56daba28d4 supports_streaming_tools member (#44753)
Release Notes:

- N/A
2025-12-13 00:56:06 +00:00
Josh Ayres
6e0ecbcb07 docs: Use relative_line_numbers instead of toggle_relative_line_numbers (#44749)
Just a small docs change

With the deprecation of `toggle_relative_line_numbers` the docs should
reflect that

Release Notes:

- N/A
2025-12-13 00:41:31 +00:00
Haojian Wu
4754422ef4 Add angled bracket highlighting for C++ (#44735)
Enables rainbow bracket highlighting for angle brackets (< >) in C++.

<img width="401" height="46" alt="image"
src="https://github.com/user-attachments/assets/169afdaa-c8be-4b78-bf64-9cf08787eb47"
/>


Release Notes:

- Added rainbow bracket coloring for C++ angle brackets (`<>`)
2025-12-13 01:38:44 +01:00
Marco Mihai Condrache
e860252185 gpui: Improve path rendering and bounds performance (#44655) 2025-12-12 23:01:16 +00:00
Anthony Eid
fad06dd00c git: Show all branches in branch picker empty state (#44742)
This fixes an issue where a user could get confused by the branch picker
because it would only show the 10 most recent branches, instead of all
branches.

Release Notes:

- git: Show all branches in branch picker when search field is empty
2025-12-12 17:59:35 -05:00
Xiaobo Liu
329ec645da gpui: Fix tab jitter from oversized scrolling (#42434) 2025-12-12 22:27:09 +00:00
Oleksiy Syvokon
e1d236eaf0 ep: Apply diff to editable region only and edit history fixes (#44737)
Release Notes:

- N/A

---------

Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
Co-authored-by: Agus Zubiaga <agus@zed.dev>
2025-12-12 21:18:13 +00:00
Agus Zubiaga
60f4aa333b edit prediction cli: Improve error handling (#44718)
We were panicking whenever something went wrong with an example in the
CLI. This can be very disruptive when running many examples, and e.g a
single request fails. Instead, if running more than one example, errors
will now be logged alongside instructions to explore and re-run the
example by itself.

<img width="1454" height="744" alt="CleanShot 2025-12-12 at 13 32 04@2x"
src="https://github.com/user-attachments/assets/87c59e64-08b9-4461-af5b-03af5de94152"></img>


You can still opt in to stop as soon as en error occurs with the new
`--failfast` argument.

Release Notes:

- N/A
2025-12-12 14:15:58 -03:00
localcc
a698f1bf63 Fix Bounds::contains (#44711)
Closes #11643 

Release Notes:

- Fixed double hover state on windows

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2025-12-12 14:49:29 +00:00
localcc
636d11ebec Multiple priority scheduler (#44701)
Improves the scheduler by allowing tasks to have a set priority which
will significantly improve responsiveness.

Release notes:

- N/A

---------

Co-authored-by: Yara <git@yara.blue>
Co-authored-by: dvdsk <noreply@davidsk.dev>
2025-12-12 06:32:30 -08:00
Agus Zubiaga
4d0e760b04 edit prediction cli: Progress output cleanup (#44708)
- Limit status lines to 10 in case `max_parallelism` is specified with a
grater value
- Handle logging gracefully rather than writing over it when clearing
status lines

Release Notes:

- N/A
2025-12-12 14:03:08 +00:00
localcc
8bd4d866b9 Windows/send keystrokes (#44707)
Closes #41176 

Release Notes:

- Fixed SendKeystrokes mapping on windows

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2025-12-12 05:51:11 -08:00