<[fim-suffix]> <[fim-prefix]>zed/crates/project/src/project.rs pub struct Project { active_entry: Option, buffer_ordered_messages_tx: mpsc::UnboundedSender, languages: Arc, dap_store: Entity, agent_server_store: Entity, breakpoint_store: Entity, collab_client: Arc, join_project_response_message_id: u32, task_store: Entity, user_store: Entity, fs: Arc, remote_client: Option>, // todo lw explain the client_state x remote_client matrix, its super confusing client_state: ProjectClientState, git_store: Entity, collaborators: HashMap, client_subscriptions: Vec, worktree_store: Entity, buffer_store: Entity, context_server_store: Entity, image_store: Entity, lsp_store: Entity, _subscriptions: Vec, buffers_needing_diff: HashSet>, git_diff_debouncer: DebouncedDelay, remotely_created_models: Arc>, terminals: Terminals, node: Option, search_history: SearchHistory, search_included_history: SearchHistory, search_excluded_history: SearchHistory, snippets: Entity, environment: Entity, settings_observer: Entity, toolchain_store: Option>, agent_location: Option, downloading_files: Arc>>, } ... pub enum Event { LanguageServerAdded(LanguageServerId, LanguageServerName, Option), LanguageServerRemoved(LanguageServerId), LanguageServerLog(LanguageServerId, LanguageServerLogType, String), ... LanguageServerBufferRegistered { server_id: LanguageServerId, ... }, ToggleLspLogs { server_id: LanguageServerId, ... }, Toast { notification_id: SharedString, ... }, HideToast { notification_id: SharedString, }, LanguageServerPrompt(LanguageServerPromptRequest), LanguageNotFound(Entity), ActiveEntryChanged(Option), ActivateProjectPanel, WorktreeAdded(WorktreeId), WorktreeOrderChanged, WorktreeRemoved(WorktreeId), WorktreeUpdatedEntries(WorktreeId, UpdatedEntriesSet), DiskBasedDiagnosticsStarted { language_server_id: LanguageServerId, }, DiskBasedDiagnosticsFinished { language_server_id: LanguageServerId, }, DiagnosticsUpdated { paths: Vec, ... }, RemoteIdChanged(Option), DisconnectedFromHost, DisconnectedFromRemote { server_not_running: bool, }, Closed, DeletedEntry(WorktreeId, ProjectEntryId), CollaboratorUpdated { old_peer_id: proto::PeerId, ... }, CollaboratorJoined(proto::PeerId), CollaboratorLeft(proto::PeerId), HostReshared, Reshared, Rejoined, RefreshInlayHints { server_id: LanguageServerId, ... }, RefreshSemanticTokens { server_id: LanguageServerId, ... }, RefreshCodeLens, RevealInProjectPanel(ProjectEntryId), SnippetEdit(BufferId, Vec<(lsp::Range, Snippet)>), ExpandedAllForEntry(WorktreeId, ProjectEntryId), EntryRenamed(ProjectTransaction, ProjectPath, PathBuf), WorkspaceEditApplied(ProjectTransaction), AgentLocationChanged, BufferEdited, } ... pub struct ProjectPath { pub worktree_id: WorktreeId, pub path: Arc, } ... zed/crates/edit_prediction/src/edit_prediction.rs pub struct EditPredictionJumpsFeatureFlag; ... pub struct EditPredictionStore { client: Arc, user_store: Entity, llm_token: LlmApiToken, _llm_token_subscription: Subscription, projects: HashMap, update_required: bool, edit_prediction_model: EditPredictionModel, zeta2_raw_config: Option, pub sweep_ai: SweepAi, pub mercury: Mercury, data_collection_choice: DataCollectionChoice, reject_predictions_tx: mpsc::UnboundedSender, shown_predictions: VecDeque, rated_predictions: HashSet, } ... struct ProjectState { events: VecDeque, last_event: Option, recent_paths: VecDeque, registered_buffers: HashMap, current_prediction: Option, next_pending_prediction_id: usize, pending_predictions: ArrayVec, debug_tx: Option>, last_edit_prediction_refresh: Option<(EntityId, Instant)>, last_jump_prediction_refresh: Option<(EntityId, Instant)>, cancelled_predictions: HashSet, context: Entity, license_detection_watchers: HashMap>, user_actions: VecDeque, _subscriptions: [gpui::Subscription; 2], copilot: Option>, } ... impl EditPredictionStore { pub fn try_global(cx: &App) -> Option> { ... } pub fn global( client: &Arc, user_store: &Entity, cx: &mut App, ) -> Entity { ... } pub fn new(client: Arc, user_store: Entity, cx: &mut Context) -> Self { ... } fn zeta2_raw_config_from_env() -> Option { ... } pub fn set_edit_prediction_model(&mut self, model: EditPredictionModel) { self.edit_prediction_model = model; } pub fn set_zeta2_raw_config(&mut self, config: Zeta2RawConfig) { self.zeta2_raw_config = Some(config); } pub fn zeta2_raw_config(&self) -> Option<&Zeta2RawConfig> { self.zeta2_raw_config.as_ref() } pub fn icons(&self, cx: &App) -> edit_prediction_types::EditPredictionIconSet { ... } pub fn has_sweep_api_token(&self, cx: &App) -> bool { self.sweep_ai.api_token.read(cx).has_key() } pub fn has_mercury_api_token(&self, cx: &App) -> bool { self.mercury.api_token.read(cx).has_key() } pub fn clear_history(&mut self) { ... } pub fn clear_history_for_project(&mut self, project: &Entity) { ... } pub fn edit_history_for_project( &self, project: &Entity, cx: &App, ) -> Vec { ... } pub fn context_for_project<'a>( &'a self, project: &Entity, cx: &'a mut App, ) -> Vec { ... } pub fn copilot_for_project(&self, project: &Entity) -> Option> { ... } pub fn start_copilot_for_project( &mut self, project: &Entity, cx: &mut Context, ) -> Option> { ... } pub fn context_for_project_with_buffers<'a>( &'a self, project: &Entity, cx: &'a mut App, ) -> Vec<(RelatedFile, Entity)> { ... } fn handle_project_event( &mut self, project: Entity, event: &project::Event, cx: &mut Context, ) { ... let Some(project_state) = self.projects.get_mut(&project.entity_id()) else { ... if let Some(path) = path { ... } fn register_buffer_impl<'a>( project_state: &'a mut ProjectState, buffer: &Entity, project: &Entity, cx: &mut Context, ) -> &'a mut RegisteredBuffer { ... } pub fn refresh_prediction_from_diagnostics( &mut self, project: Entity, scope: DiagnosticSearchScope, cx: &mut Context, ) { ... } fn predictions_enabled_at( snapshot: &BufferSnapshot, position: Option, cx: &App, ) -> bool { ... zed/crates/gpui/src/app/context.rs pub struct Context<'a, T> { app: &'a mut App, entity_state: WeakEntity, } ... zed/crates/feature_flags/src/feature_flags.rs impl FeatureFlagAppExt for App { ... fn has_flag(&self) -> bool { self.try_global::() .map(|flags| flags.has_flag::()) .unwrap_or_else(|| { (cfg!(debug_assertions) && T::enabled_for_staff() && !*ZED_DISABLE_STAFF) || T::enabled_for_all() }) } ... } ... zed/crates/gpui/src/app/entity_map.rs pub struct Entity { #[deref] #[deref_mut] pub(crate) any_entity: AnyEntity, pub(crate) entity_type: PhantomData T>, } ... edit_history --- a/zed/crates/edit_prediction/src/edit_prediction.rs +++ b/zed/crates/edit_prediction/src/edit_prediction.rs @@ -1035,7 +1035,7 @@ project_state.recent_paths.push_front(path); } } - project::Event::DiagnosticsUpdated { .. } => { + project::Event::Disk { .. } => { if cx.has_flag::() { self.refresh_prediction_from_diagnostics( project, crates/edit_prediction/src/edit_prediction.rs ) { if !is_ep_store_provider(all_language_settings(None, cx).edit_predictions.provider) { return; } // TODO [zeta2] init with recent paths match event { project::Event::ActiveEntryChanged(Some(active_entry_id)) => { let Some(project_state) = self.projects.get_mut(&project.entity_id()) else { <|marker_1|> return; }; let path = project.read(cx).path_for_entry(*active_entry_id, cx); if let Some(path) = path { if let Some(ix) = project_state .recent_paths .iter() .position(|probe| probe == &path) { project_state.recent_paths.remove(ix); } project_state.recent_paths.push_front(path); } } project::Event::Disk<|user_cursor|> { .. } => { if cx.has_flag::() { <|marker_2|> self.refresh_prediction_from_diagnostics( project, DiagnosticSearchScope::Global, cx, ); } } _ => (), } } fn register_buffer_impl<'a>( project_state: &'a mut ProjectState, buffer: &Entity, project: &Entity,<|marker_3|> <[fim-middle]>