feat(webui): make attempts a pager above the tabs
The attempt selector becomes an icon-ended pager from the registry pagination primitive: chevrons walk run history, numbers land on an attempt, and the active page is the attempt on screen. It sits top-right above the tab card, and the meta line loses the attempt text fact since the control now carries it.
This commit is contained in:
14 files changed
+348
-49
No files matched your search
@@ -85,9 +85,8 @@ automatically and note it in the handoff.
|
||||
|
||||
Commands are defined in `Taskfile.yml` (requires Go 1.27.0,
|
||||
[Task](https://taskfile.dev), `gofumpt`, `golangci-lint`, and Node/npm).
|
||||
Install the versions pinned in `Dockerfile`, never `@latest`. `golangci-lint`
|
||||
is the single writer for ordinary Go formatting; standalone `gofumpt` formats
|
||||
generated protobuf contracts only.
|
||||
`golangci-lint` is the single writer for ordinary Go formatting; standalone
|
||||
`gofumpt` formats generated protobuf contracts only.
|
||||
|
||||
```bash
|
||||
task build # build archied and archie-agent binaries into bin/
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<script setup lang="ts">
|
||||
import type { PaginationRootEmits, PaginationRootProps } from 'reka-ui'
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { reactiveOmit } from '@vueuse/core'
|
||||
import { PaginationRoot, useForwardPropsEmits } from 'reka-ui'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = defineProps<PaginationRootProps & {
|
||||
class?: HTMLAttributes['class']
|
||||
}>()
|
||||
const emits = defineEmits<PaginationRootEmits>()
|
||||
|
||||
const delegatedProps = reactiveOmit(props, 'class')
|
||||
const forwarded = useForwardPropsEmits(delegatedProps, emits)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<PaginationRoot
|
||||
v-slot="slotProps"
|
||||
data-slot="pagination"
|
||||
v-bind="forwarded"
|
||||
:class="cn('mx-auto flex w-full justify-center', props.class)"
|
||||
>
|
||||
<slot v-bind="slotProps" />
|
||||
</PaginationRoot>
|
||||
</template>
|
||||
@@ -0,0 +1,22 @@
|
||||
<script setup lang="ts">
|
||||
import type { PaginationListProps } from 'reka-ui'
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { reactiveOmit } from '@vueuse/core'
|
||||
import { PaginationList } from 'reka-ui'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = defineProps<PaginationListProps & { class?: HTMLAttributes['class'] }>()
|
||||
|
||||
const delegatedProps = reactiveOmit(props, 'class')
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<PaginationList
|
||||
v-slot="slotProps"
|
||||
data-slot="pagination-content"
|
||||
v-bind="delegatedProps"
|
||||
:class="cn('gap-0.5 flex items-center', props.class)"
|
||||
>
|
||||
<slot v-bind="slotProps" />
|
||||
</PaginationList>
|
||||
</template>
|
||||
@@ -0,0 +1,26 @@
|
||||
<script setup lang="ts">
|
||||
import type { PaginationEllipsisProps } from 'reka-ui'
|
||||
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { MoreHorizontalIcon } from '@lucide/vue'
|
||||
import { reactiveOmit } from '@vueuse/core'
|
||||
import { PaginationEllipsis } from 'reka-ui'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = defineProps<PaginationEllipsisProps & { class?: HTMLAttributes['class'] }>()
|
||||
|
||||
const delegatedProps = reactiveOmit(props, 'class')
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<PaginationEllipsis
|
||||
data-slot="pagination-ellipsis"
|
||||
v-bind="delegatedProps"
|
||||
:class="cn('size-8 [&_svg:not([class*=size-])]:size-4 flex items-center justify-center', props.class)"
|
||||
>
|
||||
<slot>
|
||||
<MoreHorizontalIcon />
|
||||
<span class="sr-only">More pages</span>
|
||||
</slot>
|
||||
</PaginationEllipsis>
|
||||
</template>
|
||||
@@ -0,0 +1,34 @@
|
||||
<script setup lang="ts">
|
||||
import type { PaginationFirstProps } from 'reka-ui'
|
||||
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import type { ButtonVariants } from '@/components/ui/button'
|
||||
import { ChevronsLeftIcon } from '@lucide/vue'
|
||||
import { reactiveOmit } from '@vueuse/core'
|
||||
import { PaginationFirst, useForwardProps } from 'reka-ui'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { buttonVariants } from '@/components/ui/button'
|
||||
|
||||
const props = withDefaults(defineProps<PaginationFirstProps & {
|
||||
size?: ButtonVariants['size']
|
||||
class?: HTMLAttributes['class']
|
||||
}>(), {
|
||||
size: 'default',
|
||||
})
|
||||
|
||||
const delegatedProps = reactiveOmit(props, 'class', 'size')
|
||||
const forwarded = useForwardProps(delegatedProps)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<PaginationFirst
|
||||
data-slot="pagination-first"
|
||||
:class="cn(buttonVariants({ variant: 'ghost', size }), '', props.class)"
|
||||
v-bind="forwarded"
|
||||
>
|
||||
<slot>
|
||||
<ChevronsLeftIcon data-icon="inline-start" />
|
||||
<span class="hidden sm:block">First</span>
|
||||
</slot>
|
||||
</PaginationFirst>
|
||||
</template>
|
||||
@@ -0,0 +1,34 @@
|
||||
<script setup lang="ts">
|
||||
import type { PaginationListItemProps } from 'reka-ui'
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import type { ButtonVariants } from '@/components/ui/button'
|
||||
import { reactiveOmit } from '@vueuse/core'
|
||||
import { PaginationListItem } from 'reka-ui'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { buttonVariants } from '@/components/ui/button'
|
||||
|
||||
const props = withDefaults(defineProps<PaginationListItemProps & {
|
||||
size?: ButtonVariants['size']
|
||||
class?: HTMLAttributes['class']
|
||||
isActive?: boolean
|
||||
}>(), {
|
||||
size: 'icon',
|
||||
})
|
||||
|
||||
const delegatedProps = reactiveOmit(props, 'class', 'size', 'isActive')
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<PaginationListItem
|
||||
data-slot="pagination-item"
|
||||
v-bind="delegatedProps"
|
||||
:class="cn(
|
||||
buttonVariants({
|
||||
variant: isActive ? 'outline' : 'ghost',
|
||||
size,
|
||||
}),
|
||||
props.class)"
|
||||
>
|
||||
<slot />
|
||||
</PaginationListItem>
|
||||
</template>
|
||||
@@ -0,0 +1,34 @@
|
||||
<script setup lang="ts">
|
||||
import type { PaginationLastProps } from 'reka-ui'
|
||||
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import type { ButtonVariants } from '@/components/ui/button'
|
||||
import { ChevronsRightIcon } from '@lucide/vue'
|
||||
import { reactiveOmit } from '@vueuse/core'
|
||||
import { PaginationLast, useForwardProps } from 'reka-ui'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { buttonVariants } from '@/components/ui/button'
|
||||
|
||||
const props = withDefaults(defineProps<PaginationLastProps & {
|
||||
size?: ButtonVariants['size']
|
||||
class?: HTMLAttributes['class']
|
||||
}>(), {
|
||||
size: 'default',
|
||||
})
|
||||
|
||||
const delegatedProps = reactiveOmit(props, 'class', 'size')
|
||||
const forwarded = useForwardProps(delegatedProps)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<PaginationLast
|
||||
data-slot="pagination-last"
|
||||
:class="cn(buttonVariants({ variant: 'ghost', size }), '', props.class)"
|
||||
v-bind="forwarded"
|
||||
>
|
||||
<slot>
|
||||
<span class="hidden sm:block">Last</span>
|
||||
<ChevronsRightIcon data-icon="inline-end" />
|
||||
</slot>
|
||||
</PaginationLast>
|
||||
</template>
|
||||
@@ -0,0 +1,35 @@
|
||||
<script setup lang="ts">
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import type { ButtonVariants } from '@/components/ui/button'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { buttonVariants } from '@/components/ui/button'
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
href?: string
|
||||
size?: ButtonVariants['size']
|
||||
isActive?: boolean
|
||||
class?: HTMLAttributes['class']
|
||||
}>(), {
|
||||
size: 'icon',
|
||||
isActive: false,
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<a
|
||||
:href="href"
|
||||
data-slot="pagination-link"
|
||||
:data-active="isActive ? '' : undefined"
|
||||
:aria-current="isActive ? 'page' : undefined"
|
||||
:class="cn(
|
||||
buttonVariants({
|
||||
variant: isActive ? 'outline' : 'ghost',
|
||||
size,
|
||||
}),
|
||||
'',
|
||||
props.class,
|
||||
)"
|
||||
>
|
||||
<slot />
|
||||
</a>
|
||||
</template>
|
||||
@@ -0,0 +1,34 @@
|
||||
<script setup lang="ts">
|
||||
import type { PaginationNextProps } from 'reka-ui'
|
||||
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import type { ButtonVariants } from '@/components/ui/button'
|
||||
import { ChevronRightIcon } from '@lucide/vue'
|
||||
import { reactiveOmit } from '@vueuse/core'
|
||||
import { PaginationNext, useForwardProps } from 'reka-ui'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { buttonVariants } from '@/components/ui/button'
|
||||
|
||||
const props = withDefaults(defineProps<PaginationNextProps & {
|
||||
size?: ButtonVariants['size']
|
||||
class?: HTMLAttributes['class']
|
||||
}>(), {
|
||||
size: 'default',
|
||||
})
|
||||
|
||||
const delegatedProps = reactiveOmit(props, 'class', 'size')
|
||||
const forwarded = useForwardProps(delegatedProps)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<PaginationNext
|
||||
data-slot="pagination-next"
|
||||
:class="cn(buttonVariants({ variant: 'ghost', size }), 'pr-1.5!', props.class)"
|
||||
v-bind="forwarded"
|
||||
>
|
||||
<slot>
|
||||
<ChevronRightIcon data-icon="inline-start" class="cn-rtl-flip" />
|
||||
<span class="sr-only">Next attempt</span>
|
||||
</slot>
|
||||
</PaginationNext>
|
||||
</template>
|
||||
@@ -0,0 +1,34 @@
|
||||
<script setup lang="ts">
|
||||
import type { PaginationPrevProps } from 'reka-ui'
|
||||
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import type { ButtonVariants } from '@/components/ui/button'
|
||||
import { ChevronLeftIcon } from '@lucide/vue'
|
||||
import { reactiveOmit } from '@vueuse/core'
|
||||
import { PaginationPrev, useForwardProps } from 'reka-ui'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { buttonVariants } from '@/components/ui/button'
|
||||
|
||||
const props = withDefaults(defineProps<PaginationPrevProps & {
|
||||
size?: ButtonVariants['size']
|
||||
class?: HTMLAttributes['class']
|
||||
}>(), {
|
||||
size: 'default',
|
||||
})
|
||||
|
||||
const delegatedProps = reactiveOmit(props, 'class', 'size')
|
||||
const forwarded = useForwardProps(delegatedProps)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<PaginationPrev
|
||||
data-slot="pagination-previous"
|
||||
:class="cn(buttonVariants({ variant: 'ghost', size }), 'pl-1.5!', props.class)"
|
||||
v-bind="forwarded"
|
||||
>
|
||||
<slot>
|
||||
<ChevronLeftIcon data-icon="inline-start" class="cn-rtl-flip" />
|
||||
<span class="sr-only">Previous attempt</span>
|
||||
</slot>
|
||||
</PaginationPrev>
|
||||
</template>
|
||||
@@ -0,0 +1,9 @@
|
||||
export { default as Pagination } from './Pagination.vue'
|
||||
export { default as PaginationContent } from './PaginationContent.vue'
|
||||
export { default as PaginationEllipsis } from './PaginationEllipsis.vue'
|
||||
export { default as PaginationFirst } from './PaginationFirst.vue'
|
||||
export { default as PaginationItem } from './PaginationItem.vue'
|
||||
export { default as PaginationLast } from './PaginationLast.vue'
|
||||
export { default as PaginationLink } from './PaginationLink.vue'
|
||||
export { default as PaginationNext } from './PaginationNext.vue'
|
||||
export { default as PaginationPrevious } from './PaginationPrevious.vue'
|
||||
@@ -1,57 +1,74 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from "vue";
|
||||
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group";
|
||||
import {
|
||||
Pagination,
|
||||
PaginationContent,
|
||||
PaginationEllipsis,
|
||||
PaginationItem,
|
||||
PaginationNext,
|
||||
PaginationPrevious,
|
||||
} from "@/components/ui/pagination";
|
||||
|
||||
import { stageStatusMeta } from "./stage-rail";
|
||||
import { useTaskRun } from "./use-task-run";
|
||||
|
||||
/**
|
||||
* The attempts of this task, each a pill carrying its own status and stage
|
||||
* count. Selection is the page's, and the stage rail reads the same response,
|
||||
* so the two views of the same task's attempts can never disagree about which
|
||||
* one is on screen.
|
||||
* The attempts of this task as a pager, sitting above the tab card: chevrons
|
||||
* walk run history, the numbers land on an attempt directly, and the attempt
|
||||
* on screen reads as the active page. Selection is the page's, and the stage
|
||||
* rail reads the same response, so the two views of the same task's attempts
|
||||
* can never disagree about which one is on screen.
|
||||
*
|
||||
* One attempt renders the rail anyway, disabled: the control states "there is
|
||||
* exactly one run" by being inert rather than by disappearing, which is what
|
||||
* the old text fact ("attempt 1 of 1") said without saying it as navigation.
|
||||
*/
|
||||
const run = useTaskRun();
|
||||
|
||||
const attempts = computed(() => run.attempts?.attempts ?? []);
|
||||
const selected = computed(() => (run.attemptNumber == null ? "" : String(run.attemptNumber)));
|
||||
const selected = computed(() =>
|
||||
attempts.value.findIndex((a) => Number(a.attempt) === Number(run.attemptNumber)),
|
||||
);
|
||||
|
||||
function select(value: unknown): void {
|
||||
// Re-pressing the selected attempt deselects it (a single-typed group answers
|
||||
// ""), which is not an attempt: keep the selection rather than moving to
|
||||
// none.
|
||||
const n = Number(value);
|
||||
if (Number.isInteger(n) && n > 0) run.selectAttempt(n);
|
||||
}
|
||||
// reka's pagination counts pages over items; one attempt per page makes the
|
||||
// page number an index into the run history. The controlled page keeps the
|
||||
// URL (`?attempt=N`) the single source of truth.
|
||||
const page = computed(() => (selected.value >= 0 ? selected.value + 1 : undefined));
|
||||
|
||||
function stageCount(attempt: { stages?: unknown[] }): string {
|
||||
const n = (attempt.stages || []).length;
|
||||
return `${n} stage${n === 1 ? "" : "s"}`;
|
||||
function select(p: number): void {
|
||||
const attempt = attempts.value[p - 1];
|
||||
if (attempt) run.selectAttempt(Number(attempt.attempt));
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ToggleGroup
|
||||
v-if="attempts.length"
|
||||
type="single"
|
||||
variant="outline"
|
||||
:spacing="2"
|
||||
:model-value="selected"
|
||||
<Pagination
|
||||
v-if="attempts.length && selected >= 0"
|
||||
:items-per-page="1"
|
||||
:total="attempts.length"
|
||||
:page="page"
|
||||
:sibling-count="1"
|
||||
aria-label="Attempts of this task"
|
||||
class="mb-4 flex-wrap"
|
||||
@update:model-value="select"
|
||||
class="mx-0"
|
||||
@update:page="select"
|
||||
>
|
||||
<ToggleGroupItem
|
||||
v-for="attempt in attempts"
|
||||
:key="attempt.attempt"
|
||||
:value="String(attempt.attempt)"
|
||||
class="gap-2 rounded-full px-3"
|
||||
>
|
||||
<span class="font-medium">Attempt {{ attempt.attempt }}</span>
|
||||
<Badge :variant="stageStatusMeta(attempt.status).kind">{{ stageStatusMeta(attempt.status).label }}</Badge>
|
||||
<span class="text-xs text-fg-muted">{{ stageCount(attempt) }}</span>
|
||||
</ToggleGroupItem>
|
||||
</ToggleGroup>
|
||||
</template>
|
||||
<PaginationContent>
|
||||
<PaginationPrevious size="icon-sm" class="border-transparent" />
|
||||
<PaginationList v-slot="{ items }">
|
||||
<template v-for="(item, i) in items" :key="i">
|
||||
<PaginationEllipsis v-if="item.type === 'ellipsis'" :index="i" />
|
||||
<PaginationItem
|
||||
v-else
|
||||
:value="item.value"
|
||||
:is-active="item.value === page"
|
||||
size="icon-sm"
|
||||
:title="`Attempt ${attempts[item.value - 1]?.attempt}`"
|
||||
>
|
||||
{{ item.value }}
|
||||
</PaginationItem>
|
||||
</template>
|
||||
</PaginationList>
|
||||
<PaginationNext size="icon-sm" class="border-transparent" />
|
||||
</PaginationContent>
|
||||
</Pagination>
|
||||
</template>
|
||||
@@ -49,6 +49,9 @@ const run = provideTaskRun(taskId);
|
||||
|
||||
<Card>
|
||||
<CardContent>
|
||||
<div class="mb-2 flex justify-end">
|
||||
<AttemptSelector />
|
||||
</div>
|
||||
<Tabs class="gap-4" :model-value="run.tab" @update:model-value="run.setTab">
|
||||
<TabBar />
|
||||
<TaskRunPanels :id="rawId" />
|
||||
|
||||
@@ -22,13 +22,6 @@ const run = useTaskRun();
|
||||
// the Badge draws, which is what makes the cast honest rather than a guess.
|
||||
const taskKind = computed<StatusKind>(() => statusKind(run.task?.status ?? "") as StatusKind);
|
||||
const taskStatusLabel = computed(() => statusLabel(run.task?.status ?? ""));
|
||||
|
||||
const attemptText = computed(() => {
|
||||
if (run.attempts === null) return "";
|
||||
if (run.attempts === undefined) return "";
|
||||
if (run.attemptNumber == null) return "";
|
||||
return `attempt ${run.attemptNumber} of ${run.currentAttempt ?? run.attemptNumber}`;
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -37,7 +30,6 @@ const attemptText = computed(() => {
|
||||
<template v-else-if="run.task">
|
||||
<Badge :variant="taskKind">{{ taskStatusLabel }}</Badge>
|
||||
</template>
|
||||
<span v-if="attemptText" class="text-fg-muted">{{ attemptText }}</span>
|
||||
<a
|
||||
v-if="run.task?.repo_url"
|
||||
class="text-link hover:underline"
|
||||
|
||||
Reference in new issue
Block a user