core/apps/webapp/app/routes/api.v1.spaces.$spaceId.reset.ts
Harshith Mullapudi f39c7cc6d0
feat: remove trigger and run base on bullmq (#126)
* feat: remove trigger and run base on bullmq
* fix: telemetry and trigger deploymen
* feat: add Ollama container and update ingestion status for unchanged documents
* feat: add logger to bullmq workers
* 1. Remove chat and deep-search from trigger
2. Add ai/sdk for chat UI
3. Added a better model manager

* refactor: simplify clustered graph query and add stop conditions for AI responses

* fix: streaming

* fix: docker docs

---------

Co-authored-by: Manoj <saimanoj58@gmail.com>
2025-10-26 12:56:12 +05:30

56 lines
1.6 KiB
TypeScript

import { z } from "zod";
import { createHybridActionApiRoute } from "~/services/routeBuilders/apiBuilder.server";
import { SpaceService } from "~/services/space.server";
import { json } from "@remix-run/node";
import { logger } from "~/services/logger.service";
import { enqueueSpaceAssignment } from "~/lib/queue-adapter.server";
// Schema for space ID parameter
const SpaceParamsSchema = z.object({
spaceId: z.string(),
});
const { loader, action } = createHybridActionApiRoute(
{
params: SpaceParamsSchema,
allowJWT: true,
authorization: {
action: "search",
},
corsStrategy: "all",
},
async ({ authentication, params }) => {
const userId = authentication.userId;
const { spaceId } = params;
const spaceService = new SpaceService();
// Reset the space (clears all assignments, summary, and metadata)
const space = await spaceService.resetSpace(spaceId, userId);
logger.info(`Reset space ${space.id} successfully`);
// Trigger automatic episode assignment for the reset space
try {
await enqueueSpaceAssignment({
userId: userId,
workspaceId: space.workspaceId,
mode: "new_space",
newSpaceId: space.id,
batchSize: 20, // Analyze recent episodes for reassignment
});
logger.info(`Triggered space assignment for reset space ${space.id}`);
} catch (error) {
// Don't fail space reset if assignment fails
logger.warn(
`Failed to trigger assignment for space ${space.id}:`,
error as Record<string, unknown>,
);
}
return json(space);
},
);
export { loader, action };