1
0
mirror of https://github.com/coalaura/whiskr.git synced 2025-09-08 17:06:42 +00:00

4 Commits

Author SHA1 Message Date
Laura
118e88ab67 some small fixes 2025-08-30 15:05:32 +02:00
Laura
dc8ad8d408 dynamic edit height 2025-08-30 14:34:29 +02:00
Laura
7abfd965db fix title schema 2025-08-30 14:15:22 +02:00
Laura
fc0a34ee12 import/export title 2025-08-30 14:13:24 +02:00
3 changed files with 24 additions and 11 deletions

View File

@@ -714,6 +714,7 @@ body:not(.loading) #loading {
.files {
display: flex;
gap: 6px;
overflow-x: auto;
}
.files:not(.has-files) {

View File

@@ -267,6 +267,10 @@
}
});
this.#_edit.addEventListener("input", () => {
this.updateEditHeight();
});
// message tool
this.#_tool = make("div", "tool");
@@ -381,7 +385,7 @@
mark(false);
generate(false);
generate(false, true);
});
// edit option
@@ -511,7 +515,7 @@
_result.classList.toggle("error", result?.startsWith("error: "));
_result.innerHTML = render(result || "*processing*");
this.#_tool.classList.toggle("invalid", invalid);
this.#_tool.classList.toggle("invalid", !!invalid);
this.#_tool.setAttribute("data-tool", name);
} else {
@@ -797,6 +801,11 @@
this.toggleEdit();
}
updateEditHeight() {
this.#_edit.style.height = "";
this.#_edit.style.height = `${Math.max(100, this.#_edit.scrollHeight + 2)}px`;
}
toggleEdit() {
this.#editing = !this.#editing;
@@ -804,11 +813,10 @@
activeMessage = this;
this.#_edit.value = this.#text;
this.#_edit.style.height = "";
this.setState("editing");
this.#_edit.style.height = `${Math.max(100, this.#_edit.scrollHeight)}px`;
this.updateEditHeight();
this.#_edit.focus();
} else {
@@ -932,7 +940,7 @@
let chatController;
function generate(cancel = false) {
function generate(cancel = false, noPush = false) {
if (chatController) {
chatController.abort();
@@ -972,7 +980,9 @@
$reasoningTokens.classList.remove("invalid");
}
if (!noPush) {
pushMessage();
}
chatController = new AbortController();
@@ -1599,6 +1609,7 @@
$export.addEventListener("click", () => {
const data = JSON.stringify({
title: chatTitle,
message: $message.value,
attachments: attachments,
role: $role.value,
@@ -1639,6 +1650,7 @@
clearMessages();
storeValue("title", data.title);
storeValue("message", data.message);
storeValue("attachments", data.attachments);
storeValue("role", data.role);

View File

@@ -17,7 +17,6 @@ type TitleRequest struct {
type TitleResponse struct {
Title string `json:"title"`
Cost float64 `json:"cost,omitempty"`
}
var (
@@ -146,7 +145,8 @@ func HandleTitle(w http.ResponseWriter, r *http.Request) {
return
}
result.Cost = cost
RespondJson(w, http.StatusOK, result)
RespondJson(w, http.StatusOK, map[string]any{
"title": result.Title,
"cost": cost,
})
}