feat(web): add description meta to bug pages

Amolith and Crush created

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 <crush@charm.land>

Change summary

pkg/web/webui_bugs.go | 32 ++++++++++++++++++++++++++------
1 file changed, 26 insertions(+), 6 deletions(-)

Detailed changes

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,