Files
pad/internal/collections/defaults.go
T
xarmian faf9b3734a feat(web): default new collections to Board — schema-aware (IDEA-2274, IDEA-2287) (#1015)
* feat(web): default new collections to Board view (IDEA-2274)

Board becomes the baseline default view for new collections; existing
collections keep their stored default_view (no migration).

- Frontend fallback (settingsDefaults, collection-page defaultMode,
  shareView coerce, initial viewMode) -> board
- Create/Edit collection modals default -> board
- Backend template seeds (defaults.go, templates*.go) list -> board for
  ideas/plans/docs/hiring/interviewing collections (tasks was already board)
- CLI `pad collection create` and MCP mapCollectionCreate defaults -> board
- Curated create-modal presets with deliberate list curation (Meeting
  Notes, Decisions, OKRs) intentionally left as list
- Pin the three list-keyboard-nav pane E2E tests to ?view=list

Claude-Session: https://claude.ai/code/session_01EZ6yr6pAUFb1uffan912ra

* fix(web): board default reaches public share page + ItemDetail fallback (Codex round 1)

Codex review found the public share route (s/[token]) derives its owner
default view via a separate `?? 'list'` fallback that bypassed the
coerceSettings change, so settings-less/legacy collections rendered List
on public share pages. Align it (and the pre-init selectedBase) to board.
Also align ItemDetail's inline CollectionSettings fallback (default_view
is unused there, but keep it consistent with settingsDefaults).

Claude-Session: https://claude.ai/code/session_01EZ6yr6pAUFb1uffan912ra

* fix(collections): group Contacts board by relationship, not status (Codex round 2)

Contacts has no `status` field, so defaulting it to Board grouped by the
default `status` rendered every card in a single Uncategorized lane. Set
BoardGroupBy=relationship so the board shows real lanes. All other
board-defaulted seed collections have a status field or an explicit
board_group_by (verified: Companies/Conventions/Playbooks/Docs have status).

Claude-Session: https://claude.ai/code/session_01EZ6yr6pAUFb1uffan912ra

* fix(web): always serialize ?view= so a List URL survives a board default (Codex round 3)

buildCollectionUrlParams treated List as the implicit URL view and omitted
it. With Board now a possible collection default (IDEA-2274), a List
selection on a board-default collection produced a URL that, when copied or
opened without the sender's localStorage, resolved back to Board. Always
serialize the view mode; add a covering unit test. Verified the pane E2E
suite (URL-equality assertions) stays green.

Claude-Session: https://claude.ai/code/session_01EZ6yr6pAUFb1uffan912ra
2026-07-23 13:33:01 -04:00

205 lines
7.0 KiB
Go

