Ground Bean Bro in displayed temperatures, stream replies, and add activity calendar
Test and deploy / test-and-deploy (push) Successful in 1m19s

This commit is contained in:
snowspeeder committed 2026-09-07 06:38:16 -04:00
1 parent a72aec9f86
commit d96ed22de1
16 files changed
+551 -484

No files matched your search

+21 -8
View File
@@ -1,4 +1,4 @@
import { api } from "./api.js?v=__ASSET_VERSION__";
import { api, streamPlanChat } from "./api.js?v=__ASSET_VERSION__";
import {
SUGGESTION_FIELDS,
cleanSuggestions,
@@ -232,11 +232,22 @@ export function initPlanChat({
);
thread.append(pending);
const sentFields = structuredClone(getPlan().fields);
memory().suggestions = [];
showSuggestions([]);
recompute();
thread.setAttribute("aria-busy", "true");
let partial = "";
try {
const result = await api("/api/plan-chat", {
method: "POST",
body: JSON.stringify({ plan: getPlan(), messages: memory().messages }),
});
const result = await streamPlanChat(
{ plan: getPlan(), messages: memory().messages },
(text) => {
const nearBottom = thread.scrollHeight - thread.scrollTop - thread.clientHeight < 80;
partial = text;
pending.textContent = text;
pending.classList.remove("pending");
if (nearBottom) thread.scrollTop = thread.scrollHeight;
},
);
memory().messages.push({ role: "assistant", content: result.reply });
memory().messages = memory().messages.slice(-30);
memory().suggestionBase = sentFields;
@@ -246,14 +257,16 @@ export function initPlanChat({
showSuggestions(memory().suggestions);
recompute();
} catch (error) {
pending.textContent =
error.code === "no_model"
pending.classList.remove("pending");
pending.textContent = (partial ? partial + "\n\nResponse interrupted. " : "") +
(error.code === "no_model"
? "Bean Bro is not connected. An admin can configure the provider in Admin → Bean Bro."
: `Could not get a reply. ${error.message}`;
: `Could not get a reply. ${error.message}`);
memory().messages.pop();
input.value = text;
recompute();
} finally {
thread.setAttribute("aria-busy", "false");
busy = false;
send.disabled = false;
}