~bigbes/sr-ht-dolt

ref: aff726826a23dcaeeb8ed784e4dd562b04fddeb3 sr-ht-dolt/web/beads.go -rw-r--r-- 1.6 KiB
aff72682 — Eugene Blikh docs: spec the MCP surface and the second round of beads views 5 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package web

import (
	"context"
	"net/url"

	"sourcecraft.dev/bigbes/sr-ht-dolt/beads"
	"sourcecraft.dev/bigbes/sr-ht-dolt/browse"
	"sourcecraft.dev/bigbes/sr-ht-dolt/core"
)

// beadsView renders a "beads" (bd) issue database as a Mardi Gras parade board:
// four lanes of cards (Rolling / Lined Up / Stalled / Past Stand) plus a
// per-issue detail pane reachable via ?issue=<id>. All data is read through the
// BrowseSession surface (Rows/Tables) — there is no SQL engine behind it.
//
// The reading itself is not here: the fingerprint, the lane bucketing, the ready
// rule and the whole view model live in the beads package, which the MCP surface
// shares. This type is only the View adapter — slug, label, template, and the
// hand-off of the request's ref and query.
type beadsView struct{}

func init() { RegisterView(&beadsView{}) }

func (*beadsView) Name() string     { return "beads" }
func (*beadsView) Label() string    { return "Beads" }
func (*beadsView) Template() string { return "beads.html" }

// Applies fingerprints a beads DB; see beads.Applies for the rule.
func (*beadsView) Applies(tables []browse.TableInfo) bool { return beads.Applies(tables) }

// Build reads the issue graph and produces either the board or, when ?issue=
// names an issue, that issue's detail pane. The result is a *beads.Data,
// handed to beads.html as its .Data.
func (*beadsView) Build(ctx context.Context, sess BrowseSession, _ *core.Repo, ref string, query url.Values) (any, error) {
	data, err := beads.Build(ctx, sess, ref, query)
	if err != nil {
		return nil, err
	}
	return data, nil
}