Skip to content

Agent Zero AI framework

projects, contexts continued

frdel1f37bcd844d2
diff --git a/python/helpers/task_scheduler.py b/python/helpers/task_scheduler.py
index 9bfabcece..819ee6058 100644
--- a/python/helpers/task_scheduler.py
+++ b/python/helpers/task_scheduler.py
@@ -776,6 +776,7 @@ class TaskScheduler:
self._printer.print(f"Scheduler Task '{current_task.name}' started")
context = await self._get_chat_context(current_task)
+ AgentContext.use(context.id)
# Ensure the context is properly registered in the AgentContext._contexts
# This is critical for the polling mechanism to find and stream logs
diff --git a/webui/components/projects/project-create.html b/webui/components/projects/project-create.html
index 93137d6d9..caab8194a 100644
--- a/webui/components/projects/project-create.html
+++ b/webui/components/projects/project-create.html
@@ -3,7 +3,7 @@
<head>
<title>Create a new project</title>
<script type="module">
- import { store } from "/components/projects/projectsStore.js";
+ import { store } from "/components/projects/projects-store.js";
</script>
</head>
diff --git a/webui/components/projects/project-edit-basic-data.html b/webui/components/projects/project-edit-basic-data.html
index 1e7423a8f..c84b1ddfb 100644
--- a/webui/components/projects/project-edit-basic-data.html
+++ b/webui/components/projects/project-edit-basic-data.html
@@ -3,7 +3,7 @@
<head>
<title>Project basic data</title>
<script type="module">
- import { store } from "/components/projects/projectsStore.js";
+ import { store } from "/components/projects/projects-store.js";
</script>
</head>
diff --git a/webui/components/projects/project-edit-instructions.html b/webui/components/projects/project-edit-instructions.html
index d3accb760..f91cfb70c 100644
--- a/webui/components/projects/project-edit-instructions.html
+++ b/webui/components/projects/project-edit-instructions.html
@@ -3,7 +3,7 @@
<head>
<title>Create a new project</title>
<script type="module">
- import { store } from "/components/projects/projectsStore.js";
+ import { store } from "/components/projects/projects-store.js";
</script>
</head>
diff --git a/webui/components/projects/project-edit-memory.html b/webui/components/projects/project-edit-memory.html
new file mode 100644
index 000000000..2e8bacbdf
--- /dev/null
+++ b/webui/components/projects/project-edit-memory.html
@@ -0,0 +1,60 @@
+<html>
+
+<head>
+ <title>Create a new project</title>
+ <script type="module">
+ import { store } from "/components/projects/projects-store.js";
+ </script>
+</head>
+
+<body>
+ <div x-data>
+ <template x-if="$store.projects && $store.projects.selectedProject">
+ <div>
+
+ <div class="projects-setting-row" style="padding: 1rem 0;">
+ <div class="projects-setting-text">
+ <label class="projects-form-label">Project-specific memory</label>
+ <span class="projects-form-description">When turned on, the agent's memory while working on this
+ project will be isolated from the global memory. The memory will be stored in <strong><span
+ x-text="$store.projects.getSelectedAbsPath('.a0proj','memory')"></span></strong>.</span>
+ </div>
+ <div class="projects-setting-control">
+ <label class="toggle">
+ <input type="checkbox" x-model="$store.projects.selectedProject._ownMemory">
+ <span class="toggler"></span>
+ </label>
+ </div>
+ </div>
+
+ <style>
+ .projects-setting-row {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 2rem;
+ }
+ .projects-setting-text {
+ flex-grow: 1;
+ flex-shrink: 1;
+ min-width: 0;
+ }
+ .projects-setting-control {
+ flex-grow: 0;
+ flex-shrink: 0;
+ }
+ .projects-form-label {
+ display: block;
+ }
+ </style>
+
+ </div>
+
+
+ </template>
+ </div>
+</body>
+<style>
+</style>
+
+</html>
\ No newline at end of file
diff --git a/webui/components/projects/project-edit-secrets.html b/webui/components/projects/project-edit-secrets.html
index 76c066750..49409c618 100644
--- a/webui/components/projects/project-edit-secrets.html
+++ b/webui/components/projects/project-edit-secrets.html
@@ -3,7 +3,7 @@
<head>
<title>Create a new project</title>
<script type="module">
- import { store } from "/components/projects/projectsStore.js";
+ import { store } from "/components/projects/projects-store.js";
</script>
</head>
diff --git a/webui/components/projects/project-edit.html b/webui/components/projects/project-edit.html
index 69dd47264..871c576b6 100644
--- a/webui/components/projects/project-edit.html
+++ b/webui/components/projects/project-edit.html
@@ -3,7 +3,7 @@
<head>
<title>Edit project</title>
<script type="module">
- import { store } from "/components/projects/projectsStore.js";
+ import { store } from "/components/projects/projects-store.js";
</script>
</head>
@@ -42,6 +42,14 @@
</x-component>
</div>
+ <div class="project-detail">
+ <div class="project-detail-header">
+ <span class="projects-project-card-title">Memory</span>
+ </div>
+ <x-component path="projects/project-edit-memory.html">
+ </x-component>
+ </div>
+
<div class="project-detail">
<div class="project-detail-header">
<span class="projects-project-card-title">Secrets</span>
diff --git a/webui/components/projects/project-list.html b/webui/components/projects/project-list.html
index 4e24ad105..663e31148 100644
--- a/webui/components/projects/project-list.html
+++ b/webui/components/projects/project-list.html
@@ -3,7 +3,7 @@
<head>
<title>Projects</title>
<script type="module">
- import { store as projectsStore } from "/components/projects/projectsStore.js";
+ import { store as projectsStore } from "/components/projects/projects-store.js";
import { store as chatsStore } from "/components/sidebar/chats/chats-store.js";
</script>
</head>
@@ -16,7 +16,7 @@
instructions and files.
You can create projects for your tasks and switch between them easily.</p>
<div class="projects-list-header">
- <div x-show="$store.chats.selectedContext?.project" class="active-project-display">
+ <div x-show="$store.chats.selectedContext && $store.chats.selectedContext?.project" class="active-project-display">
<span style="display: inline-flex; align-items: center; gap: 0.5em;">
<span>Active:</span>
<span class="project-color-ball" :style="$store.chats.selectedContext?.project?.color ? { backgroundColor: $store.chats.selectedContext?.project?.color } : { border: '1px solid var(--color-border)' }"></span>
@@ -46,12 +46,12 @@
<div class="projects-project-card-name">/<span x-text="project.name"></span></div>
</div>
<div class="projects-project-card-actions" style="display: flex; gap: 0.5em;">
- <template x-if="project.name === $store.chats.selectedContext?.project?.name">
+ <template x-if="$store.chats.selectedContext && project.name === $store.chats.selectedContext?.project?.name">
<button type="button" class="button cancel" title="Deactivate" style="width:9em" @click="$store.projects.deactivateProject()">
<span class="icon material-symbols-outlined">close</span> Deactivate
</button>
</template>
- <template x-if="project.name !== $store.chats.selectedContext?.project?.name">
+ <template x-if="$store.chats.selectedContext && project.name !== $store.chats.selectedContext?.project?.name">
<button type="button" class="button confirm" title="Activate" style="width:9em" @click="$store.projects.activateProject(project.name)">
<span class="icon material-symbols-outlined">play_arrow</span> Activate
</button>
diff --git a/webui/components/projects/project-selector.html b/webui/components/projects/project-selector.html
index deea9cb3a..c1b8eb3d7 100644
--- a/webui/components/projects/project-selector.html
+++ b/webui/components/projects/project-selector.html
@@ -2,22 +2,22 @@
<head>
<script type="module">
- import { store as projectsStore } from "/components/projects/projectsStore.js";
+ import { store as projectsStore } from "/components/projects/projects-store.js";
import { store as chatsStore } from "/components/sidebar/chats/chats-store.js";
</script>
</head>
<body>
<div x-data>
- <template x-if="$store.projects && $store.chats">
+ <template x-if="$store.projects && $store.chats && $store.chats.selectedContext">
<div>
- <template x-if="$store.chats.selectedContext?.project?.name">
+ <template x-if="$store.chats.selectedContext.project?.name">
<button @click="$store.projects.openProjectsModal()" type="button" class="button project-button">
<span class="project-color-ball" :style="$store.chats.selectedContext.project.color ? { backgroundColor: $store.chats.selectedContext.project.color } : { border: '1px solid var(--color-border)' }"></span>
- <span x-text="$store.chats.selectedContext?.project?.name"></span>
+ <span x-text="$store.chats.selectedContext.project.name"></span>
</button>
</template>
- <template x-if="!$store.chats.selectedContext?.project?.name">
+ <template x-if="!$store.chats.selectedContext.project?.name">
<button @click="$store.projects.openProjectsModal()" type="button" class="button project-button">
No project</button>
</template>
diff --git a/webui/components/projects/projectsStore.js b/webui/components/projects/projects-store.js
similarity index 97%
rename from webui/components/projects/projectsStore.js
rename to webui/components/projects/projects-store.js
index 9978c8ae3..420fc21e7 100644
--- a/webui/components/projects/projectsStore.js
+++ b/webui/components/projects/projects-store.js
@@ -228,8 +228,12 @@ const model = {
// prepare data
const data = {
...this.selectedProject,
- _meta: undefined,
+ memory: this.selectedProject._ownMemory ? "own" : "global",
};
+ // remove internal fields
+ for (const kvp of Object.entries(data))
+ if (kvp[0].startsWith("_")) delete data[kvp[0]];
+
// call backend
const response = await api.callJsonApi("projects", {
action: creating ? "create" : "update",
@@ -276,6 +280,7 @@ const model = {
_meta: {
creating: true,
},
+ _ownMemory: true,
name: ``,
title: `Project #${this.projectList.length + 1}`,
description: "",
@@ -295,6 +300,7 @@ const model = {
creating: false,
},
...projectData,
+ _ownMemory: projectData.memory == "own",
};
},
diff --git a/webui/components/sidebar/chats/chats-store.js b/webui/components/sidebar/chats/chats-store.js
index 72b09556a..e92daff1b 100644
--- a/webui/components/sidebar/chats/chats-store.js
+++ b/webui/components/sidebar/chats/chats-store.js
@@ -26,7 +26,8 @@ const model = {
// Initialize from localStorage
const lastSelectedChat = localStorage.getItem("lastSelectedChat");
if (lastSelectedChat) {
- this.selected = lastSelectedChat;
+ this.selectChat(lastSelectedChat);
+ // this.selected = lastSelectedChat;
}
},
@@ -107,7 +108,8 @@ const model = {
await this.selectChat(alternateChat.id);
} else {
// If no other chats, create a new empty context
- await this.newChat();
+ this.deselectChat();
+ //await this.newChat();
}
},
@@ -158,6 +160,10 @@ const model = {
}
},
+ deselectChat(){
+ globalThis.deselectChat(); //TODO move here
+ },
+
// Smoothly scroll the chats list to top if present
_scrollChatsToTop() {
const listEl = document.querySelector('#chats-section .chats-config-list');
diff --git a/webui/components/welcome/welcome-screen.html b/webui/components/welcome/welcome-screen.html
index f262a8419..039dcb251 100644
--- a/webui/components/welcome/welcome-screen.html
+++ b/webui/components/welcome/welcome-screen.html
@@ -1,241 +1,241 @@
<html>
- <head>
- <script type="module">
- import { store } from "/components/welcome/welcome-store.js";
- </script>
- </head>
- <body>
- <div x-data x-show="$store.welcomeStore && $store.welcomeStore.isVisible">
- <template x-if="$store.welcomeStore">
- <div x-data="$store.welcomeStore" class="welcome-container">
- <!-- Agent Zero Logo -->
- <div class="welcome-logo-container">
- <img
- src="./public/darkSymbol.svg"
- alt="Agent Zero Logo"
- class="welcome-logo"
- />
+
+<head>
+ <script type="module">
+ import { store } from "/components/welcome/welcome-store.js";
+ </script>
+</head>
+
+<body>
+ <div x-data x-show="$store.welcomeStore && $store.welcomeStore.isVisible">
+ <template x-if="$store.welcomeStore">
+ <div x-data="$store.welcomeStore" class="welcome-container">
+ <!-- Agent Zero Logo -->
+ <div class="welcome-logo-container">
+ <img src="./public/darkSymbol.svg" alt="Agent Zero Logo" class="welcome-logo" />
+ </div>
+
+ <!-- Welcome Title -->
+ <h1 class="welcome-title">Welcome to Agent Zero</h1>
+ <p class="welcome-subtitle">
+ Start a new conversation or explore the features below.
+ </p>
+
+ <!-- Action Cards -->
+ <div class="welcome-actions">
+ <div class="welcome-action-card" @click="executeAction('new-chat')">
+ <span class="material-symbols-outlined welcome-action-icon">add_circle</span>
+ <h3 class="welcome-action-title">New Chat</h3>
+ <p class="welcome-action-description">
+ Start a new conversation
+ </p>
</div>
- <!-- Welcome Title -->
- <h1 class="welcome-title">Welcome to Agent Zero</h1>
- <p class="welcome-subtitle">
- Start a new conversation or explore the features below.
- </p>
-
- <!-- Action Cards -->
- <div class="welcome-actions">
- <div
- class="welcome-action-card"
- @click="executeAction('new-chat')"
- >
- <span
- class="material-symbols-outlined welcome-action-icon"
- >add_circle</span
- >
- <h3 class="welcome-action-title">New Chat</h3>
- <p class="welcome-action-description">
- Start a new conversation
- </p>
- </div>
- <div
- class="welcome-action-card"
- @click="executeAction('settings')"
- >
- <span
- class="material-symbols-outlined welcome-action-icon"
- >settings</span
- >
- <h3 class="welcome-action-title">Settings</h3>
- <p class="welcome-action-description">
- Configure Agent Zero
- </p>
- </div>
- <div
- class="welcome-action-card"
- @click="executeAction('website')"
- >
- <span
- class="material-symbols-outlined welcome-action-icon"
- >language</span
- >
- <h3 class="welcome-action-title">Visit Website</h3>
- <p class="welcome-action-description">
- Learn more about Agent Zero
- </p>
- </div>
- <div
- class="welcome-action-card"
- @click="executeAction('github')"
- >
- <span
- class="material-symbols-outlined welcome-action-icon"
- >code</span
- >
- <h3 class="welcome-action-title">Visit GitHub</h3>
- <p class="welcome-action-description">
- View source code and documentation
- </p>
- </div>
+ <div class="welcome-action-card" @click="executeAction('projects')">
+ <span class="material-symbols-outlined welcome-action-icon">folder</span>
+ <h3 class="welcome-action-title">Projects</h3>
+ <p class="welcome-action-description">
+ Manage your projects
+ </p>
+ </div>
+ <div class="welcome-action-card" @click="executeAction('memory')">
+ <span class="material-symbols-outlined welcome-action-icon">memory</span>
+ <h3 class="welcome-action-title">Memory</h3>
+ <p class="welcome-action-description">
+ Open Memory Dashboard
+ </p>
+ </div>
+ <div class="welcome-action-card" @click="executeAction('settings')">
+ <span class="material-symbols-outlined welcome-action-icon">settings</span>
+ <h3 class="welcome-action-title">Settings</h3>
+ <p class="welcome-action-description">
+ Configure Agent Zero
+ </p>
+ </div>
+ <div class="welcome-action-card" @click="executeAction('website')">
+ <span class="material-symbols-outlined welcome-action-icon">language</span>
+ <h3 class="welcome-action-title">Visit Website</h3>
+ <p class="welcome-action-description">
+ Learn more about Agent Zero
+ </p>
+ </div>
+ <div class="welcome-action-card" @click="executeAction('github')">
+ <span class="material-symbols-outlined welcome-action-icon">code</span>
+ <h3 class="welcome-action-title">Visit GitHub</h3>
+ <p class="welcome-action-description">
+ View source code and documentation
+ </p>
</div>
</div>
- </template>
- </div>
+ </div>
+ </template>
+ </div>
+
+ <style>
+ /* Welcome Screen Styles */
+ .welcome-container {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ padding: 3%;
+ text-align: center;
+ background: var(--color-background);
+ color: var(--color-text);
+ min-height: 100vh;
+ }
+
+ /* Welcome container styles */
+ .welcome-logo-container {
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ }
+
+ .welcome-logo {
+ width: 7rem;
+ height: 7rem;
+ }
+
+ /* Themes adjustments for logo */
+ .light-mode .welcome-logo {
+ filter: invert(0.5);
+ }
+
+ .dark-mode .welcome-logo {
+ filter: invert(0.8);
+ }
+
+ .welcome-title {
+ font-size: 2rem;
+ font-weight: 400;
+ margin: var(--spacing-xs) 0 0 0;
+ color: var(--color-text);
+ }
- <style>
- /* Welcome Screen Styles */
+ .welcome-action-title {
+ margin-bottom: 0;
+ }
+
+ .welcome-subtitle {
+ font-size: 1rem;
+ margin-bottom: 2rem;
+ color: var(--color-secondary);
+ max-width: 600px;
+ line-height: 1.5;
+ }
+
+ .welcome-actions {
+ display: grid;
+ grid-template-columns: repeat(3, 1fr);
+ gap: 1.2rem;
+ max-width: 520px;
+ width: 100%;
+ margin: 1.5rem 0;
+ }
+
+ .welcome-action-card {
+ background: var(--color-panel);
+ border: 1px solid var(--color-border);
+ border-radius: 12px;
+ padding: 1.5rem;
+ transition: all 0.3s ease;
+ cursor: pointer;
+ text-decoration: none;
+ color: inherit;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ text-align: center;
+ min-height: 10rem;
+ justify-content: center;
+ }
+
+ .welcome-action-card:hover {
+ border-color: var(--color-primary);
+ background: var(--color-message-bg);
+ }
+
+ .welcome-action-icon {
+ font-size: 2rem;
+ margin-bottom: 0;
+ color: var(--color-highlight-dark);
+ }
+
+ .welcome-action-description {
+ font-size: 0.8rem;
+ color: var(--color-secondary);
+ line-height: 1.3;
+ }
+
+ /* Light mode adjustments */
+ .light-mode .welcome-title {
+ color: #2d2d2d;
+ }
+
+ .light-mode .welcome-subtitle {
+ color: #666;
+ }
+
+ .light-mode .welcome-action-title {
+ color: #2d2d2d;
+ }
+
+ .light-mode .welcome-action-description {
+ color: #666;
+ }
+
+ .light-mode .welcome-footer {
+ color: #666;
+ }
+
+ /* Responsive design */
+ @media (max-width: 768px) {
.welcome-container {
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- padding: 3%;
- text-align: center;
- background: var(--color-background);
- color: var(--color-text);
- min-height: 100vh;
- }
- /* Welcome container styles */
- .welcome-logo-container {
- display: flex;
- justify-content: center;
- align-items: center;
+ padding: 1rem;
+ padding-top: 3rem;
}
.welcome-logo {
- width: 7rem;
- height: 7rem;
+ width: 5rem;
+ height: 5rem;
}
- /* Themes adjustments for logo */
- .light-mode .welcome-logo {
- filter: invert(0.5);
- }
- .dark-mode .welcome-logo {
- filter: invert(0.8);
+ .welcome-logo-container {
+ margin-top: 2rem;
}
.welcome-title {
- font-size: 2rem;
- font-weight: 400;
- margin: var(--spacing-xs) 0 0 0;
- color: var(--color-text);
- }
-
- .welcome-action-title {
- margin-bottom: 0;
+ font-size: 1.5rem;
+ margin: 0 !important;
}
.welcome-subtitle {
font-size: 1rem;
- margin-bottom: 2rem;
- color: var(--color-secondary);
- max-width: 600px;
- line-height: 1.5;
+ margin-top: var(--spacing-xs);
+ margin-bottom: 0;
}
.welcome-actions {
- display: grid;
- grid-template-columns: repeat(2, 1fr);
- gap: 1.2rem;
- max-width: 520px;
- width: 100%;
- margin: 1.5rem 0;
+ grid-template-columns: 1fr;
+ gap: 1rem;
+ margin-bottom: 2rem;
}
.welcome-action-card {
- background: var(--color-panel);
- border: 1px solid var(--color-border);
- border-radius: 12px;
padding: 1.5rem;
- transition: all 0.3s ease;
- cursor: pointer;
- text-decoration: none;
- color: inherit;
- display: flex;
- flex-direction: column;
- align-items: center;
- text-align: center;
- min-height: 10rem;
- justify-content: center;
- }
-
- .welcome-action-card:hover {
- border-color: var(--color-primary);
- background: var(--color-message-bg);
+ min-height: 120px;
}
.welcome-action-icon {
font-size: 2rem;
- margin-bottom: 0;
- color: var(--color-highlight-dark);
- }
-
- .welcome-action-description {
- font-size: 0.8rem;
- color: var(--color-secondary);
- line-height: 1.3;
}
- /* Light mode adjustments */
- .light-mode .welcome-title {
- color: #2d2d2d;
- }
-
- .light-mode .welcome-subtitle {
- color: #666;
- }
-
- .light-mode .welcome-action-title {
- color: #2d2d2d;
- }
-
- .light-mode .welcome-action-description {
- color: #666;
- }
-
- .light-mode .welcome-footer {
- color: #666;
- }
-
- /* Responsive design */
- @media (max-width: 768px) {
- .welcome-container {
- padding: 1rem;
- padding-top: 3rem;
- }
- .welcome-logo {
- width: 5rem;
- height: 5rem;
- }
- .welcome-logo-container {
- margin-top: 2rem;
- }
- .welcome-title {
- font-size: 1.5rem;
- margin: 0 !important;
- }
- .welcome-subtitle {
- font-size: 1rem;
- margin-top: var(--spacing-xs);
- margin-bottom: 0;
- }
- .welcome-actions {
- grid-template-columns: 1fr;
- gap: 1rem;
- margin-bottom: 2rem;
- }
- .welcome-action-card {
- padding: 1.5rem;
- min-height: 120px;
- }
- .welcome-action-icon {
- font-size: 2rem;
- }
.welcome-action-title {
- font-size: 1.1rem;
+ font-size: 1.1rem;
}
- }
- </style>
- </body>
-</html>
+ }
+ </style>
+</body>
+
+</html>
\ No newline at end of file
diff --git a/webui/components/welcome/welcome-store.js b/webui/components/welcome/welcome-store.js
index cae5a4b18..1bdf56094 100644
--- a/webui/components/welcome/welcome-store.js
+++ b/webui/components/welcome/welcome-store.js
@@ -1,6 +1,8 @@
import { createStore } from "/js/AlpineStore.js";
import { getContext } from "/index.js";
import { store as chatsStore } from "/components/sidebar/chats/chats-store.js";
+import { store as memoryStore } from "/components/settings/memory/memory-dashboard-store.js";
+import { store as projectsStore } from "/components/projects/projects-store.js";
const model = {
// State
@@ -45,6 +47,12 @@ const model = {
settingsButton.click();
}
break;
+ case "projects":
+ projectsStore.openProjectsModal();
+ break;
+ case "memory":
+ memoryStore.openModal();
+ break;
case "website":
window.open("https://agent-zero.ai", "_blank");
break;
diff --git a/webui/index.js b/webui/index.js
index 83ed2d699..4a2239eb6 100644
--- a/webui/index.js
+++ b/webui/index.js
@@ -154,15 +154,13 @@ export function updateChatInput(text) {
}
async function updateUserTime() {
-
let userTimeElement = document.getElementById("time-date");
- while(!userTimeElement){
+ while (!userTimeElement) {
await sleep(100);
userTimeElement = document.getElementById("time-date");
}
-
const now = new Date();
const hours = now.getHours();
const minutes = now.getMinutes();
@@ -276,6 +274,12 @@ export async function poll() {
return false;
}
+ // deselect chat if it is requested by the backend
+ if (response.deselect_chat) {
+ chatsStore.deselectChat();
+ return
+ }
+
if (
response.context != context &&
!(response.context === null && context === null) &&
@@ -356,21 +360,21 @@ export async function poll() {
tasksStore.setSelected(context);
}
} else {
- const welcomeStore =
- globalThis.Alpine && typeof globalThis.Alpine.store === "function"
- ? globalThis.Alpine.store("welcomeStore")
- : null;
- const welcomeVisible = Boolean(welcomeStore && welcomeStore.isVisible);
-
- // No context selected, try to select the first available item unless welcome screen is active
- if (!welcomeVisible && contexts.length > 0) {
- const firstChatId = chatsStore.firstId();
- if (firstChatId) {
- setContext(firstChatId);
- chatsStore.setSelected(firstChatId);
+ const welcomeStore =
+ globalThis.Alpine && typeof globalThis.Alpine.store === "function"
+ ? globalThis.Alpine.store("welcomeStore")
+ : null;
+ const welcomeVisible = Boolean(welcomeStore && welcomeStore.isVisible);
+
+ // No context selected, try to select the first available item unless welcome screen is active
+ if (!welcomeVisible && contexts.length > 0) {
+ const firstChatId = chatsStore.firstId();
+ if (firstChatId) {
+ setContext(firstChatId);
+ chatsStore.setSelected(firstChatId);
+ }
}
}
- }
lastLogVersion = response.log_version;
lastLogGuid = response.log_guid;