wrkflw-ui 0.7.3

Terminal user interface for wrkflw workflow execution engine
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
// Help overlay rendering
use ratatui::{
    backend::CrosstermBackend,
    layout::{Constraint, Direction, Layout, Rect},
    style::{Color, Modifier, Style},
    text::{Line, Span},
    widgets::{Block, BorderType, Borders, Paragraph, Wrap},
    Frame,
};
use std::io;

// Render the help tab with scroll support
pub fn render_help_content(
    f: &mut Frame<CrosstermBackend<io::Stdout>>,
    area: Rect,
    scroll_offset: usize,
) {
    // Split the area into columns for better organization
    let chunks = Layout::default()
        .direction(Direction::Horizontal)
        .constraints([Constraint::Percentage(50), Constraint::Percentage(50)].as_ref())
        .split(area);

    // Left column content
    let left_help_text = vec![
        Line::from(Span::styled(
            "🗂  NAVIGATION",
            Style::default()
                .fg(Color::Cyan)
                .add_modifier(Modifier::BOLD),
        )),
        Line::from(""),
        Line::from(vec![
            Span::styled(
                "Tab / Shift+Tab",
                Style::default()
                    .fg(Color::Yellow)
                    .add_modifier(Modifier::BOLD),
            ),
            Span::raw(" - Switch between tabs"),
        ]),
        Line::from(vec![
            Span::styled(
                "1-4 / w,x,l,h",
                Style::default()
                    .fg(Color::Yellow)
                    .add_modifier(Modifier::BOLD),
            ),
            Span::raw(" - Jump to specific tab"),
        ]),
        Line::from(vec![
            Span::styled(
                "↑/↓ or k/j",
                Style::default()
                    .fg(Color::Yellow)
                    .add_modifier(Modifier::BOLD),
            ),
            Span::raw(" - Navigate lists"),
        ]),
        Line::from(vec![
            Span::styled(
                "Enter",
                Style::default()
                    .fg(Color::Yellow)
                    .add_modifier(Modifier::BOLD),
            ),
            Span::raw(" - Select/View details"),
        ]),
        Line::from(vec![
            Span::styled(
                "Esc",
                Style::default()
                    .fg(Color::Yellow)
                    .add_modifier(Modifier::BOLD),
            ),
            Span::raw(" - Back/Exit help"),
        ]),
        Line::from(""),
        Line::from(Span::styled(
            "🚀 WORKFLOW MANAGEMENT",
            Style::default()
                .fg(Color::Green)
                .add_modifier(Modifier::BOLD),
        )),
        Line::from(""),
        Line::from(vec![
            Span::styled(
                "Space",
                Style::default()
                    .fg(Color::Yellow)
                    .add_modifier(Modifier::BOLD),
            ),
            Span::raw(" - Toggle workflow selection"),
        ]),
        Line::from(vec![
            Span::styled(
                "r",
                Style::default()
                    .fg(Color::Yellow)
                    .add_modifier(Modifier::BOLD),
            ),
            Span::raw(" - Run selected workflows"),
        ]),
        Line::from(vec![
            Span::styled(
                "a",
                Style::default()
                    .fg(Color::Yellow)
                    .add_modifier(Modifier::BOLD),
            ),
            Span::raw(" - Select all workflows"),
        ]),
        Line::from(vec![
            Span::styled(
                "n",
                Style::default()
                    .fg(Color::Yellow)
                    .add_modifier(Modifier::BOLD),
            ),
            Span::raw(" - Deselect all workflows"),
        ]),
        Line::from(vec![
            Span::styled(
                "Shift+R",
                Style::default()
                    .fg(Color::Yellow)
                    .add_modifier(Modifier::BOLD),
            ),
            Span::raw(" - Reset workflow status"),
        ]),
        Line::from(vec![
            Span::styled(
                "t",
                Style::default()
                    .fg(Color::Yellow)
                    .add_modifier(Modifier::BOLD),
            ),
            Span::raw(" - Trigger remote workflow"),
        ]),
        Line::from(""),
        Line::from(Span::styled(
            "🔧 EXECUTION MODES",
            Style::default()
                .fg(Color::Magenta)
                .add_modifier(Modifier::BOLD),
        )),
        Line::from(""),
        Line::from(vec![
            Span::styled(
                "e",
                Style::default()
                    .fg(Color::Yellow)
                    .add_modifier(Modifier::BOLD),
            ),
            Span::raw(" - Toggle emulation mode"),
        ]),
        Line::from(vec![
            Span::styled(
                "v",
                Style::default()
                    .fg(Color::Yellow)
                    .add_modifier(Modifier::BOLD),
            ),
            Span::raw(" - Toggle validation mode"),
        ]),
        Line::from(""),
        Line::from(vec![Span::styled(
            "Runtime Modes:",
            Style::default()
                .fg(Color::White)
                .add_modifier(Modifier::BOLD),
        )]),
        Line::from(vec![
            Span::raw("  • "),
            Span::styled("Docker", Style::default().fg(Color::Blue)),
            Span::raw(" - Container isolation (default)"),
        ]),
        Line::from(vec![
            Span::raw("  • "),
            Span::styled("Podman", Style::default().fg(Color::Blue)),
            Span::raw(" - Rootless containers"),
        ]),
        Line::from(vec![
            Span::raw("  • "),
            Span::styled("Emulation", Style::default().fg(Color::Red)),
            Span::raw(" - Process mode (UNSAFE)"),
        ]),
        Line::from(vec![
            Span::raw("  • "),
            Span::styled("Secure Emulation", Style::default().fg(Color::Yellow)),
            Span::raw(" - Sandboxed processes"),
        ]),
    ];

    // Right column content
    let right_help_text = vec![
        Line::from(Span::styled(
            "📄 LOGS & SEARCH",
            Style::default()
                .fg(Color::Blue)
                .add_modifier(Modifier::BOLD),
        )),
        Line::from(""),
        Line::from(vec![
            Span::styled(
                "s",
                Style::default()
                    .fg(Color::Yellow)
                    .add_modifier(Modifier::BOLD),
            ),
            Span::raw(" - Toggle log search"),
        ]),
        Line::from(vec![
            Span::styled(
                "f",
                Style::default()
                    .fg(Color::Yellow)
                    .add_modifier(Modifier::BOLD),
            ),
            Span::raw(" - Toggle log filter"),
        ]),
        Line::from(vec![
            Span::styled(
                "c",
                Style::default()
                    .fg(Color::Yellow)
                    .add_modifier(Modifier::BOLD),
            ),
            Span::raw(" - Clear search & filter"),
        ]),
        Line::from(vec![
            Span::styled(
                "n",
                Style::default()
                    .fg(Color::Yellow)
                    .add_modifier(Modifier::BOLD),
            ),
            Span::raw(" - Next search match"),
        ]),
        Line::from(vec![
            Span::styled(
                "↑/↓",
                Style::default()
                    .fg(Color::Yellow)
                    .add_modifier(Modifier::BOLD),
            ),
            Span::raw(" - Scroll logs/Navigate"),
        ]),
        Line::from(""),
        Line::from(Span::styled(
            "ℹ️  TAB OVERVIEW",
            Style::default()
                .fg(Color::White)
                .add_modifier(Modifier::BOLD),
        )),
        Line::from(""),
        Line::from(vec![
            Span::styled(
                "1. Workflows",
                Style::default()
                    .fg(Color::Cyan)
                    .add_modifier(Modifier::BOLD),
            ),
            Span::raw(" - Browse & select workflows"),
        ]),
        Line::from(vec![Span::raw("   • View workflow files")]),
        Line::from(vec![Span::raw("   • Select multiple for batch execution")]),
        Line::from(vec![Span::raw("   • Trigger remote workflows")]),
        Line::from(""),
        Line::from(vec![
            Span::styled(
                "2. Execution",
                Style::default()
                    .fg(Color::Green)
                    .add_modifier(Modifier::BOLD),
            ),
            Span::raw(" - Monitor job progress"),
        ]),
        Line::from(vec![Span::raw("   • View job status and details")]),
        Line::from(vec![Span::raw("   • Enter job details with Enter")]),
        Line::from(vec![Span::raw("   • Navigate step execution")]),
        Line::from(""),
        Line::from(vec![
            Span::styled(
                "3. Logs",
                Style::default()
                    .fg(Color::Blue)
                    .add_modifier(Modifier::BOLD),
            ),
            Span::raw(" - View execution logs"),
        ]),
        Line::from(vec![Span::raw("   • Search and filter logs")]),
        Line::from(vec![Span::raw("   • Real-time log streaming")]),
        Line::from(vec![Span::raw("   • Navigate search results")]),
        Line::from(""),
        Line::from(vec![
            Span::styled(
                "4. Help",
                Style::default()
                    .fg(Color::Yellow)
                    .add_modifier(Modifier::BOLD),
            ),
            Span::raw(" - This comprehensive guide"),
        ]),
        Line::from(""),
        Line::from(Span::styled(
            "🎯 QUICK ACTIONS",
            Style::default().fg(Color::Red).add_modifier(Modifier::BOLD),
        )),
        Line::from(""),
        Line::from(vec![
            Span::styled(
                "?",
                Style::default()
                    .fg(Color::Yellow)
                    .add_modifier(Modifier::BOLD),
            ),
            Span::raw(" - Toggle help overlay"),
        ]),
        Line::from(vec![
            Span::styled(
                "q",
                Style::default()
                    .fg(Color::Yellow)
                    .add_modifier(Modifier::BOLD),
            ),
            Span::raw(" - Quit application"),
        ]),
        Line::from(""),
        Line::from(Span::styled(
            "💡 TIPS",
            Style::default()
                .fg(Color::Yellow)
                .add_modifier(Modifier::BOLD),
        )),
        Line::from(""),
        Line::from(vec![
            Span::raw("• Use "),
            Span::styled("emulation mode", Style::default().fg(Color::Red)),
            Span::raw(" when containers"),
        ]),
        Line::from(vec![Span::raw("  are unavailable or for quick testing")]),
        Line::from(""),
        Line::from(vec![
            Span::raw("• "),
            Span::styled("Secure emulation", Style::default().fg(Color::Yellow)),
            Span::raw(" provides sandboxing"),
        ]),
        Line::from(vec![Span::raw("  for untrusted workflows")]),
        Line::from(""),
        Line::from(vec![
            Span::raw("• Use "),
            Span::styled("validation mode", Style::default().fg(Color::Green)),
            Span::raw(" to check"),
        ]),
        Line::from(vec![Span::raw("  workflows without execution")]),
        Line::from(""),
        Line::from(vec![
            Span::raw("• "),
            Span::styled("Preserve containers", Style::default().fg(Color::Blue)),
            Span::raw(" on failure"),
        ]),
        Line::from(vec![Span::raw("  for debugging (Docker/Podman only)")]),
    ];

    // Apply scroll offset to the content
    let left_help_text = if scroll_offset < left_help_text.len() {
        left_help_text.into_iter().skip(scroll_offset).collect()
    } else {
        vec![Line::from("")]
    };

    let right_help_text = if scroll_offset < right_help_text.len() {
        right_help_text.into_iter().skip(scroll_offset).collect()
    } else {
        vec![Line::from("")]
    };

    // Render left column
    let left_widget = Paragraph::new(left_help_text)
        .block(
            Block::default()
                .borders(Borders::ALL)
                .border_type(BorderType::Rounded)
                .title(Span::styled(
                    " WRKFLW Help - Controls & Features ",
                    Style::default()
                        .fg(Color::Yellow)
                        .add_modifier(Modifier::BOLD),
                )),
        )
        .wrap(Wrap { trim: true });

    // Render right column
    let right_widget = Paragraph::new(right_help_text)
        .block(
            Block::default()
                .borders(Borders::ALL)
                .border_type(BorderType::Rounded)
                .title(Span::styled(
                    " Interface Guide & Tips ",
                    Style::default()
                        .fg(Color::Cyan)
                        .add_modifier(Modifier::BOLD),
                )),
        )
        .wrap(Wrap { trim: true });

    f.render_widget(left_widget, chunks[0]);
    f.render_widget(right_widget, chunks[1]);
}

