Give each task an assigned colour across the UI; lead links tasks
This commit is contained in:
+21
-5
@@ -280,11 +280,18 @@ CREATE TABLE previews (
|
||||
PRIMARY KEY (task_id, name),
|
||||
UNIQUE (task_id, port)
|
||||
);
|
||||
`}, {"add-task-color", `
|
||||
ALTER TABLE tasks ADD COLUMN color INTEGER NOT NULL DEFAULT 0;
|
||||
UPDATE tasks SET color = (SELECT count(*) FROM tasks AS earlier WHERE earlier.rowid < tasks.rowid) % 11;
|
||||
UPDATE tasks SET color = (
|
||||
SELECT count(*) FROM tasks AS earlier WHERE earlier.status = 'active' AND earlier.rowid < tasks.rowid
|
||||
) % 11 WHERE status = 'active';
|
||||
`}}
|
||||
|
||||
const (
|
||||
DefaultPortFirst = 41000
|
||||
PortBlock = 10
|
||||
TaskColors = 11
|
||||
)
|
||||
|
||||
type Store struct {
|
||||
@@ -571,10 +578,19 @@ func (s *Store) CreateTask(ctx context.Context, t api.Task, actor string) error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = tx.QueryRowContext(ctx, `
|
||||
WITH RECURSIVE palette(c) AS (SELECT 0 UNION ALL SELECT c + 1 FROM palette WHERE c + 1 < ?)
|
||||
SELECT c FROM palette
|
||||
ORDER BY c IN (SELECT color FROM tasks WHERE status = ?), coalesce((SELECT max(rowid) FROM tasks WHERE color = c), -1), c
|
||||
LIMIT 1
|
||||
`, TaskColors, string(api.TaskStatusActive)).Scan(&t.Color)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = tx.ExecContext(ctx, `
|
||||
INSERT INTO tasks (id, project_id, title, merge_title, branch, worktree_path, base_ref, port_base, status, created_by, created_at, todo_item, forked_from, forked_at)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
`, t.Id, t.ProjectId, t.Title, mergeTitle, t.Branch, t.WorktreePath, t.BaseRef, t.PortBase, string(t.Status), t.CreatedBy, formatTime(t.CreatedAt), todoItem, forkedFrom, forkedAt)
|
||||
INSERT INTO tasks (id, project_id, title, merge_title, branch, worktree_path, base_ref, port_base, color, status, created_by, created_at, todo_item, forked_from, forked_at)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
`, t.Id, t.ProjectId, t.Title, mergeTitle, t.Branch, t.WorktreePath, t.BaseRef, t.PortBase, t.Color, string(t.Status), t.CreatedBy, formatTime(t.CreatedAt), todoItem, forkedFrom, forkedAt)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1090,7 +1106,7 @@ func (s *Store) write(ctx context.Context, fn func(tx *sql.Tx, emit emitFunc) er
|
||||
|
||||
const projectColumns = `id, name, repo_path, default_branch, remote, created_by, created_at`
|
||||
|
||||
const taskColumns = `id, project_id, title, merge_title, branch, worktree_path, base_ref, port_base, status, created_by, created_at, closed_at, merge_commit, todo_item, forked_from, forked_at, merge_queued_at`
|
||||
const taskColumns = `id, project_id, title, merge_title, branch, worktree_path, base_ref, port_base, color, status, created_by, created_at, closed_at, merge_commit, todo_item, forked_from, forked_at, merge_queued_at`
|
||||
|
||||
const sessionColumns = `id, coalesce(task_id, ''), owner, vendor, model, vendor_session_id, state, role, created_by, created_at, forked_from, forked_at`
|
||||
|
||||
@@ -1119,7 +1135,7 @@ func scanTask(row scanner) (api.Task, error) {
|
||||
forkedFrom := ""
|
||||
forkedAt := 0
|
||||
mergeQueuedAt := ""
|
||||
err := row.Scan(&t.Id, &t.ProjectId, &t.Title, &t.MergeTitle, &t.Branch, &t.WorktreePath, &t.BaseRef, &t.PortBase, &status, &t.CreatedBy, &createdAt, &closedAt, &mergeCommit, &todoItem, &forkedFrom, &forkedAt, &mergeQueuedAt)
|
||||
err := row.Scan(&t.Id, &t.ProjectId, &t.Title, &t.MergeTitle, &t.Branch, &t.WorktreePath, &t.BaseRef, &t.PortBase, &t.Color, &status, &t.CreatedBy, &createdAt, &closedAt, &mergeCommit, &todoItem, &forkedFrom, &forkedAt, &mergeQueuedAt)
|
||||
if err != nil {
|
||||
return t, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user