-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
Copy pathLumpToolbar.tsx
82 lines (74 loc) · 2.03 KB
/
LumpToolbar.tsx
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
import { useContext } from "react";
import styled from "styled-components";
import { AnimatedEllipsis } from "../..";
import { IdeMessengerContext } from "../../../context/IdeMessenger";
import { useAppDispatch, useAppSelector } from "../../../redux/hooks";
import { cancelStream } from "../../../redux/thunks/cancelStream";
import { getFontSize, getMetaKeyLabel } from "../../../util";
import { BlockSettingsTopToolbar } from "./BlockSettingsTopToolbar";
const Container = styled.div`
display: flex;
justify-content: space-between;
align-items: center;
width: 100%;
`;
const StopButton = styled.div`
font-size: ${getFontSize() - 3}px;
padding: 2px;
padding-right: 4px;
cursor: pointer;
`;
interface TopToolbarProps {
selectedSection: string | null;
setSelectedSection: (value: string | null) => void;
}
function GeneratingIndicator() {
return (
<div className="text-xs text-gray-400">
<span>Generating</span>
<AnimatedEllipsis />
</div>
);
}
export function LumpToolbar(props: TopToolbarProps) {
const dispatch = useAppDispatch();
const ideMessenger = useContext(IdeMessengerContext);
const ttsActive = useAppSelector((state) => state.ui.ttsActive);
const isStreaming = useAppSelector((state) => state.session.isStreaming);
if (ttsActive) {
return (
<Container>
<GeneratingIndicator />
<StopButton
className="text-gray-400"
onClick={() => {
ideMessenger.post("tts/kill", undefined);
}}
>
■ Stop TTS
</StopButton>
</Container>
);
}
if (isStreaming) {
return (
<Container>
<GeneratingIndicator />
<StopButton
className="text-gray-400"
onClick={() => {
dispatch(cancelStream());
}}
>
{getMetaKeyLabel()} ⌫ Cancel
</StopButton>
</Container>
);
}
return (
<BlockSettingsTopToolbar
selectedSection={props.selectedSection}
setSelectedSection={props.setSelectedSection}
/>
);
}