devbook-tui 1.1.0

A fast, keyboard-driven terminal user interface for Devbook prompt engineering workbench
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
use ratatui::{
    layout::{Constraint, Direction, Layout, Rect},
    style::{Color, Modifier, Style},
    text::{Line, Span},
    widgets::{Block, BorderType, Borders, Clear, List, ListItem, Paragraph, Wrap},
    Frame,
};

use crate::app::{App, DeleteTarget, Modal};
use crate::format::format_bytes;
use crate::input::{InputMode, TextInput};
use crate::ui::theme;

fn render_text_input(input: &TextInput, is_active: bool) -> Vec<Span<'static>> {
    let base_style = if is_active {
        Style::default().fg(theme::FG_TEXT).bg(theme::BG_HIGHLIGHT)
    } else {
        Style::default().fg(theme::FG_MUTED)
    };

    if !is_active {
        return vec![Span::styled(input.value.clone(), base_style)];
    }

    let chars: Vec<char> = input.value.chars().collect();
    let cursor = input.cursor.min(chars.len());
    let before: String = chars[..cursor].iter().collect();
    let cursor_ch = chars.get(cursor).copied().unwrap_or(' ');
    let after: String = if cursor < chars.len() {
        chars[cursor + 1..].iter().collect()
    } else {
        String::new()
    };

    let cursor_style = match input.mode {
        InputMode::Insert => Style::default()
            .fg(theme::BG_DARK)
            .bg(theme::ACCENT_GREEN)
            .add_modifier(Modifier::BOLD),
        InputMode::Normal => Style::default()
            .fg(theme::BG_DARK)
            .bg(theme::ACCENT_BLUE)
            .add_modifier(Modifier::BOLD),
    };

    let mut spans = Vec::new();
    if !before.is_empty() {
        spans.push(Span::styled(before, base_style));
    }
    spans.push(Span::styled(cursor_ch.to_string(), cursor_style));
    if !after.is_empty() {
        spans.push(Span::styled(after, base_style));
    }
    spans
}

pub fn render(f: &mut Frame, app: &App) {
    let modal = match &app.modal {
        Some(m) => m,
        None => return,
    };

    match modal {
        Modal::HostSwitcher {
            cursor,
            custom_input,
            entering_custom,
        } => render_host_switcher(f, app, *cursor, custom_input, *entering_custom),
        Modal::Search { input } => render_search(f, input),
        Modal::QuickAppendPrompt {
            content_input,
            section_input,
            as_task,
            focus_field,
        } => render_quick_append(f, content_input, section_input, *as_task, *focus_field),
        Modal::ProjectForm {
            id,
            name_input,
            desc_input,
            focus_desc,
        } => render_project_form(f, id.is_some(), name_input, desc_input, *focus_desc),
        Modal::PromptForm {
            id,
            title_input,
            project_choice_idx,
            pinned,
            focus_field,
        } => render_prompt_form(
            f,
            app,
            id.is_some(),
            title_input,
            *project_choice_idx,
            *pinned,
            *focus_field,
        ),
        Modal::ConfirmDelete { target } => render_confirm_delete(f, target),
        Modal::Attachments {
            cursor,
            upload_input,
            dest_input,
        } => render_attachments(
            f,
            app,
            *cursor,
            upload_input.as_ref(),
            dest_input.as_ref(),
        ),
        Modal::Help => render_help(f, app.config.allow_host_switcher),
    }
}

fn centered_rect(percent_x: u16, percent_y: u16, r: Rect) -> Rect {
    let popup_layout = Layout::default()
        .direction(Direction::Vertical)
        .constraints([
            Constraint::Percentage((100 - percent_y) / 2),
            Constraint::Percentage(percent_y),
            Constraint::Percentage((100 - percent_y) / 2),
        ])
        .split(r);

    Layout::default()
        .direction(Direction::Horizontal)
        .constraints([
            Constraint::Percentage((100 - percent_x) / 2),
            Constraint::Percentage(percent_x),
            Constraint::Percentage((100 - percent_x) / 2),
        ])
        .split(popup_layout[1])[1]
}

