diff --git a/Chat.go b/Chat.go index 9339cea..01810cc 100644 --- a/Chat.go +++ b/Chat.go @@ -594,6 +594,42 @@ func LoadModelSelectionHandler(c *fiber.Ctx) error { return c.SendString(GenerateModelPopoverHTML(false)) } +func GenerateConversationPopoverHTML(refresh bool) string { + var conversations []Conversation + err := edgeClient.Query(edgeCtx, ` + SELECT Conversation { + name, + position + } + FILTER .user = global currentUser + ORDER BY .position + `, &conversations) + if err != nil { + panic(err) + } + + out, err := pongo2.Must(pongo2.FromFile("views/partials/popover-conversation.html")).Execute(pongo2.Context{ + "Conversations": conversations, + "IsActive": refresh, + }) + if err != nil { + panic(err) + } + return out +} + +func LoadConversationSelectionHandler(c *fiber.Ctx) error { + if !checkIfLogin() || !checkIfHaveKey() { + return c.SendString("") + } + + return c.SendString(GenerateConversationPopoverHTML(false)) +} + +func RefreshConversationSelectionHandler(c *fiber.Ctx) error { + return c.SendString(GenerateConversationPopoverHTML(true)) +} + func LoadSettingsHandler(c *fiber.Ctx) error { if !checkIfLogin() { return c.SendString("") diff --git a/database.go b/database.go index b4ea765..ca6405f 100644 --- a/database.go +++ b/database.go @@ -39,10 +39,11 @@ type Setting struct { } type Conversation struct { - ID edgedb.UUID `edgedb:"id"` - Name string `edgedb:"name"` - Date time.Time `edgedb:"date"` - User User `edgedb:"user"` + ID edgedb.UUID `edgedb:"id"` + Name string `edgedb:"name"` + Position int32 `edgedb:"position"` + Date time.Time `edgedb:"date"` + User User `edgedb:"user"` } type Area struct { @@ -155,9 +156,15 @@ func addUsage(inputCost float32, outputCost float32, inputToken int32, outputTok func insertNewConversation() edgedb.UUID { var inserted struct{ id edgedb.UUID } err := edgeClient.QuerySingle(edgeCtx, ` + WITH + C := ( + SELECT Conversation + FILTER .user = global currentUser + ) INSERT Conversation { name := 'Default', - user := global currentUser + user := global currentUser, + position := count(C) + 1 } `, &inserted) if err != nil { diff --git a/dbschema/default.esdl b/dbschema/default.esdl index bb4088a..de408ce 100644 --- a/dbschema/default.esdl +++ b/dbschema/default.esdl @@ -37,6 +37,7 @@ module default { type Conversation { required name: str; + required position: int32; required user: User { on target delete delete source; }; diff --git a/dbschema/migrations/00042-m1ospnj.edgeql b/dbschema/migrations/00042-m1ospnj.edgeql new file mode 100644 index 0000000..0470e30 --- /dev/null +++ b/dbschema/migrations/00042-m1ospnj.edgeql @@ -0,0 +1,9 @@ +CREATE MIGRATION m1ospnjzsatmkntvczm5eu65omytyezeg3lanxeogtdqz2372t6cuq + ONTO m1cmvjy3ikuh5ii6b7l7gckttjmqk554llocwqx7n4aibtzngybvoq +{ + ALTER TYPE default::Conversation { + CREATE REQUIRED PROPERTY position: std::int32 { + SET REQUIRED USING ({0}); + }; + }; +}; diff --git a/main.go b/main.go index 48111c8..f8dfedf 100644 --- a/main.go +++ b/main.go @@ -86,6 +86,8 @@ func main() { // Popovers app.Get("/loadModelSelection", LoadModelSelectionHandler) + app.Get("/loadConversationSelection", LoadConversationSelectionHandler) + app.Get("/refreshConversationSelection", RefreshConversationSelectionHandler) app.Get("/loadUsageKPI", LoadUsageKPIHandler) app.Get("/loadKeys", LoadKeysHandler) app.Get("/loadSettings", LoadSettingsHandler) diff --git a/static/icons/.DS_Store b/static/icons/.DS_Store index 91eed7f..5008ddf 100644 Binary files a/static/icons/.DS_Store and b/static/icons/.DS_Store differ diff --git a/static/style.css b/static/style.css index 6e8d883..72a5c0e 100644 --- a/static/style.css +++ b/static/style.css @@ -118,4 +118,54 @@ svg text { .message-bot:hover .message-button { opacity: 1; +} + +.selected { + border: 2px solid #126d0f; + border-radius: 4px; + padding: 1px; + margin: 2px; +} + +.unselected { + border-radius: 4px; + padding: 3px; +} + +.shiftselected { + background: #126d0f; + border-radius: 4px; + padding: 1px; + margin: 2px; +} + +.shift-pressed *::selection { + background: transparent; +} + +input[type="range"].slider { + -webkit-appearance: none; + width: 80%; + background: transparent; + border: 1px solid #2c2c2c; + border-radius: 4px; + height: 6px; + border-radius: 2px; +} + +input[type="range"].slider::-webkit-slider-thumb { + -webkit-appearance: none; + width: 12px; + height: 12px; + border-radius: 2px; + background: #126d0f; + cursor: pointer; +} + +input[type="range"].slider::-moz-range-thumb { + width: 16px; + height: 16px; + border-radius: 2px; + background: #ffffff; + cursor: pointer; } \ No newline at end of file diff --git a/views/chat.html b/views/chat.html index 7e30506..b627798 100644 --- a/views/chat.html +++ b/views/chat.html @@ -9,8 +9,8 @@ id="chat-input-textarea">
- + +
+ + + +{% if not IsActive %} + +{% endif %} \ No newline at end of file diff --git a/views/partials/popover-conversations.html b/views/partials/popover-conversations.html deleted file mode 100644 index 2582bf8..0000000 --- a/views/partials/popover-conversations.html +++ /dev/null @@ -1,27 +0,0 @@ - \ No newline at end of file diff --git a/views/partials/popover-keys.html b/views/partials/popover-keys.html deleted file mode 100644 index f89ebca..0000000 --- a/views/partials/popover-keys.html +++ /dev/null @@ -1,88 +0,0 @@ - \ No newline at end of file diff --git a/views/partials/popover-models.html b/views/partials/popover-models.html index 9e49fc6..d03a4a1 100644 --- a/views/partials/popover-models.html +++ b/views/partials/popover-models.html @@ -163,56 +163,4 @@ event.preventDefault(); } }); - - - \ No newline at end of file + \ No newline at end of file diff --git a/views/partials/popover-settings.html b/views/partials/popover-settings.html index b528e29..21b80d0 100644 --- a/views/partials/popover-settings.html +++ b/views/partials/popover-settings.html @@ -1,11 +1,11 @@ -