11<script setup lang="ts">
22import type { DocksContext } from ' @vitejs/devtools-kit/client'
33import type { TerminalState } from ' ../state/terminals'
4+ import { watchImmediate } from ' @vueuse/core'
45import { shallowRef } from ' vue'
56import { useTerminals } from ' ../state/terminals'
7+ import DockIcon from ' ./DockIcon.vue'
68import ViewBuiltinTerminalPanel from ' ./ViewBuiltinTerminalPanel.vue'
79
810const props = defineProps <{
@@ -11,28 +13,40 @@ const props = defineProps<{
1113
1214const terminals = useTerminals (props .context )
1315const selectedTerminal = shallowRef <TerminalState | null >(null )
16+
17+ watchImmediate (
18+ terminals ,
19+ () => {
20+ if (selectedTerminal .value == null && terminals .size > 0 ) {
21+ selectedTerminal .value = terminals .values ().next ().value !
22+ }
23+ },
24+ )
1425 </script >
1526
1627<template >
17- <div class =" w-full h-full grid-cols -[max-content_1fr]" >
18- <div class =" border-base border-b" >
28+ <div class =" w-full h-full grid grid-rows -[max-content_1fr]" >
29+ <div class =" border-base border-b rounded-t overflow-x-auto " >
1930 <button
2031 v-for =" terminal of terminals.values()"
2132 :key =" terminal.info.id"
22- class =" px3 py2 border-r border-base hover:bg-active"
33+ class =" px3 py1.5 border-r border-base hover:bg-active text-sm flex items-center gap-1"
34+ :class =" { 'bg-active': selectedTerminal?.info.id === terminal.info.id }"
2335 @click =" selectedTerminal = terminal"
2436 >
25- {{ terminal.info.title }}
37+ <DockIcon :icon =" terminal.info.icon || 'ph:terminal-duotone'" />
38+ <span >{{ terminal.info.title }}</span >
2639 </button >
2740 </div >
28- <div class =" h-full flex relative" >
41+ <div class =" h-full w-full flex relative" >
2942 <ViewBuiltinTerminalPanel
3043 v-if =" selectedTerminal"
44+ :key =" selectedTerminal.info.id"
3145 :context
3246 :terminal =" selectedTerminal"
3347 />
34- <div v-else class =" flex items-center justify-center h-full text-center" >
35- Select a terminal tab to start
48+ <div v-else class =" flex items-center justify-center h-full w-full text-center" >
49+ < div > Select a terminal tab to start</ div >
3650 </div >
3751 </div >
3852 </div >
0 commit comments