feat(web/claw): fold the other keys to a working count
The task: and calendar: keys sat in the sidebar at full height all the time, a block of rows most of them idle. The group folds now: by default it shows one line, the count of other sessions holding a lease (the same `leased` state the status dot paints green) beside a more button, and the button unfolds every row and becomes less. The count stays visible unfolded, so the header does not jump when it toggles. The count is gray at zero and takes the ok color only when something runs. The Sessions header still counts folded rows, and the fold state is in-memory like the rest of the page: a reload folds again.
This commit is contained in:
1 parent
473a7765e7
commit
178d0af82b
1 file changed
+64
-3
@@ -7,6 +7,10 @@
|
|||||||
// new key lands in the inventory. The delete button asks nothing itself
|
// new key lands in the inventory. The delete button asks nothing itself
|
||||||
// — the confirmation, which names the transcript that goes with the
|
// — the confirmation, which names the transcript that goes with the
|
||||||
// session, is the shell's.
|
// session, is the shell's.
|
||||||
|
//
|
||||||
|
// The non-interactive keys fold under *others*: folded (the default),
|
||||||
|
// the group shows only how many of them hold a lease, plus the
|
||||||
|
// more/less toggle; unfolded it lists every row.
|
||||||
import { SESSION_NAME_PATTERN, isResidentKey } from '~/composables/useClaw'
|
import { SESSION_NAME_PATTERN, isResidentKey } from '~/composables/useClaw'
|
||||||
import type { ClawSession } from '~/composables/useClaw'
|
import type { ClawSession } from '~/composables/useClaw'
|
||||||
|
|
||||||
@@ -28,6 +32,10 @@ const emit = defineEmits<{
|
|||||||
interface Group {
|
interface Group {
|
||||||
label: string
|
label: string
|
||||||
rows: { key: string; name: string; session: ClawSession }[]
|
rows: { key: string; name: string; session: ClawSession }[]
|
||||||
|
/** How many rows hold a lease; the others' header shows the count. */
|
||||||
|
working: number
|
||||||
|
/** Whether the rows fold away until the toggle says otherwise. */
|
||||||
|
collapsible: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const groups = computed<Group[]>(() => {
|
const groups = computed<Group[]>(() => {
|
||||||
@@ -52,13 +60,29 @@ const groups = computed<Group[]>(() => {
|
|||||||
name: session.key.replace(/^interactive:/, ''),
|
name: session.key.replace(/^interactive:/, ''),
|
||||||
session,
|
session,
|
||||||
})
|
})
|
||||||
|
const working = (sessions: ClawSession[]) =>
|
||||||
|
sessions.filter((session) => session.state === 'leased').length
|
||||||
const groups: Group[] = []
|
const groups: Group[] = []
|
||||||
if (interactive.length > 0)
|
if (interactive.length > 0)
|
||||||
groups.push({ label: 'interactive', rows: interactive.map(row) })
|
groups.push({
|
||||||
if (others.length > 0) groups.push({ label: 'other keys', rows: others.map(row) })
|
label: 'interactive',
|
||||||
|
rows: interactive.map(row),
|
||||||
|
working: working(interactive),
|
||||||
|
collapsible: false,
|
||||||
|
})
|
||||||
|
if (others.length > 0)
|
||||||
|
groups.push({
|
||||||
|
label: 'others',
|
||||||
|
rows: others.map(row),
|
||||||
|
working: working(others),
|
||||||
|
collapsible: true,
|
||||||
|
})
|
||||||
return groups
|
return groups
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/** Whether the others group is folded out; it starts folded. */
|
||||||
|
const othersOpen = ref(false)
|
||||||
|
|
||||||
const shownCount = computed(() =>
|
const shownCount = computed(() =>
|
||||||
groups.value.reduce((total, group) => total + group.rows.length, 0),
|
groups.value.reduce((total, group) => total + group.rows.length, 0),
|
||||||
)
|
)
|
||||||
@@ -159,7 +183,21 @@ watch(
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div v-for="group in groups" :key="group.label" class="group">
|
<div v-for="group in groups" :key="group.label" class="group">
|
||||||
|
<div class="group-head">
|
||||||
<span class="label">{{ group.label }}</span>
|
<span class="label">{{ group.label }}</span>
|
||||||
|
<span v-if="group.collapsible" class="working" :class="{ live: group.working > 0 }">
|
||||||
|
{{ group.working }} working
|
||||||
|
</span>
|
||||||
|
<button
|
||||||
|
v-if="group.collapsible"
|
||||||
|
class="ghost toggle"
|
||||||
|
:title="othersOpen ? 'fold the other keys away' : 'show every other key'"
|
||||||
|
@click="othersOpen = !othersOpen"
|
||||||
|
>
|
||||||
|
{{ othersOpen ? 'less' : 'more' }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<template v-if="!group.collapsible || othersOpen">
|
||||||
<div
|
<div
|
||||||
v-for="row in group.rows"
|
v-for="row in group.rows"
|
||||||
:key="row.key"
|
:key="row.key"
|
||||||
@@ -183,6 +221,7 @@ watch(
|
|||||||
×
|
×
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</aside>
|
</aside>
|
||||||
</template>
|
</template>
|
||||||
@@ -287,10 +326,32 @@ watch(
|
|||||||
margin-bottom: 14px;
|
margin-bottom: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.group .label {
|
.group-head {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
padding: 0 8px 4px;
|
padding: 0 8px 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.group-head .working {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
text-align: right;
|
||||||
|
font-family: var(--mono);
|
||||||
|
font-size: 11px;
|
||||||
|
color: var(--text3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.group-head .working.live {
|
||||||
|
color: var(--ok);
|
||||||
|
}
|
||||||
|
|
||||||
|
.group-head .toggle {
|
||||||
|
flex: none;
|
||||||
|
padding: 0 6px;
|
||||||
|
font-size: 11px;
|
||||||
|
}
|
||||||
|
|
||||||
/* The row owns the hover and active surface: the select button fills it
|
/* The row owns the hover and active surface: the select button fills it
|
||||||
and the delete button sits beside it, so neither has to nest in the
|
and the delete button sits beside it, so neither has to nest in the
|
||||||
other. */
|
other. */
|
||||||
|
|||||||
Reference in new issue
Block a user