@@ -60,6 +60,10 @@ export const Workspace = (() => {
6060 const cookieName = `hidden_orgs_${ workspace } ` ;
6161 const cookieValue = JSON . stringify ( orgs ) ;
6262
63+ console . log ( `[Workspace.setHiddenOrgs] Workspace: ${ workspace } ` ) ;
64+ console . log ( `[Workspace.setHiddenOrgs] Cookie name: ${ cookieName } ` ) ;
65+ console . log ( `[Workspace.setHiddenOrgs] Cookie value: ${ cookieValue } ` ) ;
66+
6367 // Cookie size limit check (4KB is typical browser limit)
6468 // Allow some overhead for cookie name and attributes
6569 const maxCookieSize = 3800 ; // Conservative limit
@@ -79,23 +83,33 @@ export const Workspace = (() => {
7983 expires . setTime ( expires . getTime ( ) + 365 * 24 * 60 * 60 * 1000 ) ;
8084 const isSecure = window . location . protocol === "https:" ;
8185 const securePart = isSecure ? ";Secure" : "" ;
82- document . cookie = `${ cookieName } =${ cookieValue } ;expires=${ expires . toUTCString ( ) } ;path=/;domain=.${ BASE_DOMAIN } ;SameSite=Lax${ securePart } ` ;
86+ const cookieString = `${ cookieName } =${ cookieValue } ;expires=${ expires . toUTCString ( ) } ;path=/;domain=.${ BASE_DOMAIN } ;SameSite=Lax${ securePart } ` ;
87+ console . log ( `[Workspace.setHiddenOrgs] Setting cookie: ${ cookieString } ` ) ;
88+ document . cookie = cookieString ;
89+ console . log ( `[Workspace.setHiddenOrgs] document.cookie after set:` , document . cookie ) ;
8390 } ;
8491
8592 // Toggle org visibility
8693 const toggleOrgVisibility = ( org ) => {
94+ console . log ( `[Workspace.toggleOrgVisibility] Toggling: ${ org } ` ) ;
8795 const hidden = hiddenOrgs ( ) ;
96+ console . log ( `[Workspace.toggleOrgVisibility] Current hidden orgs:` , hidden ) ;
8897 const index = hidden . indexOf ( org ) ;
98+ console . log ( `[Workspace.toggleOrgVisibility] Index of ${ org } :` , index ) ;
8999
90100 if ( index === - 1 ) {
91101 // Hide the org
102+ console . log ( `[Workspace.toggleOrgVisibility] Adding ${ org } to hidden list` ) ;
92103 hidden . push ( org ) ;
93104 } else {
94105 // Show the org
106+ console . log ( `[Workspace.toggleOrgVisibility] Removing ${ org } from hidden list` ) ;
95107 hidden . splice ( index , 1 ) ;
96108 }
97109
110+ console . log ( `[Workspace.toggleOrgVisibility] New hidden list:` , hidden ) ;
98111 setHiddenOrgs ( hidden ) ;
112+ console . log ( `[Workspace.toggleOrgVisibility] After setHiddenOrgs, reading back:` , hiddenOrgs ( ) ) ;
99113 return hidden ;
100114 } ;
101115
@@ -104,6 +118,27 @@ export const Workspace = (() => {
104118 return hiddenOrgs ( ) . includes ( org ) ;
105119 } ;
106120
121+ // Initialize default hidden orgs for org-based workspaces
122+ // In org workspaces, hide personal account PRs by default, show all orgs
123+ const initializeDefaults = ( ) => {
124+ const workspace = currentWorkspace ( ) ;
125+ const username = getCookie ( "username" ) ;
126+
127+ // Only initialize defaults for org workspaces (not personal workspace)
128+ if ( ! workspace || ! username ) return ;
129+
130+ const cookieName = `hidden_orgs_${ workspace } ` ;
131+ const existingCookie = getCookie ( cookieName ) ;
132+
133+ // Only set defaults if no preference exists yet
134+ if ( existingCookie === null ) {
135+ console . log ( `[Workspace] Initializing defaults for org workspace: ${ workspace } ` ) ;
136+ console . log ( `[Workspace] Hiding personal account: ${ username } ` ) ;
137+ // Hide the user's personal GitHub account by default
138+ setHiddenOrgs ( [ username ] ) ;
139+ }
140+ } ;
141+
107142 // Switch workspace (redirect to different subdomain, preserving current path)
108143 const switchWorkspace = ( org ) => {
109144 const protocol = window . location . protocol ;
@@ -150,6 +185,7 @@ export const Workspace = (() => {
150185 isOrgHidden,
151186 switchWorkspace,
152187 username,
188+ initializeDefaults,
153189 } ;
154190 console . log ( "[Workspace Module] Exports:" , workspaceExports ) ;
155191 return workspaceExports ;
0 commit comments