80 lines
3.7 KiB
Vue
80 lines
3.7 KiB
Vue
<script setup lang="ts">
|
|
import { computed, onMounted, watch } from "vue";
|
|
|
|
import AccountEntry from "@/accounts/AccountEntry.vue";
|
|
import { useAccountsStore } from "@/accounts/accounts";
|
|
|
|
import ChatLauncher from "@/chat/ChatLauncher.vue";
|
|
import Topbar from "@/components/topbar/Topbar.vue";
|
|
import SettingsShell from "@/settings/SettingsShell.vue";
|
|
import { TooltipProvider } from "@/components/ui/tooltip";
|
|
import { hiddenPaths } from "@/lib/nav";
|
|
import { loadTaskMeta } from "@/lib/task-meta";
|
|
import { useSessionStore } from "@/stores/session";
|
|
|
|
const reauthenticate=new URLSearchParams(window.location.search).has("reauth");
|
|
const accounts=useAccountsStore();
|
|
const session = useSessionStore();
|
|
const hidden = computed(() => hiddenPaths(session.sections));
|
|
|
|
onMounted(() => {void accounts.load();});
|
|
watch(() => accounts.status?.user, (user) => {
|
|
if (!user || reauthenticate) return;
|
|
session.initialize();
|
|
// Asked for once, after the shell is up: the nav paints immediately and
|
|
// loses the entries this process cannot back a moment later, rather than
|
|
// holding the page behind a request. A failed read hides nothing.
|
|
void session.loadCapabilities();
|
|
|
|
// The lifecycle vocabulary -- status labels, pill severity, "needs you"
|
|
// grouping, and the operator actions -- is served by /api/task-meta. Asked
|
|
// for once, after the shell is up: the freeze-dried defaults paint
|
|
// immediately and this replaces them, so a catalogue change on the server
|
|
// reaches the browser without a UI release. loadTaskMeta never throws (a
|
|
// failed read keeps the defaults), so it needs no catch here.
|
|
void loadTaskMeta();
|
|
});
|
|
</script>
|
|
|
|
<template>
|
|
<div v-if="!accounts.status" class="mx-auto max-w-md p-8" role="status"><p>{{accounts.error||'Connecting to Archie…'}}</p><button v-if="accounts.error" class="mt-3 underline" @click="accounts.load">Retry</button></div>
|
|
<AccountEntry v-else-if="!accounts.status.user || accounts.status.setup_required || reauthenticate" />
|
|
<TooltipProvider v-else :delay-duration="350">
|
|
<!-- `backdrop-filter` makes this a containing block for `position: fixed`,
|
|
so the chat launcher has to render outside this element. -->
|
|
<div
|
|
class="flex min-h-screen flex-col overflow-clip bg-[var(--workspace)] backdrop-blur-[28px] backdrop-saturate-[1.2]"
|
|
>
|
|
<Topbar :hidden="hidden" />
|
|
<!-- `max-md:pb-24` keeps the page clear of the floating chat launcher,
|
|
which is pinned to the bottom right at phone width. -->
|
|
<main class="w-full flex-1 overflow-x-clip px-6 py-5 max-md:pb-24 max-lg:p-4">
|
|
<!--
|
|
Keyed on the path and its parameters but not the query: a query-only
|
|
change is an entry state, so the page keeps the operator's filters,
|
|
while two different :id values get fresh instances -- without that
|
|
the second id diffs the first one in place and the previous task's
|
|
open tab stays open on the next.
|
|
-->
|
|
<RouterView v-slot="{ Component, route }">
|
|
<SettingsShell v-if="route.meta.settings" scope="instance">
|
|
<component :is="Component" :key="route.path" />
|
|
</SettingsShell>
|
|
<SettingsShell v-else-if="route.meta.org" scope="org">
|
|
<component :is="Component" :key="route.path" />
|
|
</SettingsShell>
|
|
<component :is="Component" v-else :key="route.path" />
|
|
</RouterView>
|
|
</main>
|
|
</div>
|
|
|
|
<!--
|
|
Outside the shell on purpose: the frame above carries `backdrop-filter`,
|
|
which makes it a containing block for `position: fixed`, so a launcher
|
|
nested inside it would anchor to the shell rather than the viewport and
|
|
ride off the bottom of a long page.
|
|
-->
|
|
<ChatLauncher />
|
|
</TooltipProvider>
|
|
</template>
|