diff --git a/internal/render/templates/day.html b/internal/render/templates/day.html index fa8fce1..6113dd3 100644 --- a/internal/render/templates/day.html +++ b/internal/render/templates/day.html @@ -12,12 +12,99 @@

All dates{{ if .SelectedCwd }} / All directories / Directory dates{{ end }}

Sessions on {{ .Date.Label }}{{ if .SelectedCwdLabel }} – {{ .SelectedCwdLabel }}{{ end }}

{{ if .SelectedCwd }} -

Directory filter active. Clear filter / View directory dates

+

Directory filter active. Clear directory filter

{{ end }} +
+ {{ if .SelectedCwd }}{{ end }} + + +
+ {{ if .SelectedCwd }} +
+ + +

+ +
+ {{ end }} + {{ if .FallbackDate }} +
+

No sessions found for this directory today.

+
+
+

--- Previous Day ---

+
+

Filter by directory (click to filter sessions below)

+ +
+ {{ if or .HasPrev .HasNext (gt .TotalPages 1) }} + + {{ end }} +
+ {{ if .FallbackSessions }} + + {{ else }} +

No sessions found for this directory.

+ {{ end }} +
+ {{ else }} {{ if .Dirs }} -
+

Filter by directory (click to filter sessions below)

{{ end }} -
+ {{ if or .HasPrev .HasNext (gt .TotalPages 1) }} + + {{ end }} +
{{ if .Sessions }} @@ -48,7 +169,238 @@

Sessions on {{ .Date.Label }}{{ if .SelectedCwdLabel }}

No sessions found{{ if .SelectedCwdLabel }} for this directory{{ end }}.

{{ end }}

+ {{ end }}
+ {{ end }} diff --git a/internal/render/templates/dir.html b/internal/render/templates/dir.html index 90ee7b4..24d3162 100644 --- a/internal/render/templates/dir.html +++ b/internal/render/templates/dir.html @@ -10,19 +10,61 @@

All directories

-

Dates for {{ .Dir.Label }}

+

Sessions for {{ .Dir.Label }}

{{ .Dir.Count }} session{{ if ne .Dir.Count 1 }}s{{ end }}

+
+ + + +
+ {{ if or .HasPrev .HasNext (gt .TotalPages 1) }} + + {{ end }}
- {{ if .Dates }} + {{ if .Sessions }} @@ -31,6 +73,17 @@

Dates for {{ .Dir.Label }}

{{ end }}
+ {{ end }} diff --git a/internal/render/templates/index.html b/internal/render/templates/index.html index 4ddfd7b..4c2e8fe 100644 --- a/internal/render/templates/index.html +++ b/internal/render/templates/index.html @@ -136,11 +136,15 @@

{{ if eq .View "dir" }}Available Directories{{ else }}Ava setStatus(data.results.length + " result" + (data.results.length === 1 ? "" : "s") + "."); data.results.forEach(function (item) { var li = document.createElement("li"); - li.className = "search-result"; + li.className = "session-list-item search-result"; var link = document.createElement("a"); - link.className = "search-result-link"; - link.href = "/" + item.path + "/" + item.file + "#line-" + item.line; + link.className = "link-item-link search-result-link"; + var targetLine = item.line; + if (item.role === "assistant" && item.prevUserLine) { + targetLine = item.prevUserLine; + } + link.href = "/" + item.path + "/" + item.file + "#line-" + targetLine; link.textContent = item.file; var meta = document.createElement("span"); @@ -163,11 +167,57 @@

{{ if eq .View "dir" }}Available Directories{{ else }}Ava li.appendChild(link); li.appendChild(meta); - if (item.preview) { - var snippet = document.createElement("div"); - snippet.className = "search-result-snippet"; - highlightText(snippet, item.preview, query); - li.appendChild(snippet); + var thread = document.createElement("div"); + thread.className = "session-snippet session-snippet-thread"; + var hasUserSnippet = false; + + function addSnippet(role, text, highlight, line) { + if (!text) return; + var snippetLink = document.createElement("a"); + snippetLink.className = "snippet-link"; + var resolvedLine = line && line > 0 ? line : targetLine; + snippetLink.href = "/" + item.path + "/" + item.file + "#line-" + resolvedLine; + + var itemBox = document.createElement("div"); + itemBox.className = "session-item role-" + role + " snippet-item"; + + var content = document.createElement("div"); + content.className = "session-content"; + if (highlight) { + highlightText(content, text, query); + } else { + content.textContent = text; + } + + itemBox.appendChild(content); + snippetLink.appendChild(itemBox); + thread.appendChild(snippetLink); + } + + if (item.role === "user") { + hasUserSnippet = !!item.preview; + addSnippet("user", item.preview, true, item.line); + if (item.nextAssistant) { + addSnippet("assistant", item.nextAssistant, false, item.nextAssistantLine); + } + } else if (item.role === "assistant") { + if (item.prevUser) { + hasUserSnippet = true; + addSnippet("user", item.prevUser, false, item.prevUserLine); + } + addSnippet("assistant", item.preview, true, item.line); + } else if (item.preview) { + addSnippet(item.role || "unknown", item.preview, true, item.line); + } + + if (thread.childNodes.length > 0) { + if (hasUserSnippet) { + var divider = document.createElement("div"); + divider.className = "snippet-divider"; + divider.textContent = ":"; + thread.insertBefore(divider, thread.firstChild); + } + li.appendChild(thread); } results.appendChild(li); diff --git a/internal/render/templates/session.html b/internal/render/templates/session.html index e0480ea..8d1332f 100644 --- a/internal/render/templates/session.html +++ b/internal/render/templates/session.html @@ -9,13 +9,12 @@