feat: integrate filegraph

This commit is contained in:
Justin Lin committed 2025-04-24 23:30:12 +08:00
1 parent b3ed0e646e
commit fba92dad46
4 files changed
+13 -11

No files matched your search

+1 -1
View File
@@ -12,7 +12,7 @@ const sessionStore = useSession()
<FileNode <FileNode
v-if="sessionStore.session" v-if="sessionStore.session"
:node="sessionStore.session.graph" :node="sessionStore.session.graph"
:pwd="sessionStore.session.pwd" pwd="/home/commander"
/> />
</li> </li>
</ul> </ul>
+6 -6
View File
@@ -2,6 +2,7 @@ import { defineStore } from 'pinia'
import { import {
FileGraph, FileGraph,
type FileGraphUpdateEvent, type FileGraphUpdateEvent,
type FileObject,
} from '../../../packages/file-graph' } from '../../../packages/file-graph'
import type { IResponse, ITask } from '../../../packages/game' import type { IResponse, ITask } from '../../../packages/game'
import type { SessionDetail } from '../../../server/src/routers/sessionRouter' import type { SessionDetail } from '../../../server/src/routers/sessionRouter'
@@ -75,9 +76,7 @@ const useSession = defineStore('session', {
this.session.responses = update.responses this.session.responses = update.responses
this.session.tasks = update.tasks this.session.tasks = update.tasks
this.session.status = update.status this.session.status = update.status
if (update.graphUpdate) { console.log('update', update)
this.session.graph.handleEvent(update.graphUpdate)
}
// if ( // if (
// response.status === 'finished' && // response.status === 'finished' &&
// this.session.status !== 'finished' // this.session.status !== 'finished'
@@ -103,9 +102,10 @@ const useSession = defineStore('session', {
term.onData((data: string) => { term.onData((data: string) => {
socket.emit('terminal', data) socket.emit('terminal', data)
}) })
// socket.on('graph', (event: { discover: FileObject[]; pwd: string }) => { socket.on('graph', (event: FileGraphUpdateEvent) => {
// this.updateGraph(event) if (!this.session) return
// }) this.session.graph.handleEvent(event)
})
socket.on('update', (update: SessionUpdate) => { socket.on('update', (update: SessionUpdate) => {
this.newUpdate(update) this.newUpdate(update)
}) })
+1 -1
View File
@@ -84,7 +84,7 @@ onMounted(async () => {
<div class="bg-border rounded-xl h-[90%] p-2"> <div class="bg-border rounded-xl h-[90%] p-2">
<div class="bg-bg rounded-lg h-full p-2"> <div class="bg-bg rounded-lg h-full p-2">
<section id="visualization" class="bg-bg-primary h-full rounded-md"> <section id="visualization" class="bg-bg-primary h-full rounded-md">
<!-- <VisualizationPart /> --> <VisualizationPart />
</section> </section>
</div> </div>
</div> </div>
@@ -58,16 +58,18 @@ export const newCommand = asyncHandler(async (req: Request, res: Response) => {
if (gameSession.isFinished()) { if (gameSession.isFinished()) {
await finishSession(session) await finishSession(session)
} else {
await session.save()
} }
pushToSession(session.id, 'update', { pushToSession(session.id, 'update', {
responses: gameSession.getResponses(), responses: gameSession.getResponses(),
tasks: gameSession.getTasks(), tasks: gameSession.getTasks(),
status: session.status, status: session.status,
graphUpdate: command.params,
}) })
} }
if (command.params) {
session.graph = gameSession.getGraph()
pushToSession(session.id, 'graph', command.params)
}
await session.save()
res.status(200).end() res.status(200).end()
}) })