@@ -144,18 +144,18 @@ async function renderMainCard() {
144144 }
145145
146146 document
147- . querySelector ( '# allSpacesLink .optionText ')
147+ . getElementById ( ' allSpacesLink')
148148 . addEventListener ( 'click' , ( ) => {
149149 chrome . runtime . sendMessage ( {
150150 action : 'requestShowSpaces' ,
151151 } ) ;
152152 window . close ( ) ;
153153 } ) ;
154154 document
155- . querySelector ( '# switcherLink .optionText ')
155+ . getElementById ( ' switcherLink')
156156 . addEventListener ( 'click' , ( ) => handlePopupMenuClick ( 'switch' ) ) ;
157157 document
158- . querySelector ( '# moverLink .optionText ')
158+ . getElementById ( ' moverLink')
159159 . addEventListener ( 'click' , ( ) => handlePopupMenuClick ( 'move' ) ) ;
160160}
161161
@@ -194,6 +194,12 @@ async function handleNameSave() {
194194 const inputEl = document . getElementById ( 'activeSpaceTitle' ) ;
195195 const newName = inputEl . value ;
196196
197+ // If the input is empty and the space was previously unnamed, restore the placeholder.
198+ if ( newName . trim ( ) === '' && ! globalCurrentSpace . name ) {
199+ inputEl . value = UNSAVED_SESSION ;
200+ return ;
201+ }
202+
197203 if (
198204 newName === UNSAVED_SESSION ||
199205 newName === globalCurrentSpace . name
@@ -209,19 +215,26 @@ async function handleNameSave() {
209215 }
210216
211217 if ( globalCurrentSpace . sessionId ) {
212- chrome . runtime . sendMessage ( {
218+ const updatedSession = await chrome . runtime . sendMessage ( {
213219 action : 'updateSessionName' ,
214220 deleteOld : true ,
215221 sessionName : newName ,
216222 sessionId : globalCurrentSpace . sessionId ,
217223 } ) ;
224+ if ( updatedSession ) {
225+ globalCurrentSpace . name = updatedSession . name ;
226+ }
218227 } else {
219- chrome . runtime . sendMessage ( {
228+ const newSession = await chrome . runtime . sendMessage ( {
220229 action : 'saveNewSession' ,
221230 deleteOld : true ,
222231 sessionName : newName ,
223232 windowId : globalCurrentSpace . windowId ,
224233 } ) ;
234+ if ( newSession ) {
235+ globalCurrentSpace . name = newSession . name ;
236+ globalCurrentSpace . sessionId = newSession . id ;
237+ }
225238 }
226239}
227240
0 commit comments