Files
archie/ui/src/chat/ChatNavChip.vue
T

36 lines
1.5 KiB
Vue

<script setup lang="ts">
import { ArrowUpRight } from "@lucide/vue";
import { computed } from "vue";
import { useRouter } from "vue-router";
/**
* A dashboard_navigate result: a clickable chip that routes the operator to a
* dashboard page. It is an action, not evidence, so it is styled as a button
* rather than a muted log line, and it visibly invites a click. It is the only
* clickable navigation surface in the transcript.
*
* A RouterLink rather than a `#/path` anchor: history routing means the server
* stores bare paths, and an anchor would reload the whole app to change one
* segment.
*
* The server only checks that the path stays on the dashboard, so a path no
* route serves shows as plain text instead of a link to the not-found page.
*/
const props = defineProps<{ path: string; label?: string }>();
const router = useRouter();
const known = computed(() => router.resolve(props.path).name !== "not-found");
</script>
<template>
<RouterLink
v-if="known"
:to="path"
:title="`Go to ${label || path}`"
class="inline-flex max-w-full items-center gap-1.5 rounded-md border border-primary/45 bg-primary-soft px-2.5 py-1 text-caption font-semibold text-link transition-colors hover:border-primary hover:bg-primary/15 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary"
>
<ArrowUpRight aria-hidden="true" class="size-3.5 shrink-0" />
<span class="truncate">{{ label || path }}</span>
</RouterLink>
<span v-else class="text-caption text-muted-foreground">{{ label || path }}</span>
</template>