From fe0d24ae875a8212d364ad2af9f7b94dc145d8ff Mon Sep 17 00:00:00 2001 From: wizardchen Date: Thu, 30 Apr 2026 16:15:49 +0800 Subject: [PATCH] fix(sessions): review fixes for keyword search / pinning / IM titles - Apply the session-list additions to the SQLite init migration (Lite build) and make QueryPaged dialect-aware: LOWER(..) LIKE on SQLite, ILIKE on Postgres, drop NULLS LAST on SQLite. Escape LIKE wildcards in the keyword via the existing escapeLikeKeyword helper. - SetPinned now returns rowsAffected so the handler can respond 404 on unknown / unauthorized session IDs instead of a misleading 200. - GET /sessions always returns the enriched shape (pin state + IM origin fields) so the frontend never needs a second roundtrip; the dual-path legacy branch in the handler is gone. - Register pin routes with the wildcard name that matches each verb's existing radix tree (POST :session_id, DELETE :id) and accept either param name in the handler; avoids gin's "wildcard conflicts" panic. - Drop the redundant [platform] prefix from IM session titles now that the list renders a platform icon alongside the title; add unit tests for shortID / buildUserSessionTitle / buildThreadSessionTitle. - Frontend: remove the submenu search input and its i18n/keyword wiring (search lives elsewhere in the app); pin icon uses the TDesign `pin` glyph and inherits color so the active session turns green; optimistic pin moves the item to the top of the list so it shows up at the top of the Pinned group; IM text badge replaced by the platform SVG icons from assets/img/im, desaturated by default and full-color on hover or when the session is active. --- frontend/src/api/chat/index.ts | 14 +-- frontend/src/components/menu.vue | 116 +++++++++++---------- frontend/src/i18n/locales/en-US.ts | 3 - frontend/src/i18n/locales/ko-KR.ts | 3 - frontend/src/i18n/locales/ru-RU.ts | 3 - frontend/src/i18n/locales/zh-CN.ts | 3 - internal/application/repository/session.go | 29 +++++- internal/application/service/session.go | 6 +- internal/handler/session/handler.go | 64 +++++------- internal/im/service.go | 5 +- internal/im/session_title_test.go | 109 +++++++++++++++++++ internal/router/router.go | 6 +- internal/types/interfaces/session.go | 7 +- migrations/sqlite/000000_init.up.sql | 6 ++ 14 files changed, 244 insertions(+), 130 deletions(-) create mode 100644 internal/im/session_title_test.go diff --git a/frontend/src/api/chat/index.ts b/frontend/src/api/chat/index.ts index f8ca9e77..ad96b2d5 100644 --- a/frontend/src/api/chat/index.ts +++ b/frontend/src/api/chat/index.ts @@ -6,18 +6,8 @@ export async function createSessions(data = {}) { return post("/api/v1/sessions", data); } -export async function getSessionsList( - page: number, - page_size: number, - filters: { keyword?: string; source?: string; agent_id?: string } = {} -) { - const params = new URLSearchParams(); - params.set("page", String(page)); - params.set("page_size", String(page_size)); - if (filters.keyword) params.set("keyword", filters.keyword); - if (filters.source) params.set("source", filters.source); - if (filters.agent_id) params.set("agent_id", filters.agent_id); - return get(`/api/v1/sessions?${params.toString()}`); +export async function getSessionsList(page: number, page_size: number) { + return get(`/api/v1/sessions?page=${page}&page_size=${page_size}`); } export async function pinSession(session_id: string) { diff --git a/frontend/src/components/menu.vue b/frontend/src/components/menu.vue index c0a51978..2394dbc8 100644 --- a/frontend/src/components/menu.vue +++ b/frontend/src/components/menu.vue @@ -61,18 +61,6 @@