mirror of
https://github.com/PerpetualSoftware/pad.git
synced 2026-09-10 23:15:40 +00:00
bde15d45ca
* Rename "Phases" to "Plans" and clean up deprecated phase aliases
Renames the default "Phases" collection to "Plans" across the full stack:
- DB migration renames existing collections in-place (name, slug, prefix PLAN, icon 🗺️)
- Removes all deprecated Phase* backward-compat aliases from models and store
- Removes --phase CLI flag (use --parent instead)
- Updates convention triggers: on-phase-start/complete → on-plan-start/complete
- Updates dashboard API: active_phases → active_plans, /phases-progress → /plans-progress
- Updates all frontend components, types, and documentation
Closes IDEA-124
* Fix CSRF cookie not being cleared on logout
The SessionAuth middleware was re-issuing a CSRF cookie before the
logout handler could clear it, resulting in two Set-Cookie headers.
Skip CSRF re-issue for /api/v1/auth/ paths since auth endpoints
manage their own CSRF cookies (login sets, logout clears).
* Fix migration issues found in Codex review
- P1: Move doc_type UPDATE from migration 024 into 025, which recreates
the table with the new CHECK constraint first (SQLite enforces CHECK
on UPDATE, so the old constraint would reject 'plan')
- P1: Add PostgreSQL migration 005 for the collection rename (phases →
plans) — previously only existed on the SQLite path
- P2: Recreate FTS triggers, indexes, and rebuild FTS after the table
swap in migration 025 (DROP TABLE drops associated objects in SQLite)
* Fix parent filter field name and sync .agents skill copy
Codex review round 2 findings:
- P1: Parent filter compared against `parent_id` (wrong) instead of
`parent_link_id` — plan filtering in collection view was broken
- P1: .agents/skills/pad/SKILL.md still had old --phase flags and
"Phases" references — synced from the updated .claude copy
- P2: Accept legacy 'phase' filter key for backward compat with
existing saved views that serialized the old key name
* Fix PG migration JSONB casting and add slug collision guards
Codex PR review bot findings:
- P1: PostgreSQL REPLACE/LIKE don't work on JSONB columns — cast
schema::text and fields::text before string ops, then back to ::jsonb
- P1: If a workspace already has a custom 'plans' collection, the
rename hits UNIQUE(workspace_id, slug) — added NOT EXISTS guard
to both SQLite and PostgreSQL migrations
111 lines
3.1 KiB
Go
111 lines
3.1 KiB
Go
package models
|
|
|
|
import "time"
|
|
|
|
// Valid document types
|
|
var ValidDocTypes = []string{
|
|
"roadmap", "plan", "architecture", "ideation",
|
|
"feature-spec", "notes", "prompt-library", "reference",
|
|
}
|
|
|
|
// Valid document statuses
|
|
var ValidStatuses = []string{
|
|
"draft", "active", "completed", "archived",
|
|
}
|
|
|
|
// Valid actors
|
|
var ValidActors = []string{"user", "agent"}
|
|
|
|
// Valid sources
|
|
var ValidSources = []string{"cli", "web", "skill"}
|
|
|
|
type Document struct {
|
|
ID string `json:"id"`
|
|
WorkspaceID string `json:"workspace_id"`
|
|
Title string `json:"title"`
|
|
Slug string `json:"slug"`
|
|
Content string `json:"content"`
|
|
DocType string `json:"doc_type"`
|
|
Status string `json:"status"`
|
|
Tags string `json:"tags"` // JSON array
|
|
Pinned bool `json:"pinned"`
|
|
SortOrder int `json:"sort_order"`
|
|
CreatedBy string `json:"created_by"`
|
|
LastModifiedBy string `json:"last_modified_by"`
|
|
Source string `json:"source"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
DeletedAt *time.Time `json:"deleted_at,omitempty"`
|
|
}
|
|
|
|
type DocumentCreate struct {
|
|
Title string `json:"title"`
|
|
Content string `json:"content,omitempty"`
|
|
DocType string `json:"doc_type,omitempty"`
|
|
Status string `json:"status,omitempty"`
|
|
Tags string `json:"tags,omitempty"`
|
|
Pinned bool `json:"pinned,omitempty"`
|
|
CreatedBy string `json:"created_by,omitempty"`
|
|
Source string `json:"source,omitempty"`
|
|
}
|
|
|
|
type DocumentUpdate struct {
|
|
Title *string `json:"title,omitempty"`
|
|
Content *string `json:"content,omitempty"`
|
|
DocType *string `json:"doc_type,omitempty"`
|
|
Status *string `json:"status,omitempty"`
|
|
Tags *string `json:"tags,omitempty"`
|
|
Pinned *bool `json:"pinned,omitempty"`
|
|
SortOrder *int `json:"sort_order,omitempty"`
|
|
LastModifiedBy string `json:"last_modified_by,omitempty"`
|
|
Source string `json:"source,omitempty"`
|
|
ChangeSummary string `json:"change_summary,omitempty"`
|
|
}
|
|
|
|
type QuickSave struct {
|
|
Title string `json:"title"`
|
|
Content string `json:"content"`
|
|
DocType string `json:"doc_type,omitempty"`
|
|
Status string `json:"status,omitempty"`
|
|
Tags string `json:"tags,omitempty"`
|
|
CreatedBy string `json:"created_by,omitempty"`
|
|
Source string `json:"source,omitempty"`
|
|
ChangeSummary string `json:"change_summary,omitempty"`
|
|
}
|
|
|
|
type DocumentListParams struct {
|
|
Type string
|
|
Status string
|
|
Tag string
|
|
Pinned *bool
|
|
Query string
|
|
Sort string
|
|
Order string
|
|
}
|
|
|
|
func IsValidDocType(t string) bool {
|
|
for _, v := range ValidDocTypes {
|
|
if v == t {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
func IsValidStatus(s string) bool {
|
|
for _, v := range ValidStatuses {
|
|
if v == s {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
func IsValidActor(a string) bool {
|
|
return a == "user" || a == "agent"
|
|
}
|
|
|
|
func IsValidSource(s string) bool {
|
|
return s == "cli" || s == "web" || s == "skill"
|
|
}
|