chenbhao commited on
Commit
9a6f0b1
·
1 Parent(s): 50af4e4

fix: after /friend stop can esc

Browse files
Files changed (1) hide show
  1. src/commands/friend/friend.tsx +23 -1
src/commands/friend/friend.tsx CHANGED
@@ -39,7 +39,7 @@ export async function call(
39
  if (trimmed === 'stop') {
40
  updatePrefs({ enabled: false })
41
  stopTauri(logger())
42
- return <Text>Friend companion stopped.</Text>
43
  }
44
 
45
  if (trimmed === 'status') {
@@ -84,6 +84,28 @@ function FriendManager({ onDone }: { onDone: LocalJSXCommandOnDone }) {
84
  )
85
  }
86
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  function FriendStartView({ onDone }: { onDone: () => void }) {
88
  const [dismissed, setDismissed] = useState(false)
89
 
 
39
  if (trimmed === 'stop') {
40
  updatePrefs({ enabled: false })
41
  stopTauri(logger())
42
+ return <FriendStopView onDone={() => onDone?.()} />
43
  }
44
 
45
  if (trimmed === 'status') {
 
84
  )
85
  }
86
 
87
+ function FriendStopView({ onDone }: { onDone: () => void }) {
88
+ const [dismissed, setDismissed] = useState(false)
89
+
90
+ useInput((_input, key) => {
91
+ if (key.escape || key.return) setDismissed(true)
92
+ })
93
+
94
+ if (dismissed) {
95
+ onDone()
96
+ return null
97
+ }
98
+
99
+ return (
100
+ <Box flexDirection="column">
101
+ <Text>Stopping Friend companion...</Text>
102
+ <Box marginTop={1}>
103
+ <Text dimColor>Press Esc or Enter to close.</Text>
104
+ </Box>
105
+ </Box>
106
+ )
107
+ }
108
+
109
  function FriendStartView({ onDone }: { onDone: () => void }) {
110
  const [dismissed, setDismissed] = useState(false)
111