fn render_host_switcher(
    f: &mut Frame,
    app: &App,
    cursor: usize,
    custom_input: &TextInput,
    entering_custom: bool,
) {
    let area = centered_rect(60, 45, f.area());
    f.render_widget(Clear, area);

    let block = Block::default()
        .title(" Switch Devbook Host URL ")
        .borders(Borders::ALL)
        .border_type(BorderType::Thick)
        .border_style(Style::default().fg(theme::ACCENT_BLUE))
        .style(Style::default().bg(theme::BG_DARK));

    let inner = block.inner(area);
    f.render_widget(block, area);

    let mut lines = Vec::new();
    lines.push(Line::from(Span::styled(
        format!("Current Active Host: {}", app.config.base_url),
        Style::default()
            .fg(Color::LightCyan)
            .add_modifier(Modifier::BOLD),
    )));
    lines.push(Line::from(""));
    lines.push(Line::from(Span::styled(
        "Preset Hosts:",
        Style::default().fg(Color::Gray),
    )));

    for (i, preset) in app.preset_hosts.iter().enumerate() {
        let is_sel = !entering_custom && cursor == i;
        let prefix = if is_sel { " ▶ " } else { "   " };
        let style = if is_sel {
            Style::default()
                .fg(Color::Cyan)
                .add_modifier(Modifier::BOLD)
        } else if *preset == app.config.base_url {
            Style::default().fg(Color::Green)
        } else {
            Style::default().fg(Color::White)
        };
        let active_mark = if *preset == app.config.base_url {
            " (active)"
        } else {
            ""
        };
        lines.push(Line::from(vec![
            Span::styled(prefix, style),
            Span::styled(preset.as_str(), style),
            Span::styled(active_mark, Style::default().fg(Color::Green)),
        ]));
    }

    lines.push(Line::from(""));
    let custom_sel = entering_custom || cursor == app.preset_hosts.len();
    let custom_prefix = if custom_sel {
        " ▶ Custom URL: "
    } else {
        "   Custom URL: "
    };
    let custom_style = if custom_sel {
        Style::default()
            .fg(Color::Cyan)
            .add_modifier(Modifier::BOLD)
    } else {
        Style::default().fg(Color::Gray)
    };

    let mut custom_line = vec![Span::styled(custom_prefix, custom_style)];
    if custom_input.value.is_empty() && !entering_custom {
        custom_line.push(Span::styled(
            "(type or press c to enter)",
            Style::default().fg(theme::FG_MUTED),
        ));
    } else {
        custom_line.extend(render_text_input(custom_input, entering_custom));
    }
    lines.push(Line::from(custom_line));

    lines.push(Line::from(""));
    lines.push(Line::from(Span::styled(
        "Keys: j/k: select preset | Enter: switch | c: custom input | Esc: cancel",
        Style::default().fg(Color::DarkGray),
    )));

    f.render_widget(Paragraph::new(lines).wrap(Wrap { trim: false }), inner);
}

fn render_search(f: &mut Frame, input: &TextInput) {
    let area = centered_rect(60, 20, f.area());
    f.render_widget(Clear, area);

    let block = Block::default()
        .title(" Search Prompts ")
        .borders(Borders::ALL)
        .border_type(BorderType::Thick)
        .border_style(Style::default().fg(theme::ACCENT_BLUE))
        .style(Style::default().bg(theme::BG_DARK));

    let inner = block.inner(area);
    f.render_widget(block, area);

    let mut query_line = vec![Span::styled(
        " Query: ",
        Style::default().fg(theme::ACCENT_CYAN),
    )];
    query_line.extend(render_text_input(input, true));

    let lines = vec![
        Line::from(Span::styled(
            "Type search query (matches title or prompt body):",
            Style::default().fg(theme::FG_MUTED),
        )),
        Line::from(""),
        Line::from(query_line),
        Line::from(""),
        Line::from(Span::styled(
            "Press Enter to apply filter, Esc to cancel / clear",
            Style::default().fg(theme::FG_MUTED),
        )),
    ];

    f.render_widget(Paragraph::new(lines), inner);
}

