1+ import { useNavigate , useParams } from "@solidjs/router"
12import { createEffect , createMemo , For , Show , type Accessor , type JSX } from "solid-js"
23import { createStore } from "solid-js/store"
34import { createSortable } from "@thisbeyond/solid-dnd"
@@ -86,6 +87,8 @@ export const SortableWorkspace = (props: {
8687 project : LocalProject
8788 mobile ?: boolean
8889} ) : JSX . Element => {
90+ const navigate = useNavigate ( )
91+ const params = useParams ( )
8992 const globalSync = useGlobalSync ( )
9093 const language = useLanguage ( )
9194 const sortable = createSortable ( props . directory )
@@ -111,6 +114,7 @@ export const SortableWorkspace = (props: {
111114 const busy = createMemo ( ( ) => props . ctx . isBusy ( props . directory ) )
112115 const wasBusy = createMemo ( ( prev ) => prev || busy ( ) , false )
113116 const loading = createMemo ( ( ) => open ( ) && ! booted ( ) && sessions ( ) . length === 0 && ! wasBusy ( ) )
117+ const showNew = createMemo ( ( ) => ! loading ( ) && ( sessions ( ) . length === 0 || ( active ( ) && ! params . id ) ) )
114118 const loadMore = async ( ) => {
115119 setWorkspaceStore ( "limit" , ( limit ) => limit + 5 )
116120 await globalSync . project . loadSessions ( props . directory )
@@ -260,20 +264,39 @@ export const SortableWorkspace = (props: {
260264 </ DropdownMenu . Content >
261265 </ DropdownMenu . Portal >
262266 </ DropdownMenu >
267+ < Tooltip value = { language . t ( "command.session.new" ) } placement = "top" >
268+ < IconButton
269+ icon = "plus-small"
270+ variant = "ghost"
271+ class = "size-6 rounded-md opacity-0 pointer-events-none group-hover/workspace:opacity-100 group-hover/workspace:pointer-events-auto group-focus-within/workspace:opacity-100 group-focus-within/workspace:pointer-events-auto"
272+ data-action = "workspace-new-session"
273+ data-workspace = { base64Encode ( props . directory ) }
274+ aria-label = { language . t ( "command.session.new" ) }
275+ onClick = { ( event ) => {
276+ event . preventDefault ( )
277+ event . stopPropagation ( )
278+ props . ctx . setHoverSession ( undefined )
279+ props . ctx . clearHoverProjectSoon ( )
280+ navigate ( `/${ slug ( ) } /session` )
281+ } }
282+ />
283+ </ Tooltip >
263284 </ div >
264285 </ div >
265286 </ div >
266287 </ div >
267288
268289 < Collapsible . Content >
269290 < nav class = "flex flex-col gap-1 px-2" >
270- < NewSessionItem
271- slug = { slug ( ) }
272- mobile = { props . mobile }
273- sidebarExpanded = { props . ctx . sidebarExpanded }
274- clearHoverProjectSoon = { props . ctx . clearHoverProjectSoon }
275- setHoverSession = { props . ctx . setHoverSession }
276- />
291+ < Show when = { showNew ( ) } >
292+ < NewSessionItem
293+ slug = { slug ( ) }
294+ mobile = { props . mobile }
295+ sidebarExpanded = { props . ctx . sidebarExpanded }
296+ clearHoverProjectSoon = { props . ctx . clearHoverProjectSoon }
297+ setHoverSession = { props . ctx . setHoverSession }
298+ />
299+ </ Show >
277300 < Show when = { loading ( ) } >
278301 < SessionSkeleton />
279302 </ Show >
0 commit comments