@@ -96,7 +96,8 @@ export interface ThreadRightPanelState {
9696}
9797
9898export interface ThreadPanelVisibility {
99- inlineOpen : boolean ;
99+ /** Absent until the user opens or closes the card here; absent threads follow the setting. */
100+ inlineOpen ?: boolean ;
100101 popoverOpen : boolean ;
101102}
102103
@@ -186,7 +187,11 @@ interface RightPanelStoreState {
186187 presentation : ThreadPanelPresentation ,
187188 open : boolean ,
188189 ) => void ;
189- toggleThreadPanel : ( ref : ScopedThreadRef , presentation : ThreadPanelPresentation ) => void ;
190+ toggleThreadPanel : (
191+ ref : ScopedThreadRef ,
192+ presentation : ThreadPanelPresentation ,
193+ inlineOpenByDefault : boolean ,
194+ ) => void ;
190195 removeThread : ( ref : ScopedThreadRef ) => void ;
191196}
192197
@@ -196,10 +201,7 @@ const EMPTY_THREAD_STATE: ThreadRightPanelState = {
196201 surfaces : [ ] ,
197202} ;
198203
199- const DEFAULT_THREAD_PANEL_VISIBILITY : ThreadPanelVisibility = {
200- inlineOpen : true ,
201- popoverOpen : false ,
202- } ;
204+ const DEFAULT_THREAD_PANEL_VISIBILITY : ThreadPanelVisibility = { popoverOpen : false } ;
203205
204206const singletonSurface = (
205207 kind : Exclude < RightPanelKind , "file" | "preview" | "terminal" | "pull-request" > ,
@@ -329,7 +331,7 @@ const updateThreadPanelVisibilityMap = (
329331) : Record < string , ThreadPanelVisibility > => {
330332 const current = byThreadKey [ threadKey ] ?? DEFAULT_THREAD_PANEL_VISIBILITY ;
331333 const next = updater ( current ) ;
332- if ( next . inlineOpen && ! next . popoverOpen ) {
334+ if ( next . inlineOpen === undefined && ! next . popoverOpen ) {
333335 if ( ! ( threadKey in byThreadKey ) ) return byThreadKey ;
334336 const { [ threadKey ] : _removed , ...rest } = byThreadKey ;
335337 return rest ;
@@ -1058,14 +1060,14 @@ export const useRightPanelStore = create<RightPanelStoreState>()(
10581060 } ,
10591061 ) ,
10601062 } ) ) ,
1061- toggleThreadPanel : ( ref , presentation ) =>
1063+ toggleThreadPanel : ( ref , presentation , inlineOpenByDefault ) =>
10621064 set ( ( state ) => ( {
10631065 threadPanelVisibilityByThreadKey : updateThreadPanelVisibilityMap (
10641066 state . threadPanelVisibilityByThreadKey ,
10651067 scopedThreadKey ( ref ) ,
10661068 ( visibility ) =>
10671069 presentation === "inline"
1068- ? { ...visibility , inlineOpen : ! visibility . inlineOpen }
1070+ ? { ...visibility , inlineOpen : ! ( visibility . inlineOpen ?? inlineOpenByDefault ) }
10691071 : { ...visibility , popoverOpen : ! visibility . popoverOpen } ,
10701072 ) ,
10711073 } ) ) ,
@@ -1110,7 +1112,9 @@ export const useRightPanelStore = create<RightPanelStoreState>()(
11101112 threadPanelVisibilityByThreadKey : Object . fromEntries (
11111113 Object . entries ( state . threadPanelVisibilityByThreadKey ) . flatMap (
11121114 ( [ threadKey , visibility ] ) =>
1113- visibility . inlineOpen ? [ ] : [ [ threadKey , { inlineOpen : false , popoverOpen : false } ] ] ,
1115+ visibility . inlineOpen === undefined
1116+ ? [ ]
1117+ : [ [ threadKey , { inlineOpen : visibility . inlineOpen , popoverOpen : false } ] ] ,
11141118 ) ,
11151119 ) ,
11161120 } ) ,
@@ -1165,9 +1169,12 @@ export function selectThreadPanelOpen(
11651169 byThreadKey : Record < string , ThreadPanelVisibility > ,
11661170 ref : ScopedThreadRef | null | undefined ,
11671171 presentation : ThreadPanelPresentation ,
1172+ inlineOpenByDefault : boolean ,
11681173) : boolean {
11691174 const visibility = selectThreadPanelVisibility ( byThreadKey , ref ) ;
1170- return presentation === "inline" ? visibility . inlineOpen : visibility . popoverOpen ;
1175+ return presentation === "inline"
1176+ ? ( visibility . inlineOpen ?? inlineOpenByDefault )
1177+ : visibility . popoverOpen ;
11711178}
11721179
11731180export function selectActiveRightPanel (
0 commit comments