fn render_quick_append(
    f: &mut Frame,
    content_input: &TextInput,
    section_input: &TextInput,
    as_task: bool,
    focus_field: usize,
) {
    let area = centered_rect(65, 45, f.area());
    f.render_widget(Clear, area);

    let block = Block::default()
        .title(" Quick Append to Prompt ")
        .borders(Borders::ALL)
        .border_type(BorderType::Thick)
        .border_style(Style::default().fg(theme::ACCENT_BLUE))
        .style(Style::default().bg(theme::BG_DARK));

    let inner = block.inner(area);
    f.render_widget(block, area);

    let task_mode_str = if as_task {
        "[x] Append as checklist task (- [ ] ...)"
    } else {
        "[ ] Append as normal Markdown prose"
    };

    let task_style = if as_task {
        Style::default()
            .fg(theme::ACCENT_GREEN)
            .add_modifier(Modifier::BOLD)
    } else {
        Style::default().fg(theme::FG_MUTED)
    };

    let mut sec_line = vec![Span::styled(
        " Section: ## ",
        Style::default().fg(theme::ACCENT_BLUE),
    )];
    sec_line.extend(render_text_input(section_input, focus_field == 0));

    let mut content_line = vec![Span::styled(
        " Text:    ",
        Style::default().fg(theme::ACCENT_BLUE),
    )];
    content_line.extend(render_text_input(content_input, focus_field == 1));

    let lines = vec![
        Line::from(Span::styled(
            "Optional Section Heading (e.g. 'Instructions' or 'Examples'):",
            Style::default().fg(theme::ACCENT_CYAN),
        )),
        Line::from(sec_line),
        Line::from(""),
        Line::from(Span::styled(
            "Content to append:",
            Style::default().fg(theme::ACCENT_CYAN),
        )),
        Line::from(content_line),
        Line::from(""),
        Line::from(Span::styled(task_mode_str, task_style)),
        Line::from(""),
        Line::from(Span::styled(
            "Keys: Tab: switch field | Space: toggle task | Enter: append | Esc: cancel",
            Style::default().fg(theme::FG_MUTED),
        )),
    ];

    f.render_widget(Paragraph::new(lines).wrap(Wrap { trim: false }), inner);
}

fn render_project_form(
    f: &mut Frame,
    is_edit: bool,
    name_input: &TextInput,
    desc_input: &TextInput,
    focus_desc: bool,
) {
    let area = centered_rect(55, 35, f.area());
    f.render_widget(Clear, area);

    let title = if is_edit {
        " Edit Project "
    } else {
        " Create New Project "
    };

    let block = Block::default()
        .title(title)
        .borders(Borders::ALL)
        .border_type(BorderType::Thick)
        .border_style(Style::default().fg(theme::ACCENT_BLUE))
        .style(Style::default().bg(theme::BG_DARK));

    let inner = block.inner(area);
    f.render_widget(block, area);

    let mut name_line = vec![Span::styled(
        " Name: ",
        Style::default().fg(theme::ACCENT_BLUE),
    )];
    name_line.extend(render_text_input(name_input, !focus_desc));

    let mut desc_line = vec![Span::styled(
        " Desc: ",
        Style::default().fg(theme::ACCENT_BLUE),
    )];
    desc_line.extend(render_text_input(desc_input, focus_desc));

    let lines = vec![
        Line::from(Span::styled(
            "Project Name (required):",
            Style::default().fg(theme::ACCENT_CYAN),
        )),
        Line::from(name_line),
        Line::from(""),
        Line::from(Span::styled(
            "Description (optional):",
            Style::default().fg(theme::ACCENT_CYAN),
        )),
        Line::from(desc_line),
        Line::from(""),
        Line::from(Span::styled(
            "Keys: Tab: switch field | Enter: save | Esc: cancel",
            Style::default().fg(theme::FG_MUTED),
        )),
    ];

    f.render_widget(Paragraph::new(lines).wrap(Wrap { trim: false }), inner);
}

