-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathapp.tsx
More file actions
62 lines (57 loc) · 1.56 KB
/
Copy pathapp.tsx
File metadata and controls
62 lines (57 loc) · 1.56 KB
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
import { Box, Text, useInput } from "ink";
import { useSyncExternalStore } from "react";
import { ConfigView } from "./config-view";
import { Header } from "./header";
import { RequestLog } from "./request-log";
import {
getCliState,
subscribeCliState,
toggleLogFlow,
toggleViewMode,
toggleVibeState,
} from "./cli-store";
import { skipTrack, toggleVibe } from "./vibe/vibe-player";
const HEADER_HEIGHT = 15;
const HEADER_HEIGHT_VIBE = 19;
export function App({ home }: { home: string }) {
const state = useSyncExternalStore(subscribeCliState, getCliState);
useInput((_input) => {
if (_input === "k" || _input === "K") {
toggleViewMode();
}
if (_input === "l" || _input === "L") {
toggleLogFlow();
}
if ((_input === "v" || _input === "V") && state.dataDir) {
toggleVibe(state.dataDir);
toggleVibeState();
}
if ((_input === "n" || _input === "N") && state.vibe) {
skipTrack();
}
});
return (
<Box flexDirection="column">
<Header
services={state.services}
migrationsStatus={state.migrationsStatus}
home={home}
serverUrl={state.serverUrl}
vibe={state.vibe}
autostartProject={state.autostartProject}
/>
{state.viewMode === "config" ? (
state.env ? (
<ConfigView env={state.env} />
) : (
<Text dimColor>Loading configuration...</Text>
)
) : (
<RequestLog
logs={state.logs}
headerHeight={state.vibe ? HEADER_HEIGHT_VIBE : HEADER_HEIGHT}
/>
)}
</Box>
);
}