improved chat ui
This commit is contained in:
+26
-1
@@ -5,7 +5,8 @@ import { EmbedAuthWrapper } from './components/EmbedAuthWrapper';
|
||||
import { CriticalView } from './views/CriticalView';
|
||||
import { AuthCallback } from './components/Auth';
|
||||
import { pb } from './lib/pocketbase';
|
||||
import { initStore, setStore } from './store';
|
||||
import { initStore, setStore, store, appendAIHelpTipHistory } from './store';
|
||||
import { generateAIHelpTip, hasFireworksApiKey } from './lib/ai-help';
|
||||
|
||||
// const CriticalView = lazy(() => import('./views/CriticalView').then(m => ({ default: m.CriticalView })));
|
||||
const UrgencyView = lazy(() => import('./views/UrgencyView').then(m => ({ default: m.UrgencyView })));
|
||||
@@ -27,6 +28,8 @@ const App: Component = () => {
|
||||
const [isAuthenticated, setIsAuthenticated] = createSignal(pb.authStore.isValid);
|
||||
const [location, setLocation] = createSignal(window.location.href);
|
||||
const [isDesktop, setIsDesktop] = createSignal(window.matchMedia("(min-width: 768px)").matches);
|
||||
const [aiHelpTip, setAiHelpTip] = createSignal<string | null>(null);
|
||||
const [hasRequestedSessionTip, setHasRequestedSessionTip] = createSignal(false);
|
||||
|
||||
createEffect(() => {
|
||||
const view = currentView();
|
||||
@@ -39,6 +42,25 @@ const App: Component = () => {
|
||||
currentView() === "help_ai" && isDesktop() ? lastNonAIView() : currentView()
|
||||
);
|
||||
|
||||
createEffect(() => {
|
||||
const ready = isAuthenticated() && isDesktop() && !store.isInitializing;
|
||||
if (!ready) return;
|
||||
if (!hasFireworksApiKey()) return;
|
||||
if (hasRequestedSessionTip()) return;
|
||||
|
||||
setHasRequestedSessionTip(true);
|
||||
void (async () => {
|
||||
try {
|
||||
const nextTip = await generateAIHelpTip(store.aiHelpTipHistory);
|
||||
if (!nextTip) return;
|
||||
setAiHelpTip(nextTip);
|
||||
await appendAIHelpTipHistory(nextTip);
|
||||
} catch (err) {
|
||||
console.error("Failed to generate AI help tip", err);
|
||||
}
|
||||
})();
|
||||
});
|
||||
|
||||
onMount(() => {
|
||||
const mediaQuery = window.matchMedia("(min-width: 768px)");
|
||||
const openHelpGuide = (sectionId?: string) => {
|
||||
@@ -81,6 +103,8 @@ const App: Component = () => {
|
||||
const removeListener = pb.authStore.onChange((token) => {
|
||||
const wasAuthenticated = isAuthenticated();
|
||||
setIsAuthenticated(!!token);
|
||||
setHasRequestedSessionTip(false);
|
||||
setAiHelpTip(null);
|
||||
|
||||
if (token && (isFirstRun || !wasAuthenticated)) {
|
||||
initStore();
|
||||
@@ -155,6 +179,7 @@ const App: Component = () => {
|
||||
setView={setCurrentView}
|
||||
isAIHelpOpen={currentView() === "help_ai" && isDesktop()}
|
||||
onToggleAIHelp={() => setCurrentView(currentView() === "help_ai" ? lastNonAIView() : "help_ai")}
|
||||
aiHelpTip={aiHelpTip()}
|
||||
hideQuickEntry={currentView() === "help_ai" && !isDesktop()}
|
||||
>
|
||||
<Suspense fallback={<div class="flex items-center justify-center h-full"><div class="animate-spin rounded-full h-8 w-8 border-b-2 border-primary"></div></div>}>
|
||||
|
||||
Reference in New Issue
Block a user