fn render_prompt_form(
    f: &mut Frame,
    app: &App,
    is_edit: bool,
    title_input: &TextInput,
    project_choice_idx: usize,
    pinned: bool,
    focus_field: usize,
) {
    let area = centered_rect(65, 45, f.area());
    f.render_widget(Clear, area);

    let modal_title = if is_edit {
        " Edit Prompt Metadata "
    } else {
        " Create New Prompt "
    };

    let block = Block::default()
        .title(modal_title)
        .borders(Borders::ALL)
        .border_type(BorderType::Thick)
        .border_style(Style::default().fg(theme::ACCENT_BLUE))
        .style(Style::default().bg(theme::BG_DARK));

    let inner = block.inner(area);
    f.render_widget(block, area);

    let proj_label = if project_choice_idx == 0 {
        "(None — Standalone scratchpad)".to_string()
    } else if let Some(p) = app.projects.get(project_choice_idx - 1) {
        format!("{} (ID: {})", p.name, p.id)
    } else {
        "(None)".to_string()
    };

    let proj_style = if focus_field == 1 {
        Style::default()
            .fg(Color::Cyan)
            .add_modifier(Modifier::BOLD)
    } else {
        Style::default().fg(Color::Gray)
    };

    let pin_str = if pinned {
        "[x] Pinned (★)"
    } else {
        "[ ] Not Pinned"
    };

    let pin_style = if focus_field == 2 {
        Style::default()
            .fg(Color::LightCyan)
            .add_modifier(Modifier::BOLD)
    } else {
        Style::default().fg(Color::Gray)
    };

    let mut title_line = vec![Span::styled(
        " Title:   ",
        Style::default().fg(theme::ACCENT_BLUE),
    )];
    title_line.extend(render_text_input(title_input, focus_field == 0));

    let lines = vec![
        Line::from(Span::styled(
            "Prompt Title (required):",
            Style::default().fg(theme::ACCENT_CYAN),
        )),
        Line::from(title_line),
        Line::from(""),
        Line::from(Span::styled(
            "Assigned Project (Left/Right to choose):",
            Style::default().fg(Color::LightCyan),
        )),
        Line::from(vec![
            Span::styled(" Project: ", Style::default().fg(Color::Cyan)),
            Span::styled(format!("◀ {} ▶", proj_label), proj_style),
        ]),
        Line::from(""),
        Line::from(vec![
            Span::styled(" Pinned:  ", Style::default().fg(Color::Cyan)),
            Span::styled(pin_str, pin_style),
        ]),
        Line::from(""),
        Line::from(Span::styled(
            "Keys: Tab/Shift-Tab: navigate | h/l: select project | Space: toggle pin | Enter: save | Esc: cancel",
            Style::default().fg(Color::DarkGray),
        )),
    ];

    f.render_widget(Paragraph::new(lines).wrap(Wrap { trim: false }), inner);
}

fn render_confirm_delete(f: &mut Frame, target: &DeleteTarget) {
    let area = centered_rect(50, 25, f.area());
    f.render_widget(Clear, area);

    let (type_name, obj_name) = match target {
        DeleteTarget::Project(p) => ("Project", p.name.as_str()),
        DeleteTarget::Prompt(p) => ("Prompt", p.title.as_str()),
        DeleteTarget::Attachment { filename, .. } => ("Attachment", filename.as_str()),
    };

    let block = Block::default()
        .title(format!(" Confirm Delete {} ", type_name))
        .borders(Borders::ALL)
        .border_type(BorderType::Rounded)
        .border_style(Style::default().fg(Color::Red));

    let inner = block.inner(area);
    f.render_widget(block, area);

    let lines = vec![
        Line::from(Span::styled(
            format!("Are you sure you want to delete this {}?", type_name),
            Style::default().fg(Color::White),
        )),
        Line::from(""),
        Line::from(Span::styled(
            format!("  ▶ \"{}\"", obj_name),
            Style::default()
                .fg(Color::Red)
                .add_modifier(Modifier::BOLD),
        )),
        Line::from(""),
        Line::from(Span::styled(
            "Press 'y' to confirm delete, 'n' or Esc to cancel",
            Style::default().fg(Color::DarkGray),
        )),
    ];

    f.render_widget(Paragraph::new(lines).wrap(Wrap { trim: false }), inner);
}

