Skip to content

Commit 3e4dbb1

Browse files
authored
feat(tarko-server-next): optimize parts of controller by avoiding go … (#1684)
1 parent 135cf99 commit 3e4dbb1

File tree

2 files changed

+17
-28
lines changed

2 files changed

+17
-28
lines changed

multimodal/tarko/agent-server-next/src/controllers/sessions.ts

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -77,27 +77,24 @@ export async function createSession(c: HonoContext) {
7777
*/
7878
export async function getSessionDetails(c: HonoContext) {
7979
const server = c.get('server');
80-
const session = c.get('session');
8180
const sessionId = c.req.query('sessionId');
8281

8382
try {
84-
if (!session) {
85-
return c.json({ error: 'Session not found' }, 404);
83+
if (!sessionId) {
84+
return c.json({ error: 'SessionId not found' }, 404);
8685
}
8786

88-
if (sessionId) {
89-
const sessionInfo = await server.daoFactory.getSessionInfo(sessionId);
87+
const sessionInfo = await server.daoFactory.getSessionInfo(sessionId);
9088

91-
sessionInfo && filterSessionModel([sessionInfo]);
89+
sessionInfo && filterSessionModel([sessionInfo]);
9290

93-
if (sessionInfo) {
94-
return c.json(
95-
{
96-
session: sessionInfo,
97-
},
98-
200,
99-
);
100-
}
91+
if (sessionInfo) {
92+
return c.json(
93+
{
94+
session: sessionInfo,
95+
},
96+
200,
97+
);
10198
}
10299

103100
return c.json({ error: 'Session not found' }, 404);
@@ -163,7 +160,7 @@ export async function getSessionStatus(c: HonoContext) {
163160
return c.json({ error: 'Session not found' }, 404);
164161
}
165162

166-
const isProcessing = session.getProcessingStatus();
163+
const isProcessing = session.getProcessingStatus();
167164

168165
return c.json(
169166
{
@@ -186,7 +183,6 @@ export async function getSessionStatus(c: HonoContext) {
186183
*/
187184
export async function updateSession(c: HonoContext) {
188185
const server = c.get('server');
189-
const session = c.get('session');
190186
const body = await c.req.json();
191187

192188
const { sessionId, metadata: metadataUpdates } = body as {
@@ -195,8 +191,8 @@ export async function updateSession(c: HonoContext) {
195191
};
196192

197193
try {
198-
if (!session) {
199-
return c.json({ error: 'Session not found' }, 404);
194+
if (!sessionId) {
195+
return c.json({ error: 'SessionId not found' }, 404);
200196
}
201197

202198
const sessionInfo = await server.daoFactory.getSessionInfo(sessionId);
@@ -223,14 +219,12 @@ export async function updateSession(c: HonoContext) {
223219
*/
224220
export async function deleteSession(c: HonoContext) {
225221
const server = c.get('server');
226-
const session = c.get('session');
222+
const sessionId = (await c.req.json())?.sessionId
227223

228-
if (!session) {
229-
return c.json({ error: 'Session not found' }, 404);
224+
if (!sessionId) {
225+
return c.json({ error: 'sessionId not found' }, 404);
230226
}
231227

232-
const sessionId = session.id;
233-
234228
try {
235229
const sessionPool = server.getSessionPool();
236230

multimodal/tarko/agent-server-next/src/routes/sessions.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,7 @@ export function createSessionRoutes(): Hono<{ Variables: ContextVariables }> {
1919
router.post('/api/v1/sessions/create', exclusiveModeMiddleware, sessionsController.createSession);
2020

2121
// Routes that require session restore middleware
22-
router.use('/api/v1/sessions/details', sessionRestoreMiddleware);
23-
router.use('/api/v1/sessions/events', sessionRestoreMiddleware);
24-
router.use('/api/v1/sessions/events/*', sessionRestoreMiddleware);
2522
router.use('/api/v1/sessions/status', sessionRestoreMiddleware);
26-
router.use('/api/v1/sessions/update', sessionRestoreMiddleware);
27-
router.use('/api/v1/sessions/delete', sessionRestoreMiddleware);
2823
router.use('/api/v1/sessions/generate-summary', sessionRestoreMiddleware);
2924
router.use('/api/v1/sessions/share', sessionRestoreMiddleware);
3025
router.use('/api/v1/sessions/workspace/*', sessionRestoreMiddleware);

0 commit comments

Comments
 (0)