@@ -495,21 +495,27 @@ impl UserWorkspaces {
495495 view : & WeakViewHandle < T > ,
496496 app : & AppContext ,
497497 ) -> Option < TeamContext < ' a > > {
498- Some ( self . team_context_for_window ( view. window_id ( app) ?) )
498+ Some ( self . team_context_for_window_id ( view. window_id ( app) ?) )
499499 }
500500
501- /// [`Self::team_context`] for a caller that holds a [`WindowId`] rather than a view handle:
502- /// a model owned by a window's view tree, or a view still inside its own constructor.
501+ /// [`Self::team_context`] for a view still inside its own constructor.
503502 ///
504- /// Same borrow discipline, so a caller still re-resolves on every read and follows the
505- /// window. Unlike [`Self::team_context`] it cannot fail: a `WindowId` names a window
506- /// whether or not this model has a team assignment for it, and a window with no team
507- /// selected yields a scope whose `team_uid()` is `None`.
503+ /// A view is not in `view_to_window` until its build closure returns, so its own
504+ /// [`WeakViewHandle`] resolves no window yet and [`Self::team_context`] would report no
505+ /// scope. A `ViewContext` already names the window, and it is the same one the handle
506+ /// resolves to from the first render onward, so this cannot fail. Prefer
507+ /// [`Self::team_context`] everywhere else: a handle keeps following the view if it later
508+ /// moves between windows.
509+ pub ( crate ) fn team_context_for_view < T : Entity > ( & self , ctx : & ViewContext < T > ) -> TeamContext < ' _ > {
510+ self . team_context_for_window_id ( ctx. window_id ( ) )
511+ }
512+
513+ /// The resolution both scope accessors above share.
508514 ///
509- /// A stored `WindowId` is weaker evidence than a live [`ViewContext`]: dragging a tab
510- /// between windows re-parents the pane and the models it owns, so whoever stores one owes
511- /// it an update on re-parent .
512- pub ( crate ) fn team_context_for_window ( & self , window_id : WindowId ) -> TeamContext < ' _ > {
515+ /// Deliberately private. The exchange for a scope is a view or a [`ViewContext`], never a
516+ /// raw id, so that no caller is offered a `WindowId`-shaped hole to carry one around in
517+ /// place of the view it came from .
518+ fn team_context_for_window_id ( & self , window_id : WindowId ) -> TeamContext < ' _ > {
513519 TeamContext {
514520 team_uid : self
515521 . team_uid_for_window ( window_id)
0 commit comments