fn render_attachments(
    f: &mut Frame,
    app: &App,
    cursor: usize,
    upload_input: Option<&TextInput>,
    dest_input: Option<&TextInput>,
) {
    let area = centered_rect(75, 65, f.area());
    f.render_widget(Clear, area);

    let prompt_title = app
        .current_prompt
        .as_ref()
        .map(|p| p.title.as_str())
        .unwrap_or("Prompt");

    let block = Block::default()
        .title(format!(" Attachments Manager — \"{}\" ", prompt_title))
        .borders(Borders::ALL)
        .border_type(BorderType::Rounded)
        .border_style(Style::default().fg(Color::Cyan));

    let inner = block.inner(area);
    f.render_widget(block, area);

    // If entering upload path or download destination
    if let Some(input) = upload_input {
        let input_lines = vec![
            Line::from(Span::styled(
                "Upload File to Prompt Attachments",
                Style::default()
                    .fg(Color::Cyan)
                    .add_modifier(Modifier::BOLD),
            )),
            Line::from(""),
            Line::from(Span::styled(
                "Enter absolute or relative path to file:",
                Style::default().fg(Color::Gray),
            )),
            Line::from({
                let mut line = vec![Span::styled(" Path: ", Style::default().fg(theme::ACCENT_CYAN))];
                line.extend(render_text_input(input, true));
                line
            }),
            Line::from(""),
            Line::from(Span::styled(
                "Press Enter to upload, Esc to cancel",
                Style::default().fg(Color::DarkGray),
            )),
        ];
        f.render_widget(Paragraph::new(input_lines), inner);
        return;
    }

    if let Some(input) = dest_input {
        let input_lines = vec![
            Line::from(Span::styled(
                "Save Attachment to Local Disk",
                Style::default()
                    .fg(Color::Cyan)
                    .add_modifier(Modifier::BOLD),
            )),
            Line::from(""),
            Line::from(Span::styled(
                "Enter destination file path:",
                Style::default().fg(Color::Gray),
            )),
            Line::from({
                let mut line = vec![Span::styled(" Dest: ", Style::default().fg(theme::ACCENT_CYAN))];
                line.extend(render_text_input(input, true));
                line
            }),
            Line::from(""),
            Line::from(Span::styled(
                "Press Enter to download, Esc to cancel",
                Style::default().fg(Color::DarkGray),
            )),
        ];
        f.render_widget(Paragraph::new(input_lines), inner);
        return;
    }

    let mut items = Vec::new();
    let attachments = app
        .current_prompt
        .as_ref()
        .map(|p| &p.attachments)
        .cloned()
        .unwrap_or_default();

    if attachments.is_empty() {
        items.push(ListItem::new(Line::from(Span::styled(
            "  (no attachments on this prompt — press 'u' to upload a file)",
            Style::default().fg(Color::DarkGray),
        ))));
    } else {
        for (i, att) in attachments.iter().enumerate() {
            let is_sel = cursor == i;
            let prefix = if is_sel { "▶ " } else { "  " };
            let style = if is_sel {
                Style::default()
                    .fg(Color::Cyan)
                    .add_modifier(Modifier::BOLD)
            } else {
                Style::default().fg(Color::White)
            };

            let size_str = format_bytes(att.byte_size.unwrap_or(0));
            let line = Line::from(vec![
                Span::styled(prefix, style),
                Span::styled(format!("{:<30} ", att.filename), style),
                Span::styled(
                    format!("{:>10} ", size_str),
                    Style::default().fg(Color::LightCyan),
                ),
                Span::styled(
                    att.content_type.as_deref().unwrap_or("unknown"),
                    Style::default().fg(Color::DarkGray),
                ),
            ]);
            items.push(ListItem::new(line));
        }
    }

    let layout = Layout::default()
        .direction(Direction::Vertical)
        .constraints([Constraint::Min(0), Constraint::Length(2)])
        .split(inner);

    f.render_widget(List::new(items), layout[0]);

    let footer = Paragraph::new(Line::from(Span::styled(
        "Keys: j/k: select | u: upload file | s: save to disk | y: copy URL | d: delete | Esc: close",
        Style::default().fg(Color::DarkGray),
    )));
    f.render_widget(footer, layout[1]);
}

