| 1 | //! Current Codewhale TUI footer chrome, rendered through portable host data. |
| 2 | use std::time::Duration; |
| 3 | |
| 4 | use ratatui::{buffer::Buffer, layout::Rect}; |
| 5 | |
| 6 | use super::Entry; |
| 7 | use crate::{ |
| 8 | NativeComposer, NativeComposerDensity, Paint, Theme, WorkflowProgress, WorkflowRun, |
| 9 | WorkflowRunState, |
| 10 | }; |
| 11 | |
| 12 | fn composer(area: Rect, buf: &mut Buffer, theme: &Theme) { |
| 13 | NativeComposer::new("Keep the composer compact and the workflow progress visible.") |
| 14 | .focused(true) |
| 15 | .can_submit(true) |
| 16 | .submit_hint("Enter send Shift+Enter newline") |
| 17 | .paint(area, buf, theme); |
| 18 | } |
| 19 | fn composer_narrow(area: Rect, buf: &mut Buffer, theme: &Theme) { |
| 20 | NativeComposer::new("Review the changes, then continue.") |
| 21 | .focused(true) |
| 22 | .can_submit(true) |
| 23 | .density(NativeComposerDensity::Compact) |
| 24 | .submit_hint("Enter send") |
| 25 | .paint(area, buf, theme); |
| 26 | } |
| 27 | fn composer_quiet(area: Rect, buf: &mut Buffer, theme: &Theme) { |
| 28 | NativeComposer::new("") |
| 29 | .enclosed(false) |
| 30 | .density(NativeComposerDensity::Compact) |
| 31 | .focused(true) |
| 32 | .paint(area, buf, theme); |
| 33 | } |
| 34 | fn composer_target(area: Rect, buf: &mut Buffer, theme: &Theme) { |
| 35 | NativeComposer::new("Check the selected files.\nKeep the draft until I answer.") |
| 36 | .focused(true) |
| 37 | .can_submit(true) |
| 38 | .target("To reviewer") |
| 39 | .submit_hint("Enter send") |
| 40 | .density(NativeComposerDensity::Spacious) |
| 41 | .paint(area, buf, theme); |
| 42 | } |
| 43 | fn workflow_live(area: Rect, buf: &mut Buffer, theme: &Theme) { |
| 44 | WorkflowProgress::new(vec![ |
| 45 | WorkflowRun::new("Compare Cline with Codewhale", WorkflowRunState::Running) |
| 46 | .outcomes(4, 1, 0, 10) |
| 47 | .elapsed(Duration::from_secs(134)) |
| 48 | .tokens(1_234_567), |
| 49 | ]) |
| 50 | .paint(area, buf, theme); |
| 51 | } |
| 52 | fn workflow_settled(area: Rect, buf: &mut Buffer, theme: &Theme) { |
| 53 | WorkflowProgress::new(vec![ |
| 54 | WorkflowRun::new("Inspect the files", WorkflowRunState::Succeeded) |
| 55 | .outcomes(3, 0, 0, 3) |
| 56 | .elapsed(Duration::from_secs(59)), |
| 57 | WorkflowRun::new("Release-readiness audit", WorkflowRunState::Failed) |
| 58 | .outcomes(0, 2, 0, 2) |
| 59 | .elapsed(Duration::from_millis(355)) |
| 60 | .reason("Authorization failed: sign in again. No task produced a result."), |
| 61 | WorkflowRun::new("Port the fixture suite", WorkflowRunState::Degraded) |
| 62 | .outcomes(3, 1, 0, 4) |
| 63 | .elapsed(Duration::from_secs(134)) |
| 64 | .reason("Timed out waiting for the model after 600s. Retried once."), |
| 65 | ]) |
| 66 | .paint(area, buf, theme); |
| 67 | } |
| 68 | fn workflow_queued(area: Rect, buf: &mut Buffer, theme: &Theme) { |
| 69 | WorkflowProgress::new(vec![ |
| 70 | WorkflowRun::new("Compare the modules", WorkflowRunState::Running) |
| 71 | .outcomes(0, 1, 0, 25) |
| 72 | .elapsed(Duration::from_secs(5)) |
| 73 | .queued(2) |
| 74 | .tokens(48_400), |
| 75 | ]) |
| 76 | .paint(area, buf, theme); |
| 77 | } |
| 78 | fn workflow_narrow(area: Rect, buf: &mut Buffer, theme: &Theme) { |
| 79 | WorkflowProgress::new(vec![ |
| 80 | WorkflowRun::new( |
| 81 | "Read-only release-readiness audit for Codewhale", |
| 82 | WorkflowRunState::Failed, |
| 83 | ) |
| 84 | .outcomes(0, 2, 0, 2) |
| 85 | .elapsed(Duration::from_millis(355)) |
| 86 | .reason("Authorization failed: sign in again."), |
| 87 | ]) |
| 88 | .paint(area, buf, theme); |
| 89 | } |
| 90 | |
| 91 | pub(crate) fn entries() -> Vec<Entry> { |
| 92 | vec![ |
| 93 | Entry { |
| 94 | name: "native-composer", |
| 95 | width: 100, |
| 96 | height: 4, |
| 97 | draw: composer, |
| 98 | }, |
| 99 | Entry { |
| 100 | name: "native-composer-narrow", |
| 101 | width: 40, |
| 102 | height: 4, |
| 103 | draw: composer_narrow, |
| 104 | }, |
| 105 | Entry { |
| 106 | name: "native-composer-quiet", |
| 107 | width: 60, |
| 108 | height: 2, |
| 109 | draw: composer_quiet, |
| 110 | }, |
| 111 | Entry { |
| 112 | name: "native-composer-target", |
| 113 | width: 80, |
| 114 | height: 6, |
| 115 | draw: composer_target, |
| 116 | }, |
| 117 | Entry { |
| 118 | name: "workflow-progress-live", |
| 119 | width: 110, |
| 120 | height: 1, |
| 121 | draw: workflow_live, |
| 122 | }, |
| 123 | Entry { |
| 124 | name: "workflow-progress-settled", |
| 125 | width: 140, |
| 126 | height: 3, |
| 127 | draw: workflow_settled, |
| 128 | }, |
| 129 | Entry { |
| 130 | name: "workflow-progress-queued", |
| 131 | width: 120, |
| 132 | height: 1, |
| 133 | draw: workflow_queued, |
| 134 | }, |
| 135 | Entry { |
| 136 | name: "workflow-progress-narrow", |
| 137 | width: 40, |
| 138 | height: 1, |
| 139 | draw: workflow_narrow, |
| 140 | }, |
| 141 | ] |
| 142 | } |
| 143 |