package collections
import "github.com/PerpetualSoftware/pad/internal/models"
// DefaultCollection holds the definition for a default collection that gets
// created when a workspace is initialized.
type DefaultCollection struct {
Name string
Slug string
Prefix string // Optional explicit issue-ID prefix; empty means derive from Name
Icon string
Description string
Schema models.CollectionSchema
Settings models.CollectionSettings
SortOrder int
IsSystem bool // System collections (conventions, playbooks) are always visible to members
}
// Defaults returns the six default collections for a new workspace.
func Defaults() []DefaultCollection {
return []DefaultCollection{
{
Name: "Tasks",
Slug: "tasks",
Icon: "✓",
Description: "Track work items, bugs, and to-dos",
SortOrder: 0,
Schema: models.CollectionSchema{
Fields: []models.FieldDef{
{
Key: "status",
Label: "Status",
Type: "select",
Options: []string{"open", "in-progress", "done", "cancelled"},
TerminalOptions: []string{"done", "cancelled"},
Default: "open",
Required: true,
},
{
Key: "priority",
Label: "Priority",
Type: "select",
Options: []string{"low", "medium", "high", "critical"},
Default: "medium",
},
{
Key: "due_date",
Label: "Due Date",
Type: "date",
},
{
Key: "effort",
Label: "Effort",
Type: "select",
Options: []string{"xs", "s", "m", "l", "xl"},
},
},
},
Settings: models.CollectionSettings{
Layout: "fields-primary",
DefaultView: "board",
BoardGroupBy: "status",
ListSortBy: "priority",
QuickActions: []models.QuickAction{
{Label: "Implement this", Prompt: "/pad implement {ref} \"{title}\" (status: {status}, priority: {priority})", Scope: "item", Icon: "🔨"},
{Label: "Write tests", Prompt: "/pad write tests for {ref} \"{title}\"", Scope: "item", Icon: "🧪"},
{Label: "Explain this task", Prompt: "/pad explain {ref} \"{title}\" — what does it involve and why is it needed?", Scope: "item", Icon: "💬"},
{Label: "Triage open tasks", Prompt: "/pad triage all open tasks and suggest priorities", Scope: "collection", Icon: "📋"},
{Label: "Status report", Prompt: "/pad summarize progress on all tasks", Scope: "collection", Icon: "📊"},
},
},
},
{
Name: "Ideas",
Slug: "ideas",
Icon: "💡",
Description: "Capture ideas, feature requests, and inspiration",
SortOrder: 1,
Schema: models.CollectionSchema{
Fields: []models.FieldDef{
{
Key: "status",
Label: "Status",
Type: "select",
Options: []string{"new", "exploring", "planned", "implemented", "rejected"},
TerminalOptions: []string{"implemented", "rejected"},
Default: "new",
Required: true,
},
{
Key: "impact",
Label: "Impact",
Type: "select",
Options: []string{"low", "medium", "high"},
},
{
Key: "category",
Label: "Category",
Type: "text",
},
},
},
Settings: models.CollectionSettings{
Layout: "balanced",
DefaultView: "board",
ListSortBy: "created_at",
ListGroupBy: "status",
QuickActions: []models.QuickAction{
{Label: "Explore this idea", Prompt: "/pad explore {ref} \"{title}\" — research feasibility, trade-offs, and implementation approaches", Scope: "item", Icon: "🔍"},
{Label: "Break into tasks", Prompt: "/pad break down {ref} \"{title}\" into actionable tasks", Scope: "item", Icon: "📝"},
{Label: "Research this", Prompt: "/pad research {ref} \"{title}\" and summarize findings", Scope: "item", Icon: "📚"},
{Label: "Review all new ideas", Prompt: "/pad triage all new ideas and suggest which to pursue", Scope: "collection", Icon: "💡"},
},
},
},
{
Name: "Plans",
Slug: "plans",
Icon: "🗺️",
Description: "Plan and track project plans and milestones",
SortOrder: 2,
Schema: models.CollectionSchema{
Fields: []models.FieldDef{
{
Key: "status",
Label: "Status",
Type: "select",
Options: []string{"planned", "active", "completed", "paused"},
TerminalOptions: []string{"completed"},
Default: "planned",
Required: true,
},
{
Key: "start_date",
Label: "Start Date",
Type: "date",
},
{
Key: "end_date",
Label: "End Date",
Type: "date",
},
{
Key: "progress",
Label: "Progress",
Type: "number",
Suffix: "%",
Computed: true,
},
},
},
Settings: models.CollectionSettings{
Layout: "content-primary",
DefaultView: "board",
ListSortBy: "sort_order",
QuickActions: []models.QuickAction{
{Label: "Plan this", Prompt: "/pad plan {ref} \"{title}\" — outline goals, deliverables, and timeline", Scope: "item", Icon: "📐"},
{Label: "Break into tasks", Prompt: "/pad break {ref} \"{title}\" into PR-sized tasks", Scope: "item", Icon: "📝"},
{Label: "Run a retro", Prompt: "/pad run a retrospective on {ref} \"{title}\"", Scope: "item", Icon: "🔄"},
{Label: "Compare progress", Prompt: "/pad compare progress across all plans", Scope: "collection", Icon: "📊"},
},
},
},
{
Name: "Docs",
Slug: "docs",
Icon: "📄",
Description: "Documentation, notes, and reference material",
SortOrder: 3,
Schema: models.CollectionSchema{
Fields: []models.FieldDef{
{
Key: "status",
Label: "Status",
Type: "select",
Options: []string{"draft", "published", "archived"},
TerminalOptions: []string{"archived"},
Default: "draft",
Required: true,
},
{
Key: "category",
Label: "Category",
Type: "text",
},
},
},
Settings: models.CollectionSettings{
Layout: "content-primary",
DefaultView: "board",
ListSortBy: "updated_at",
ListGroupBy: "category",
QuickActions: []models.QuickAction{
{Label: "Review this doc", Prompt: "/pad review {ref} \"{title}\" for accuracy and completeness", Scope: "item", Icon: "👀"},
{Label: "Update this doc", Prompt: "/pad update {ref} \"{title}\" to reflect the current state of the codebase", Scope: "item", Icon: "✏️"},
{Label: "Summarize this", Prompt: "/pad summarize {ref} \"{title}\"", Scope: "item", Icon: "📋"},
{Label: "Find outdated docs", Prompt: "/pad review all docs and identify which are outdated", Scope: "collection", Icon: "🔍"},
},
},
},
conventionsCollection(4, SoftwareConventionTriggers, SoftwareConventionScopes),
playbooksCollection(5, SoftwarePlaybookTriggers, SoftwarePlaybookScopes),
}
}