fn render_help(f: &mut Frame, allow_switch: bool) {
    let area = centered_rect(76, 78, f.area());
    f.render_widget(Clear, area);

    let block = Block::default()
        .title(" Devbook-TUI Keyboard Shortcuts & Help ")
        .borders(Borders::ALL)
        .border_type(BorderType::Rounded)
        .border_style(Style::default().fg(Color::Cyan));

    let inner = block.inner(area);
    f.render_widget(block, area);

    let host_line = if allow_switch {
        Line::from("  H / u          Switch Host URL presets or enter custom URL")
    } else {
        Line::from(
            "  H / u          [Locked by DEVBOOK_REMOTE_URL] (pass --allow-switch to enable)",
        )
    };

    let lines = vec![
        Line::from(Span::styled(
            "Navigation & Focus",
            Style::default()
                .fg(Color::Cyan)
                .add_modifier(Modifier::BOLD),
        )),
        Line::from("  1, 2, 3        Direct focus to pane 1 (Sidebar), 2 (Prompts), 3 (Detail)"),
        Line::from("  Tab / BackTab  Cycle focus forward / backward between panes"),
        Line::from("  h / l          Move focus left / right"),
        Line::from("  j / k          Move selection down / up in focused pane"),
        Line::from("  Enter          Enter pane 2 from sidebar, or pane 3 from prompts list"),
        Line::from(""),
        Line::from(Span::styled(
            "Prompt Detail, Markdown & Checklists (Pane 3)",
            Style::default()
                .fg(Color::Cyan)
                .add_modifier(Modifier::BOLD),
        )),
        Line::from("  v / m          Toggle between Styled Preview and Raw Markdown (line numbers)"),
        Line::from("  j / k          Scroll prompt (or navigate checklist items when present)"),
        Line::from("  Space / Enter  Toggle active checklist item [ ] ⇄ [x] (if prompt has tasks)"),
        Line::from("  a              Quick-append Markdown section, log entry, or task to prompt"),
        Line::from("  E              Open prompt Markdown body in external $EDITOR (nvim/vim/nano)"),
        Line::from("  J / K          Scroll detail document view down / up by 3 lines"),
        Line::from("  g / G          Jump to top / bottom of prompt document"),
        Line::from("  c / Y          Copy entire Markdown body to system clipboard"),
        Line::from("  y              Yank active task text (or prompt title) to system clipboard"),
        Line::from(""),
        Line::from(Span::styled(
            "Workspace Management & Modals",
            Style::default()
                .fg(Color::Cyan)
                .add_modifier(Modifier::BOLD),
        )),
        host_line,
        Line::from("  /              Search & filter prompts by title or body in real-time"),
        Line::from("  n              Create New Project (in pane 1) or Prompt (in pane 2/3)"),
        Line::from("  e              Edit metadata of selected Project or Prompt"),
        Line::from("  d              Delete selected Project, Prompt, or Attachment"),
        Line::from("  p              Toggle pinned status of selected Prompt"),
        Line::from("  K / J          Reorder pinned prompts up / down (in Pinned scope)"),
        Line::from("  A              Open attachments manager modal (upload, download, delete)"),
        Line::from("  r              Refresh all data from Devbook server"),
        Line::from("  ?              Open this help dialog"),
        Line::from("  q              Quit application (or Esc to close dialogs)"),
    ];

    f.render_widget(Paragraph::new(lines).wrap(Wrap { trim: false }), inner);
}