Render renders the PRD picker modal.
()
| 426 | |
| 427 | // Render renders the PRD picker modal. |
| 428 | func (p *PRDPicker) Render() string { |
| 429 | // Modal dimensions |
| 430 | modalWidth := min(60, p.width-10) |
| 431 | modalHeight := min(20, p.height-6) |
| 432 | |
| 433 | if modalWidth < 30 { |
| 434 | modalWidth = 30 |
| 435 | } |
| 436 | if modalHeight < 10 { |
| 437 | modalHeight = 10 |
| 438 | } |
| 439 | |
| 440 | // If there's a clean result, render that instead |
| 441 | if p.cleanResult != nil { |
| 442 | return p.renderCleanResult(modalWidth, modalHeight) |
| 443 | } |
| 444 | |
| 445 | // If there's a clean confirmation, render that instead |
| 446 | if p.cleanConfirmation != nil { |
| 447 | return p.renderCleanConfirmation(modalWidth, modalHeight) |
| 448 | } |
| 449 | |
| 450 | // If there's a merge result, render that instead |
| 451 | if p.mergeResult != nil { |
| 452 | return p.renderMergeResult(modalWidth, modalHeight) |
| 453 | } |
| 454 | |
| 455 | // Build modal content |
| 456 | var content strings.Builder |
| 457 | |
| 458 | // Title |
| 459 | titleStyle := lipgloss.NewStyle(). |
| 460 | Bold(true). |
| 461 | Foreground(PrimaryColor). |
| 462 | Padding(0, 1) |
| 463 | content.WriteString(titleStyle.Render("Select PRD")) |
| 464 | content.WriteString("\n") |
| 465 | content.WriteString(DividerStyle.Render(strings.Repeat("─", modalWidth-4))) |
| 466 | content.WriteString("\n") |
| 467 | |
| 468 | if p.inputMode { |
| 469 | // Input mode for new PRD name |
| 470 | content.WriteString(p.renderInputMode(modalWidth - 4)) |
| 471 | } else if p.IsEmpty() { |
| 472 | // Empty state |
| 473 | emptyStyle := lipgloss.NewStyle(). |
| 474 | Foreground(MutedColor). |
| 475 | Padding(1, 2) |
| 476 | content.WriteString(emptyStyle.Render("No PRDs found in .chief/prds/")) |
| 477 | content.WriteString("\n") |
| 478 | content.WriteString(emptyStyle.Render("Press 'n' to create a new PRD")) |
| 479 | } else { |
| 480 | // PRD list |
| 481 | listHeight := modalHeight - 7 // Account for title, borders, footer |
| 482 | startIdx := 0 |
| 483 | if p.selectedIndex >= listHeight { |
| 484 | startIdx = p.selectedIndex - listHeight + 1 |
| 485 | } |