From f11ab21d436a2f07fd2e4fb46e874f25b3709ca0 Mon Sep 17 00:00:00 2001 From: Amolith Date: Sat, 18 Oct 2025 21:21:12 -0600 Subject: [PATCH] feat(web): add description meta to bug pages Add proper description metadata to bug listing and individual bug pages for better SEO and page information. Bug list uses repo description or fallback, individual bug pages use truncated bug message. Implements: bug-8d2588d Co-authored-by: Crush --- pkg/web/webui_bugs.go | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/pkg/web/webui_bugs.go b/pkg/web/webui_bugs.go index 88025dee75d3ac4baae91eb9a402b86d5984918e..69abd5f89b6a8f6951e7dd25572342f2a3b43abe 100644 --- a/pkg/web/webui_bugs.go +++ b/pkg/web/webui_bugs.go @@ -425,12 +425,15 @@ func repoBugs(w http.ResponseWriter, r *http.Request) { repoDisplayName = repo.Name() } + description := getRepoDescriptionOrFallback(repo, "Bugs in "+repoDisplayName) + data := BugsData{ RepoBaseData: RepoBaseData{ BaseData: BaseData{ - ServerName: cfg.Name, - ActiveTab: "bugs", - Title: "Bugs | " + repoDisplayName, + ServerName: cfg.Name, + ActiveTab: "bugs", + Title: "Bugs | " + repoDisplayName, + Description: description, }, Repo: repo, DefaultBranch: defaultBranch, @@ -494,6 +497,22 @@ func repoBug(w http.ResponseWriter, r *http.Request) { edited = timeline[0].Edited } + // Extract raw message for description + var rawMessage string + if len(snap.Timeline) > 0 { + if createOp, ok := snap.Timeline[0].(*bug.CreateTimelineItem); ok { + if !createOp.MessageIsEmpty() { + rawMessage = createOp.Message + } + } + } + + // Generate description from bug message or fallback to title + description := extractPlainTextFromMarkdown(rawMessage, 200) + if description == "" { + description = truncateText(snap.Title, 200) + } + gr, err := openRepository(repo) if err != nil { logger.Debug("failed to open repository", "repo", repo.Name(), "err", err) @@ -510,9 +529,10 @@ func repoBug(w http.ResponseWriter, r *http.Request) { data := BugData{ RepoBaseData: RepoBaseData{ BaseData: BaseData{ - ServerName: cfg.Name, - ActiveTab: "bugs", - Title: snap.Title + " | Bug " + snap.Id().Human() + " | " + repoDisplayName, + ServerName: cfg.Name, + ActiveTab: "bugs", + Title: snap.Title + " | Bug " + snap.Id().Human() + " | " + repoDisplayName, + Description: description, }, Repo: repo, DefaultBranch: defaultBranch,