MCPcopy
hub / github.com/callumalpass/tasknotes / startPomodoro

Method startPomodoro

src/api/PomodoroController.ts:23–71  ·  view source on GitHub ↗
(req: HTTPRequestLike, res: HTTPResponseLike)

Source from the content-addressed store, hash-verified

21
22 @Post("/api/pomodoro/start")
23 async startPomodoro(req: HTTPRequestLike, res: HTTPResponseLike): Promise<void> {
24 try {
25 const body = await this.parseRequestBody<StartPomodoroRequestBody>(req);
26 let task;
27
28 // Get task if taskId provided
29 if (body.taskId) {
30 const foundTask = await this.cacheManager.getTaskInfo(body.taskId);
31 if (!foundTask) {
32 this.sendResponse(res, 404, this.errorResponse("Task not found"));
33 return;
34 }
35 task = foundTask;
36 }
37
38 // Check if session is already running
39 const currentState = this.plugin.pomodoroService.getState();
40 if (currentState.isRunning) {
41 this.sendResponse(
42 res,
43 400,
44 this.errorResponse(
45 "Pomodoro session is already running. Stop or pause the current session first."
46 )
47 );
48 return;
49 }
50
51 // Start pomodoro with optional duration
52 const duration =
53 body.duration !== undefined ? parseInt(String(body.duration), 10) : undefined;
54 await this.plugin.pomodoroService.startPomodoro(task, duration);
55
56 // Get updated state
57 const newState = this.plugin.pomodoroService.getState();
58
59 this.sendResponse(
60 res,
61 200,
62 this.successResponse({
63 session: newState.currentSession,
64 task: task || null,
65 message: "Pomodoro session started",
66 })
67 );
68 } catch (error: unknown) {
69 this.sendResponse(res, 400, this.errorResponse(this.getErrorMessage(error)));
70 }
71 }
72
73 @Post("/api/pomodoro/stop")
74 async stopPomodoro(req: HTTPRequestLike, res: HTTPResponseLike): Promise<void> {

Callers

nothing calls this directly

Calls 6

sendResponseMethod · 0.80
errorResponseMethod · 0.80
successResponseMethod · 0.80
getTaskInfoMethod · 0.65
getStateMethod · 0.45
getErrorMessageMethod · 0.45

Tested by

no test coverage detected