From 1eab4d59454fa5999675d51b99e77ac6580aba95 Mon Sep 17 00:00:00 2001 From: Peter Stone Date: Thu, 5 Feb 2026 10:43:19 -1000 Subject: Improve session handling, shopping UI, and cleanup Session improvements: - Extend session lifetime to 7 days for mobile convenience - Add idle timeout to extend session on activity - Use standard cookie name for better compatibility Shopping model: - Add FlattenItemsForStore helper for extracting store items - Add StoreNames helper for store list - Improve shopping-tab.html with inline add forms Frontend: - Add WebSocket reconnection and agent approval UI to app.js - Simplify timeline calendar JS (move event positioning to CSS) - Update login page styling Deployment: - Remove unused git checkout step from deploy.sh - Update apache.conf WebSocket proxy settings Documentation: - Add Agent Context API feature spec to issues/ Co-Authored-By: Claude Opus 4.5 --- internal/models/types.go | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'internal/models/types.go') diff --git a/internal/models/types.go b/internal/models/types.go index ab06ea2..8ec2095 100644 --- a/internal/models/types.go +++ b/internal/models/types.go @@ -1,6 +1,10 @@ package models -import "time" +import ( + "sort" + "strings" + "time" +) // Task represents a task from Todoist type Task struct { @@ -60,6 +64,35 @@ type ShoppingCategory struct { Items []UnifiedShoppingItem } +// FlattenItemsForStore extracts all items for a specific store, sorted by checked status then name +func FlattenItemsForStore(stores []ShoppingStore, storeName string) []UnifiedShoppingItem { + var items []UnifiedShoppingItem + for _, store := range stores { + if strings.EqualFold(store.Name, storeName) { + for _, cat := range store.Categories { + items = append(items, cat.Items...) + } + } + } + // Sort: unchecked first, then by name + sort.Slice(items, func(i, j int) bool { + if items[i].Checked != items[j].Checked { + return !items[i].Checked + } + return items[i].Name < items[j].Name + }) + return items +} + +// StoreNames returns the names of all stores +func StoreNames(stores []ShoppingStore) []string { + names := make([]string, len(stores)) + for i, store := range stores { + names[i] = store.Name + } + return names +} + // List represents a Trello list type List struct { ID string `json:"id"` -- cgit v1.2.3