chenbhao commited on
Commit
089ea28
·
1 Parent(s): 9a6f0b1

fix: auto esc /friend start stop

Browse files
Files changed (2) hide show
  1. README.md +3 -5
  2. src/commands/friend/friend.tsx +10 -28
README.md CHANGED
@@ -144,13 +144,11 @@ firefox http://localhost:8080
144
  ```
145
 
146
  ```bash
147
- # cd desktop && rm -rf node_modules/.vite && bun run dev
148
- # cd desktop && bun run vite build
149
- cd desktop && bun run vite && bun run tauri dev
150
- # ai_friend api in 8889 so local build Omni model or use cloud service on 8889
151
 
152
  # test
153
- HTTP_PROXY=http://127.0.0.1:8888 HTTPS_PROXY=http://127.0.0.1:8888 bun run tauri dev
154
  mitmproxy -p 8888
155
  ```
156
 
 
144
  ```
145
 
146
  ```bash
147
+ # friend
148
+ cd src/components/friend/frontend && npx tauri build
 
 
149
 
150
  # test
151
+ HTTP_PROXY=http://127.0.0.1:8888 HTTPS_PROXY=http://127.0.0.1:8888 <commands>
152
  mitmproxy -p 8888
153
  ```
154
 
src/commands/friend/friend.tsx CHANGED
@@ -4,7 +4,7 @@
4
  * Ink-based terminal UI that shows status and controls for the
5
  * Friend desktop pet feature.
6
  */
7
- import React, { useState } from 'react'
8
  import { Box, Text, useInput } from '../../ink.js'
9
  import { getPrefs, updatePrefs } from '../../friend/prefs.js'
10
  import {
@@ -85,47 +85,29 @@ function FriendManager({ onDone }: { onDone: LocalJSXCommandOnDone }) {
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
-
112
- useInput((_input, key) => {
113
- if (key.escape || key.return) setDismissed(true)
114
- })
115
-
116
- if (dismissed) {
117
- onDone()
118
- return null
119
- }
120
 
121
  return (
122
  <Box flexDirection="column">
123
  <Text>Starting Friend VRM companion...</Text>
124
  <Text dimColor>A Tauri window will open.</Text>
125
  <Text dimColor>Also available at: {FRIEND_URL}</Text>
126
- <Box marginTop={1}>
127
- <Text dimColor>Press Esc or Enter to close.</Text>
128
- </Box>
129
  </Box>
130
  )
131
  }
 
4
  * Ink-based terminal UI that shows status and controls for the
5
  * Friend desktop pet feature.
6
  */
7
+ import React, { useState, useEffect } from 'react'
8
  import { Box, Text, useInput } from '../../ink.js'
9
  import { getPrefs, updatePrefs } from '../../friend/prefs.js'
10
  import {
 
85
  }
86
 
87
  function FriendStopView({ onDone }: { onDone: () => void }) {
88
+ useEffect(() => {
89
+ const t = setTimeout(onDone, 1500)
90
+ return () => clearTimeout(t)
91
+ }, [onDone])
 
 
 
 
 
 
92
 
93
  return (
94
  <Box flexDirection="column">
95
+ <Text>Friend companion stopped.</Text>
 
 
 
96
  </Box>
97
  )
98
  }
99
 
100
  function FriendStartView({ onDone }: { onDone: () => void }) {
101
+ useEffect(() => {
102
+ const t = setTimeout(onDone, 1500)
103
+ return () => clearTimeout(t)
104
+ }, [onDone])
 
 
 
 
 
 
105
 
106
  return (
107
  <Box flexDirection="column">
108
  <Text>Starting Friend VRM companion...</Text>
109
  <Text dimColor>A Tauri window will open.</Text>
110
  <Text dimColor>Also available at: {FRIEND_URL}</Text>
 
 
 
111
  </Box>
112
  )
113
  }