// Render a help overlay
pub fn render_help_overlay(f: &mut Frame<CrosstermBackend<io::Stdout>>, scroll_offset: usize) {
    let size = f.size();

    // Create a larger centered modal to accommodate comprehensive help content
    let width = (size.width * 9 / 10).min(120); // Use 90% of width, max 120 chars
    let height = (size.height * 9 / 10).min(40); // Use 90% of height, max 40 lines
    let x = (size.width - width) / 2;
    let y = (size.height - height) / 2;

    let help_area = Rect {
        x,
        y,
        width,
        height,
    };

    // Create a semi-transparent dark background for better visibility
    let clear = Block::default().style(Style::default().bg(Color::Black));
    f.render_widget(clear, size);

    // Add a border around the entire overlay for better visual separation
    let overlay_block = Block::default()
        .borders(Borders::ALL)
        .border_type(BorderType::Double)
        .style(Style::default().bg(Color::Black).fg(Color::White))
        .title(Span::styled(
            " Press ? or Esc to close help ",
            Style::default()
                .fg(Color::Gray)
                .add_modifier(Modifier::ITALIC),
        ));

    f.render_widget(overlay_block, help_area);

    // Create inner area for content
    let inner_area = Rect {
        x: help_area.x + 1,
        y: help_area.y + 1,
        width: help_area.width.saturating_sub(2),
        height: help_area.height.saturating_sub(2),
    };

    // Render the help content with scroll support
    render_help_content(f, inner_area, scroll_offset);
}