From 127cdcd843b73e64adfbb32a4a7457768d065043 Mon Sep 17 00:00:00 2001 From: Guilherme Moraes Date: Fri, 16 Oct 2026 18:56:44 -0300 Subject: [PATCH 01/30] feat: add the taskflow-panel side pane A second plugin in the marketplace, under panel/. /taskflow opens a pane listing every plan's task progress, active tasks, open questions and pull requests with links, with keys for /next-task, refresh, and deleting a plan folder after a confirmation. Plans are read from the git root's projectsDir. --- .claude-plugin/marketplace.json | 5 + README.md | 6 + panel/.claude-plugin/plugin.json | 7 + panel/hooks/hooks.json | 1 + panel/hooks/parse.test.ts | 55 ++++++++ panel/hooks/parse.ts | 75 ++++++++++ panel/hooks/register.tsx | 234 +++++++++++++++++++++++++++++++ panel/types/index.d.ts | 34 +++++ 8 files changed, 417 insertions(+) create mode 100644 panel/.claude-plugin/plugin.json create mode 100644 panel/hooks/hooks.json create mode 100644 panel/hooks/parse.test.ts create mode 100644 panel/hooks/parse.ts create mode 100644 panel/hooks/register.tsx create mode 100644 panel/types/index.d.ts diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json index 00e8361..08471b8 100644 --- a/.claude-plugin/marketplace.json +++ b/.claude-plugin/marketplace.json @@ -6,6 +6,11 @@ "name": "taskflow", "source": "./", "description": "Plan-and-task workflow: scope/tasks/questions/progress scaffolding, one-task-per-commit cycle, questions answered at the task that needs them, red-first bug fixes, docs-and-diagram sync, standards review." + }, + { + "name": "taskflow-panel", + "source": "./panel", + "description": "Side pane for taskflow plans: active tasks, progress, PRs with links, and deleting a plan workspace." } ] } diff --git a/README.md b/README.md index 408c13b..e98a639 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,12 @@ Then, in the repo you want to use it on: > 💡 To install from a local checkout instead, pass its path to `/plugin marketplace add`. +Optionally, add the side pane (`/plugin install taskflow-panel@taskflow-tools`). `/taskflow` +opens it: every plan's progress, its active tasks and open questions, the pull requests +with their links, a key for `/next-task`, and a delete button for a plan folder that +asks before it removes anything. It opens by itself at session start on terminals of 144 +columns or more. + ## How a piece of work flows 🔁 ``` diff --git a/panel/.claude-plugin/plugin.json b/panel/.claude-plugin/plugin.json new file mode 100644 index 0000000..c84b8cd --- /dev/null +++ b/panel/.claude-plugin/plugin.json @@ -0,0 +1,7 @@ +{ + "name": "taskflow-panel", + "version": "0.1.0", + "author": { "name": "Guilherme Moraes" }, + "description": "Side pane for taskflow plans: active tasks, progress, PRs with links, and deleting a plan workspace", + "types": "./types/index.d.ts" +} diff --git a/panel/hooks/hooks.json b/panel/hooks/hooks.json new file mode 100644 index 0000000..5a63f64 --- /dev/null +++ b/panel/hooks/hooks.json @@ -0,0 +1 @@ +{ "modules": ["./register.tsx"] } diff --git a/panel/hooks/parse.test.ts b/panel/hooks/parse.test.ts new file mode 100644 index 0000000..5f4ced4 --- /dev/null +++ b/panel/hooks/parse.test.ts @@ -0,0 +1,55 @@ +import { expect, test } from 'claude-code/testing' + +import { activeTasks, isSafeProjectName, parseProgress, repoWebUrl, taskTotals } from './parse' + +const PROGRESS = `# Progress — Fix double rollout (CORE-1396) + +| Status | ID | Category | Owner | Summary | +| ------ | -- | -------- | ----- | ------- | +| ✅ done | TASK-8 | 🟢 Chore | 🙋 Owner | Paste the selector | +| 👀 ready for review #498 | PR-1 | 🔀 PR | — | ci: Fix staging · \`core-1396-staging-rollout\` · 21/400 | +| ✅ answered | Q7 | ❓ 🟦 | 🙋 Owner | Commit the script? | +| 🔄 in progress | TASK-3 | 🔴 Bug | ⚙️ Sonnet | Add --wait | +| ⬜ pending | TASK-4 | 🟢 Chore | 🙋 Owner | Verify on staging | +| ⬜ not opened | PR-2 | 🔀 PR | — | ci: Fix production | +| ❌ skipped | TASK-9 | 🟢 Chore | 🔧 Haiku | Delete script | +| ⬜ open | Q8 | ❓ ⚠️ | 🙋 Owner | Atomic? | +| 👀 pushed | #465 | 🔀 PR | — | core-1368-list-pause | +` + +test('parses the title, tasks, questions and PRs', () => { + const { title, rows } = parseProgress(PROGRESS) + expect(title).toBe('Fix double rollout (CORE-1396)') + expect(rows.map(row => `${row.kind}:${row.id}:${row.prNumber}`)).toEqual([ + 'task:TASK-8:null', + 'pr:PR-1:498', + 'question:Q7:null', + 'task:TASK-3:null', + 'task:TASK-4:null', + 'pr:PR-2:null', + 'task:TASK-9:null', + 'question:Q8:null', + 'pr:#465:465', + ]) +}) + +test('counts skipped tasks as done and lists in-progress before pending', () => { + const { rows } = parseProgress(PROGRESS) + expect(taskTotals(rows)).toEqual({ done: 2, total: 4 }) + expect(activeTasks(rows).map(row => row.id)).toEqual(['TASK-3', 'TASK-4']) +}) + +test('builds the GitHub URL from ssh and https remotes', () => { + expect(repoWebUrl('git@github.com:Resquared/re2recruit-web-client.git\n')).toBe( + 'https://github.com/Resquared/re2recruit-web-client', + ) + expect(repoWebUrl('https://github.com/Resquared/re2recruit-web-client')).toBe( + 'https://github.com/Resquared/re2recruit-web-client', + ) +}) + +test('refuses project names that escape the projects folder', () => { + expect(isSafeProjectName('core-1396-double-rollout')).toBe(true) + expect(isSafeProjectName('..')).toBe(false) + expect(isSafeProjectName('a/../b')).toBe(false) +}) diff --git a/panel/hooks/parse.ts b/panel/hooks/parse.ts new file mode 100644 index 0000000..9eed56e --- /dev/null +++ b/panel/hooks/parse.ts @@ -0,0 +1,75 @@ +import type { PlanRow, RowKind } from '../types' + +const SEPARATOR_CELL = /^:?-+:?$/ + +function rowKind(id: string, category: string): RowKind | null { + if (/^TASK-\d+/i.test(id)) return 'task' + if (/^Q\d+/i.test(id)) return 'question' + if (/^PR-\d+/i.test(id) || /^#\d+/.test(id) || category.includes('🔀')) return 'pr' + + return null +} + +export function parseProgress(markdown: string): { title: string; rows: PlanRow[] } { + const heading = markdown.match(/^#\s+(.+)$/m)?.[1] ?? '' + const title = heading.replace(/^Progress\s+[—-]\s+/, '').trim() + const rows: PlanRow[] = [] + + for (const line of markdown.split('\n')) { + if (!line.trim().startsWith('|')) continue + const cells = line + .trim() + .replace(/^\||\|$/g, '') + .split('|') + .map(cell => cell.trim()) + if (cells.length < 5 || cells.every(cell => SEPARATOR_CELL.test(cell)) || cells[1] === 'ID') continue + + const [status = '', id = '', category = '', owner = '', ...summaryCells] = cells + const kind = rowKind(id, category) + if (kind === null) continue + + const prMatch = kind === 'pr' ? `${id} ${status}`.match(/#(\d+)/) : null + rows.push({ + id, + kind, + status, + owner, + summary: summaryCells.join(' | ').replace(/`/g, ''), + prNumber: prMatch ? Number(prMatch[1]) : null, + }) + } + + return { title, rows } +} + +export function isTaskDone(status: string) { + return status.startsWith('✅') || status.startsWith('❌') +} + +export function isQuestionOpen(status: string) { + return !status.startsWith('✅') && !status.startsWith('❌') +} + +export function taskTotals(rows: PlanRow[]) { + const tasks = rows.filter(row => row.kind === 'task') + + return { done: tasks.filter(row => isTaskDone(row.status)).length, total: tasks.length } +} + +export function activeTasks(rows: PlanRow[], pendingLimit = 3) { + const tasks = rows.filter(row => row.kind === 'task') + const working = tasks.filter(row => /^(🔄|🚧|⚠️)/.test(row.status)) + const pending = tasks.filter(row => row.status.startsWith('⬜')).slice(0, pendingLimit) + + return [...working, ...pending] +} + +export function repoWebUrl(remote: string): string | null { + const match = remote.trim().match(/github\.com[:/]([^/]+)\/(.+?)(\.git)?$/) + + return match ? `https://github.com/${match[1]}/${match[2]}` : null +} + +export function isSafeProjectName(name: string) { + return /^[\w.-]+$/.test(name) && name !== '.' && name !== '..' +} diff --git a/panel/hooks/register.tsx b/panel/hooks/register.tsx new file mode 100644 index 0000000..179a5f5 --- /dev/null +++ b/panel/hooks/register.tsx @@ -0,0 +1,234 @@ +import { atom, read, update } from 'claude-code' +import type { EngineInterface, Register } from 'claude-code' + +import type { PlanBoard, PlanProject } from '../types' +import { activeTasks, isQuestionOpen, isSafeProjectName, parseProgress, repoWebUrl, taskTotals } from './parse' + +const PANE = 'taskflow-panel' +const TITLE = 'Taskflow' +const DEFAULT_PROJECTS_DIR = '.planning/projects' + +const board = atom({ plugin: 'taskflow-panel', key: 'board' } as const, null) +const selected = atom({ plugin: 'taskflow-panel', key: 'selected' } as const, null) +const pendingDelete = atom({ plugin: 'taskflow-panel', key: 'pendingDelete' } as const, null) +const notice = atom({ plugin: 'taskflow-panel', key: 'notice' } as const, null) + +async function repoRoot($: EngineInterface) { + const toplevel = await $.process.run(['git', 'rev-parse', '--show-toplevel']) + + return toplevel.exitCode === 0 ? toplevel.stdout.trim() : await $.session.cwd() +} + +async function readProjectsDir($: EngineInterface, root: string) { + try { + const config = JSON.parse(await $.fs.read(`${root}/.claude/workflow.json`)) + + return typeof config.projectsDir === 'string' ? config.projectsDir : DEFAULT_PROJECTS_DIR + } catch { + return DEFAULT_PROJECTS_DIR + } +} + +async function loadBoard($: EngineInterface) { + const root = await repoRoot($) + const projectsDir = await readProjectsDir($, root) + const projectsPath = `${root}/${projectsDir}` + const remote = await $.process.run(['git', 'remote', 'get-url', 'origin'], { cwd: root }) + const repoUrl = remote.exitCode === 0 ? repoWebUrl(remote.stdout) : null + + const projects: PlanProject[] = [] + if (await $.fs.exists(projectsPath)) { + for (const entry of await $.fs.list(projectsPath)) { + if (entry.kind !== 'dir') continue + const progressPath = `${projectsPath}/${entry.name}/PROGRESS.md` + if (!(await $.fs.exists(progressPath))) continue + const { title, rows } = parseProgress(await $.fs.read(progressPath)) + const { mtimeMs } = await $.fs.stat(progressPath) + projects.push({ name: entry.name, title: title || entry.name, rows, updatedAt: mtimeMs }) + } + } + projects.sort((first, second) => second.updatedAt - first.updatedAt) + + const next: PlanBoard = { projectsDir, repoUrl, projects } + await update($, board, () => next) + + const current = await read($, selected) + if (!projects.some(project => project.name === current)) { + await update($, selected, () => projects[0]?.name ?? null) + } +} + +async function deleteProject($: EngineInterface, name: string) { + const current = await read($, board) + const isKnown = current?.projects.some(project => project.name === name) ?? false + if (current === null || !isKnown || !isSafeProjectName(name)) { + await update($, notice, () => `Refused to delete "${name}".`) + return + } + + const target = `${await repoRoot($)}/${current.projectsDir}/${name}` + const removal = await $.process.run(['rm', '-rf', '--', target]) + await update($, pendingDelete, () => null) + await update($, notice, () => + removal.exitCode === 0 ? `Deleted ${current.projectsDir}/${name}` : `Delete failed: ${removal.stderr.trim()}`, + ) + await update($, selected, () => null) + await loadBoard($) +} + +async function openPane($: EngineInterface, focus = false) { + await $.ui.open({ id: PANE, title: TITLE, columns: 60, ...(focus ? { focus: true as const } : {}) }) +} + +export const register: Register = on => { + on('session.start', async ($, e, next) => { + await $.command.register({ name: 'taskflow', description: 'Open the Taskflow pane: plans, tasks, PRs' }) + void loadBoard($) + void openPane($) + + return next(e) + }) + + on('command.run', { command: 'taskflow' }, async $ => { + await loadBoard($) + await openPane($, true) + + return { text: 'Taskflow pane opened.' } + }) + + on('turn.complete', async ($, e, next) => { + void loadBoard($) + + return next(e) + }) + + on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => { + const { Box, Text, Button, Link } = $.ui.resolve(e) + const state = await read($, board) + const selectedName = await read($, selected) + const deleting = await read($, pendingDelete) + const message = await read($, notice) + + if (state === null) return Loading… + if (state.projects.length === 0) { + return ( + + No plans in {state.projectsDir}. + {message && {message}} + + ) + } + + const project = state.projects.find(candidate => candidate.name === selectedName) ?? state.projects[0] + if (project === undefined) return No plans. + const { done, total } = taskTotals(project.rows) + const percent = total === 0 ? 0 : Math.round((done / total) * 100) + const barWidth = 20 + const filled = Math.round((percent / 100) * barWidth) + const active = activeTasks(project.rows) + const pullRequests = project.rows.filter(row => row.kind === 'pr') + const openedPullRequests = pullRequests.filter(row => row.prNumber !== null) + const openQuestions = project.rows.filter(row => row.kind === 'question' && isQuestionOpen(row.status)) + + return ( + + + Plans + {state.projects.slice(0, 9).map((candidate, index) => { + const totals = taskTotals(candidate.rows) + const isCurrent = candidate.name === project.name + + return ( + + ) + })} + + + + + {project.title} + + + {'█'.repeat(filled)} + {'░'.repeat(barWidth - filled)} {done}/{total} tasks · {percent}% + + + + + Active tasks + {active.length === 0 && Nothing left to do.} + {active.map(row => ( + + + {row.status.split(' ').slice(0, 2).join(' ')} + {' '} + {row.id} {row.owner} + {'\n '} + {row.summary} + + ))} + {openQuestions.length > 0 && ( + + {openQuestions.length} open question(s): {openQuestions.map(row => row.id).join(', ')} + + )} + + + + + Pull requests {openedPullRequests.length} + created of {pullRequests.length} + + {pullRequests.map(row => ( + + {row.status}{' '} + {row.prNumber !== null && state.repoUrl !== null ? ( + + ) : ( + {row.id} + )}{' '} + {row.summary.split(' · ')[0]} + + ))} + + + + {deleting === project.name ? ( + + + Delete {state.projectsDir}/{project.name}? This cannot be undone. + + + - ) - })} - - - - - {project.title} - - - {'█'.repeat(filled)} - {'░'.repeat(barWidth - filled)} {done}/{total} tasks · {percent}% - - - - - Active tasks - {active.length === 0 && Nothing left to do.} - {active.map(row => ( - - - {row.status.split(' ').slice(0, 2).join(' ')} - {' '} - {row.id} {row.owner} - {'\n '} - {row.summary} - - ))} - {openQuestions.length > 0 && ( - - {openQuestions.length} open question(s): {openQuestions.map(row => row.id).join(', ')} - - )} - - - - - Pull requests {openedPullRequests.length} - created of {pullRequests.length} - - {pullRequests.map(row => ( - - {row.status}{' '} - {row.prNumber !== null && state.repoUrl !== null ? ( - - ) : ( - {row.id} - )}{' '} - {row.summary.split(' · ')[0]} - - ))} - - - - {deleting === project.name ? ( - - - Delete {state.projectsDir}/{project.name}? This cannot be undone. - - - + ) + })} + + + + + {project.title} + + + {'█'.repeat(filled)} + {'░'.repeat(barWidth - filled)} {done}/{total} tasks · {percent}% + + + + + Active tasks + {active.length === 0 && Nothing left to do.} + {active.map(row => ( + + + {row.status.split(' ').slice(0, 2).join(' ')} + {' '} + {row.id} {row.owner} + {'\n '} + {row.summary} + + ))} + {openQuestions.length > 0 && ( + + {openQuestions.length} open question(s): {openQuestions.map(row => row.id).join(', ')} + + )} + + + + + Pull requests {openedPullRequests.length} + created of {pullRequests.length} + + {pullRequests.map(row => ( + + {row.status}{' '} + {row.prNumber !== null && state.repoUrl !== null ? ( + + ) : ( + {row.id} + )}{' '} + {row.summary.split(' · ')[0]} + + ))} + + + + {deleting === project.name ? ( + + + Delete {state.projectsDir}/{project.name}? This cannot be undone. + + + + + {progressBar(totals.done, totals.total, 12)} {totals.done}/{totals.total} tasks + + + {working ? `${working.id} ${working.summary}` : totals.done === totals.total ? 'All tasks done' : 'Nothing in progress'} + + + {opened}/{pullRequests.length} PRs opened + {questions > 0 && · {questions} open question(s)} + + + ) + })} + + - ) - })} - - {project.title} - {'█'.repeat(filled)} - {'░'.repeat(barWidth - filled)} {done}/{total} tasks · {percent}% + {progressBar(done, total, 20)} {done}/{total} tasks · {percent}% @@ -120,17 +149,26 @@ export async function renderPane($: EngineInterface, e: RenderInput<'Pane'>) { Pull requests {openedPullRequests.length} created of {pullRequests.length} - {pullRequests.map(row => ( - - {row.status}{' '} - {row.prNumber !== null && state.repoUrl !== null ? ( - - ) : ( - {row.id} - )}{' '} - {row.summary.split(' · ')[0]} - - ))} + {pullRequests.map(row => { + const worktree = row.branch === null ? undefined : state.worktrees[row.branch] + + return ( + + + {row.status}{' '} + {row.prNumber !== null && state.repoUrl !== null ? ( + + ) : ( + {row.id} + )}{' '} + {row.summary.split(' · ')[0]} + + + {' '}branch {row.branch ?? 'not named'} · worktree {worktree ?? 'not checked out'} + + + ) + })} diff --git a/types/index.d.ts b/types/index.d.ts index 12fd1cf..2df1f93 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -7,6 +7,7 @@ export type PlanRow = { owner: string summary: string prNumber: number | null + branch: string | null } export type PlanProject = { @@ -19,6 +20,7 @@ export type PlanProject = { export type PlanBoard = { projectsDir: string repoUrl: string | null + worktrees: Record projects: PlanProject[] } From 40dac6d98881fb5530689036e9e6818b7a87e39f Mon Sep 17 00:00:00 2001 From: Guilherme Moraes Date: Fri, 16 Oct 2026 19:57:07 -0300 Subject: [PATCH 06/30] chore: type-check the panel in the editor Adds a tsconfig with the plugin compiler settings, JSX through h and no DOM. Claude Code's plugin API types are copied into .claude-plugin/types/ locally and kept out of git, since each Claude Code version writes its own. --- .gitignore | 3 +++ tsconfig.json | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 tsconfig.json diff --git a/.gitignore b/.gitignore index 7ae0b08..8c3fce6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ # Local working notes - research, comparisons, improvement plans. # Kept out of the plugin: what ships is the procedure, not the reasoning behind it. docs/ + +# Claude Code's plugin API types, written per Claude Code version - copied in locally for the editor. +.claude-plugin/types/ diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..983647f --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "target": "es2023", + "lib": ["es2023"], + "types": [], + "module": "esnext", + "moduleResolution": "bundler", + "strict": true, + "noUncheckedIndexedAccess": true, + "noEmit": true, + "skipLibCheck": true, + "jsx": "react", + "jsxFactory": "h", + "jsxFragmentFactory": "Fragment" + }, + "include": [".claude-plugin/types", "panel", "types"] +} From d23e03674153e3e46afe7bc0a4d52d81ed7c09fc Mon Sep 17 00:00:00 2001 From: Guilherme Moraes Date: Fri, 16 Oct 2026 20:09:28 -0300 Subject: [PATCH 07/30] chore: add a Prettier config that matches the code style Single quotes, no semicolons, 120 columns. Quoted keys stay quoted, so the state key in types/index.d.ts keeps the shape sync.sh renames. --- .prettierrc.json | 8 ++++++++ panel/domain/mascot.ts | 2 -- panel/ui/pane.tsx | 36 +++++++++++++++++++++++++++++------- 3 files changed, 37 insertions(+), 9 deletions(-) create mode 100644 .prettierrc.json diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..2ea6215 --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,8 @@ +{ + "semi": false, + "singleQuote": true, + "printWidth": 120, + "trailingComma": "all", + "arrowParens": "avoid", + "quoteProps": "preserve" +} diff --git a/panel/domain/mascot.ts b/panel/domain/mascot.ts index ed2ffb0..7fe4464 100644 --- a/panel/domain/mascot.ts +++ b/panel/domain/mascot.ts @@ -40,8 +40,6 @@ const FRAMES: Record = { done: [...HEAD, LIDS, ...Array(4).fill(eyes('GG', 'GG', 'GG')), LIDS, ...VISOR_BOTTOM], } -export const MASCOT_SPEECH_ROW = 4 - export type MascotCell = { top?: string; bottom?: string } export function mascotMood(rows: PlanRow[]): MascotMood { diff --git a/panel/ui/pane.tsx b/panel/ui/pane.tsx index ccf0a6f..e3da633 100644 --- a/panel/ui/pane.tsx +++ b/panel/ui/pane.tsx @@ -2,7 +2,7 @@ import { atom, read, update } from 'claude-code' import type { EngineInterface, RenderInput } from 'claude-code' import { deleteProject, loadBoard } from '../data/board' -import { MASCOT_SPEECH_ROW, mascotArt, mascotLine, mascotMood } from '../domain/mascot' +import { mascotArt, mascotLine, mascotMood } from '../domain/mascot' import { activeTasks, isQuestionOpen, taskTotals } from '../domain/parse' const board = atom({ plugin: 'taskflow', key: 'board' } as const, null) @@ -62,10 +62,17 @@ export async function renderPane($: EngineInterface, e: RenderInput<'Pane'>) { {candidate.title} - {progressBar(totals.done, totals.total, 12)} {totals.done}/{totals.total} tasks + {progressBar(totals.done, totals.total, 12)}{' '} + + {totals.done}/{totals.total} tasks + - {working ? `${working.id} ${working.summary}` : totals.done === totals.total ? 'All tasks done' : 'Nothing in progress'} + {working + ? `${working.id} ${working.summary}` + : totals.done === totals.total + ? 'All tasks done' + : 'Nothing in progress'} {opened}/{pullRequests.length} PRs opened @@ -110,9 +117,9 @@ export async function renderPane($: EngineInterface, e: RenderInput<'Pane'>) { ' ' ), )} - {row === MASCOT_SPEECH_ROW && {mascotLine(mood, total - done)}} ))} + {mascotLine(mood, total - done)} @@ -178,13 +185,28 @@ export async function renderPane($: EngineInterface, e: RenderInput<'Pane'>) { Delete {state.projectsDir}/{project.name}? This cannot be undone. - + + {' '} + + {done}/{total} tasks + + + + {working ? `${working.id} ${working.summary}` : done === total ? 'All tasks done' : 'Nothing in progress'} + + + {opened}/{pullRequests.length} PRs opened + {questions > 0 && · {questions} open question(s)} + + + ) +} diff --git a/panel/ui/components/PlanDetail.tsx b/panel/ui/components/PlanDetail.tsx new file mode 100644 index 0000000..3679b9e --- /dev/null +++ b/panel/ui/components/PlanDetail.tsx @@ -0,0 +1,104 @@ +import type { PlanBoard, PlanProject } from '../../../types' +import { activeTasks, isQuestionOpen, taskTotals } from '../../domain/parse' +import { Mascot } from './Mascot' +import { ProgressBar } from './ProgressBar' +import { PullRequestItem } from './PullRequestItem' +import type { Ui } from './ui' + +type PlanDetailProps = { + ui: Ui + board: PlanBoard + project: PlanProject + isDeleting: boolean + message: string | null + onBack: () => void + onNextTask: () => void + onRefresh: () => void + onAskDelete: () => void + onConfirmDelete: () => void + onCancelDelete: () => void +} + +export function PlanDetail(props: PlanDetailProps) { + const { ui, board, project, isDeleting, message } = props + const { Box, Text, Button } = ui + const { done, total } = taskTotals(project.rows) + const percent = total === 0 ? 0 : Math.round((done / total) * 100) + const active = activeTasks(project.rows) + const pullRequests = project.rows.filter(row => row.kind === 'pr') + const opened = pullRequests.filter(row => row.prNumber !== null).length + const openQuestions = project.rows.filter(row => row.kind === 'question' && isQuestionOpen(row.status)) + + return ( + + + - - {progressBar(totals.done, totals.total, 12)}{' '} - - {totals.done}/{totals.total} tasks - - - - {working - ? `${working.id} ${working.summary}` - : totals.done === totals.total - ? 'All tasks done' - : 'Nothing in progress'} - - - {opened}/{pullRequests.length} PRs opened - {questions > 0 && · {questions} open question(s)} - - - ) - })} - -