Skip to content

Commit 21ced60

Browse files
Travisuncursoragent
andcommitted
fix: surface discover history delete failures and watch server dist in dev.
Show a clear error when the API still uses the legacy cancel-only DELETE handler, and run tsc --watch alongside the dev supervisor so server changes apply without a manual rebuild. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 595ff1b commit 21ced60

3 files changed

Lines changed: 25 additions & 4 deletions

File tree

apps/server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"private": true,
55
"type": "module",
66
"scripts": {
7-
"dev": "npm run build && node scripts/dev.mjs",
7+
"dev": "npm run build && concurrently -k -n tsc,api \"tsc -p tsconfig.json --watch --preserveWatchOutput\" \"node scripts/dev.mjs\"",
88
"build": "tsc -p tsconfig.json",
99
"start": "node dist/index.js",
1010
"mcp": "npm run build -w @inno-a-stock/agent && node ../../packages/agent/dist/mcp/stdio-entry.js"

client-ui/src/market/DiscoverTab.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,8 @@ export default function DiscoverTab({ session, watchlistCodes, onSelect, onAdd }
377377
cancelRun,
378378
loadHistoryJob,
379379
deleteHistoryJob,
380+
deleteError,
381+
clearDeleteError,
380382
} = session
381383

382384
const strategyOptions = useMemo((): DiscoverStrategyOption[] => {
@@ -433,6 +435,7 @@ export default function DiscoverTab({ session, watchlistCodes, onSelect, onAdd }
433435
const handleDeleteHistory = (e: MouseEvent, jobId: string) => {
434436
e.preventDefault()
435437
e.stopPropagation()
438+
clearDeleteError()
436439
void deleteHistoryJob(jobId)
437440
}
438441

@@ -591,6 +594,9 @@ export default function DiscoverTab({ session, watchlistCodes, onSelect, onAdd }
591594

592595
{panelTab === 'history' && (
593596
<div className={mergeClasses(s.historyList, 'inno-scroll')}>
597+
{deleteError && (
598+
<Text className={s.error} block>{deleteError}</Text>
599+
)}
594600
{historyJobs.length === 0 && (
595601
<Text className={s.empty}>
596602
暂无历史记录。完成一次挖掘后,结果会保存在这里,可随时回看或删除。

client-ui/src/market/useDiscoverSession.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ export interface DiscoverSessionState {
2424
runCustomStrategy: (opts: { id: string; name: string; prompt: string }) => Promise<void>
2525
cancelRun: () => Promise<void>
2626
loadHistoryJob: (job: DiscoverJobSnapshot) => void
27-
deleteHistoryJob: (jobId: string) => Promise<void>
27+
deleteHistoryJob: (jobId: string) => Promise<boolean>
28+
deleteError: string
29+
clearDeleteError: () => void
2830
}
2931

3032
export function useDiscoverSession(): DiscoverSessionState {
@@ -35,6 +37,7 @@ export function useDiscoverSession(): DiscoverSessionState {
3537
const [running, setRunning] = useState(false)
3638
const [error, setError] = useState('')
3739
const [selectedStrategyId, setSelectedStrategyId] = useState<string | null>(null)
40+
const [deleteError, setDeleteError] = useState('')
3841
const pollRef = useRef<number | null>(null)
3942
const viewingJobIdRef = useRef<string | null>(null)
4043
const historyRef = useRef<DiscoverJobSnapshot[]>([])
@@ -206,6 +209,7 @@ export function useDiscoverSession(): DiscoverSessionState {
206209
}, [])
207210

208211
const deleteHistoryJob = useCallback(async (jobId: string) => {
212+
setDeleteError('')
209213
const viewingDeleted = viewingJobIdRef.current === jobId || activeJobId === jobId
210214
const prevHistory = historyRef.current
211215

@@ -220,7 +224,13 @@ export function useDiscoverSession(): DiscoverSessionState {
220224

221225
try {
222226
await deleteDiscoverJob(jobId)
223-
} catch {
227+
} catch (e) {
228+
const msg = e instanceof Error ? e.message : ''
229+
setDeleteError(
230+
msg.includes('not running')
231+
? '删除失败:请重启应用或 API 服务后再试'
232+
: '删除失败,请稍后重试',
233+
)
224234
setHistory(prevHistory)
225235
if (viewingDeleted) {
226236
const jobs = await refreshHistory()
@@ -233,12 +243,15 @@ export function useDiscoverSession(): DiscoverSessionState {
233243
setActiveJobId(restored.status === 'running' ? restored.id : null)
234244
}
235245
}
236-
return
246+
return false
237247
}
238248

239249
await refreshHistory()
250+
return true
240251
}, [activeJobId, clearViewingJob, refreshHistory, stopPoll])
241252

253+
const clearDeleteError = useCallback(() => setDeleteError(''), [])
254+
242255
return {
243256
history,
244257
activeJobId,
@@ -254,5 +267,7 @@ export function useDiscoverSession(): DiscoverSessionState {
254267
cancelRun,
255268
loadHistoryJob,
256269
deleteHistoryJob,
270+
deleteError,
271+
clearDeleteError,
257272
}
258273
}

0 commit comments

Comments
 (0)