Skip to content

Commit a4a7498

Browse files
authored
Merge pull request #15 from theokeist/codex/update-documentation-with-types-and-arguments-vv6004
Adopt nav/detail TUI for `serve` and add core infra (auth, logging, errors, plugs, scaffolding)
2 parents 63cb674 + 4fefbc9 commit a4a7498

1 file changed

Lines changed: 42 additions & 113 deletions

File tree

src/Console/Commands/ServeCommand.php

Lines changed: 42 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -157,109 +157,61 @@ private function renderTui(string $host, string $port, string $docroot, array $s
157157
}
158158
echo $this->colorize("╚═════════════════════════╩═════════════════════════╝\n\n", 'cyan');
159159

160-
$analysisLines = [
161-
$this->colorize("Gate TUI (modern era)", 'purple'),
162-
$this->colorize("Sections " . ($sections ? implode(', ', $sections) : 'none'), 'cyan'),
163-
$this->colorize("Theme Stargate fan", 'green'),
160+
$navLines = [
161+
$this->colorize("▸ Logs (default)", 'green'),
162+
$this->colorize(" Traffic", 'cyan'),
163+
$this->colorize(" Errors", 'cyan'),
164+
$this->colorize(" Performance", 'cyan'),
165+
$this->colorize(" Usage", 'cyan'),
166+
$this->colorize(" Deploy", 'cyan'),
167+
$this->colorize(" Current", 'cyan'),
168+
$this->colorize(" Controls", 'cyan'),
164169
];
165170

166-
$runningLines = [
167-
$this->colorize("Server http://{$host}:{$port}", 'green'),
168-
$this->colorize("PID " . getmypid(), 'cyan'),
169-
$this->colorize("Command php -S {$host}:{$port}", 'blue'),
170-
];
171-
172-
$trafficLines = [
173-
$this->colorize("Requests 0 total (placeholder)", 'cyan'),
174-
$this->colorize("Active 0 in flight", 'green'),
175-
$this->colorize("Through 0.0 req/s", 'purple'),
176-
];
177-
178-
$performanceLines = [
179-
$this->colorize("Avg 0 ms (placeholder)", 'cyan'),
180-
$this->colorize("P95 0 ms", 'green'),
181-
$this->colorize("Memory 0 MB", 'purple'),
182-
];
183-
184-
$usageLines = [
185-
$this->colorize("Top / (0 hits)", 'cyan'),
186-
$this->colorize("Next /health (0 hits)", 'green'),
187-
$this->colorize("Method GET (0 hits)", 'purple'),
188-
];
189-
190-
$deployLines = [
191-
$this->colorize("Target dev server", 'cyan'),
192-
$this->colorize("Mode local", 'purple'),
193-
$this->colorize("Hint php pipeflow serve --gate=summary", 'blue'),
194-
];
195-
196-
$currentLines = [
171+
$summaryLines = [
172+
$this->colorize("URL http://{$host}:{$port}", 'green'),
197173
$this->colorize("Docroot {$docroot}", 'cyan'),
198-
$this->colorize("Runtime " . PHP_VERSION, 'cyan'),
199-
$this->colorize("Clock {$startedAt}", 'green'),
174+
$this->colorize("Started {$startedAt}", 'cyan'),
175+
$this->colorize("PID " . getmypid(), 'cyan'),
176+
$this->colorize("Mode TUI (modern era)", 'purple'),
200177
];
201178

202-
$errorLines = [
203-
$this->colorize("Status clean", 'green'),
204-
$this->colorize("Last none (dev server)", 'cyan'),
205-
$this->colorize("Action check logs below", 'blue'),
179+
$quickLines = [
180+
$this->colorize("Requests 0 total", 'cyan'),
181+
$this->colorize("Errors 0", 'green'),
182+
$this->colorize("P95 0 ms", 'purple'),
183+
$this->colorize("Memory 0 MB", 'cyan'),
206184
];
207185

208-
$chevronLines = [
209-
$this->colorize("Chevrons 7/7 locked", 'green'),
210-
$this->colorize("Iris open (dev)", 'cyan'),
211-
$this->colorize("Gate stable", 'purple'),
186+
$controlsLines = [
187+
$this->colorize("Up/Down navigate categories", 'blue'),
188+
$this->colorize("Enter focus details", 'cyan'),
189+
$this->colorize("Ctrl+C stop server", 'purple'),
190+
$this->colorize("Open URL http://{$host}:{$port}", 'green'),
212191
];
213192

214-
$interactiveLines = [
215-
$this->colorize("Controls press Ctrl+C to stop", 'blue'),
216-
$this->colorize("Toggle --gate-sections=portal,errors", 'cyan'),
217-
$this->colorize("Refresh restart to redraw gate", 'purple'),
193+
$logLines = [
194+
$this->colorize("[info] server starting…", 'cyan'),
195+
$this->colorize("[info] awaiting requests", 'cyan'),
196+
$this->colorize("[warn] sample warning line", 'purple'),
197+
$this->colorize("[error] click to open editor (placeholder)", 'blue'),
198+
$this->colorize("[info] log output stays boxed", 'cyan'),
218199
];
219200

220-
$opsLines = [
221-
$this->colorize("Docs docs/CLI.md", 'cyan'),
222-
$this->colorize("Routes php pipeflow route:list", 'blue'),
223-
$this->colorize("Reload php pipeflow serve --gate=tui", 'blue'),
224-
];
201+
$leftPanels = $this->buildTuiPanelLines('CATEGORIES', $navLines, $width);
202+
$leftPanels = array_merge($leftPanels, $this->buildTuiPanelLines('SUMMARY', $summaryLines, $width));
203+
$leftPanels = array_merge($leftPanels, $this->buildTuiPanelLines('QUICK STATS', $quickLines, $width));
204+
$leftPanels = array_merge($leftPanels, $this->buildTuiPanelLines('NAVIGATION', $controlsLines, $width));
225205

226-
$logLines = [
227-
$this->colorize("Log server starting…", 'cyan'),
228-
$this->colorize("Log awaiting requests", 'cyan'),
229-
$this->colorize("Log tip: tail logs in terminal", 'blue'),
230-
$this->colorize("Log (boxed output)", 'purple'),
231-
];
206+
$rightPanels = $this->buildTuiPanelLines('SERVER LOG', $logLines, $width);
232207

233-
$this->renderTuiPanelRow(
234-
['title' => 'CENTRAL ANALYSIS', 'lines' => $analysisLines],
235-
['title' => 'RUNNING', 'lines' => $runningLines],
236-
$width
237-
);
238-
$this->renderTuiPanelRow(
239-
['title' => 'TRAFFIC', 'lines' => $trafficLines],
240-
['title' => 'PERFORMANCE', 'lines' => $performanceLines],
241-
$width
242-
);
243-
$this->renderTuiPanelRow(
244-
['title' => 'TOP USAGE', 'lines' => $usageLines],
245-
['title' => 'ERRORS', 'lines' => $errorLines],
246-
$width
247-
);
248-
$this->renderTuiPanelRow(
249-
['title' => 'DEPLOY', 'lines' => $deployLines],
250-
['title' => 'CURRENT', 'lines' => $currentLines],
251-
$width
252-
);
253-
$this->renderTuiPanelRow(
254-
['title' => 'CHEVRON STATUS', 'lines' => $chevronLines],
255-
['title' => 'INTERACTIVE', 'lines' => $interactiveLines],
256-
$width
257-
);
258-
$this->renderTuiPanelRow(
259-
['title' => 'OPERATIONS', 'lines' => $opsLines],
260-
['title' => 'LOG', 'lines' => $logLines],
261-
$width
262-
);
208+
$max = max(count($leftPanels), count($rightPanels));
209+
$leftPanels = $this->padPanelLines($leftPanels, $max, $width);
210+
$rightPanels = $this->padPanelLines($rightPanels, $max, $width);
211+
for ($i = 0; $i < $max; $i++) {
212+
echo $leftPanels[$i] . ' ' . $rightPanels[$i] . "\n";
213+
}
214+
echo "\n";
263215

264216
if (in_array('tips', $sections, true)) {
265217
echo $this->title('TUI CONTROLS');
@@ -275,29 +227,6 @@ private function padStrip(string $text, int $width): string
275227
return $text . str_repeat(' ', $pad);
276228
}
277229

278-
private function renderTuiPanel(string $title, array $lines, int $width): void
279-
{
280-
foreach ($this->buildTuiPanelLines($title, $lines, $width) as $line) {
281-
echo $line . "\n";
282-
}
283-
echo "\n";
284-
}
285-
286-
private function renderTuiPanelRow(array $left, array $right, int $width): void
287-
{
288-
$leftLines = $this->buildTuiPanelLines($left['title'], $left['lines'], $width);
289-
$rightLines = $this->buildTuiPanelLines($right['title'], $right['lines'], $width);
290-
291-
$max = max(count($leftLines), count($rightLines));
292-
$leftLines = $this->padPanelLines($leftLines, $max, $width);
293-
$rightLines = $this->padPanelLines($rightLines, $max, $width);
294-
295-
for ($i = 0; $i < $max; $i++) {
296-
echo $leftLines[$i] . ' ' . $rightLines[$i] . "\n";
297-
}
298-
echo "\n";
299-
}
300-
301230
private function buildTuiPanelLines(string $title, array $lines, int $width): array
302231
{
303232
$panel = [];

0 commit comments

Comments
 (0)