Skip to content

Commit f5a2f18

Browse files
committed
Update TaskService.tsx
1 parent c50a0ee commit f5a2f18

File tree

1 file changed

+26
-21
lines changed

1 file changed

+26
-21
lines changed

src/frontend_react/src/services/TaskService.tsx

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,12 @@ export class TaskService {
8989
return `sid_${timestamp}_${random}`;
9090
}
9191
/**
92-
* Split subtask action into description and function/details parts
93-
* @param action The full action string to split
94-
* @returns Object containing description and functionOrDetails
95-
*/
92+
* Split subtask action into description and function/details parts
93+
* @param action The full action string to split
94+
* @returns Object containing description and functionOrDetails
95+
*/
9696
static splitSubtaskAction(action: string): { description: string; functionOrDetails: string | null } {
97-
// Check for "Function:" pattern
98-
// Check for "Function:" pattern
97+
// Check for "Function:" pattern (with period before Function)
9998
const functionMatch = action.match(/^(.+?)\.\s*Function:\s*(.+)$/);
10099
if (functionMatch) {
101100
return {
@@ -104,31 +103,37 @@ export class TaskService {
104103
};
105104
}
106105

107-
// Check for "Provide more details about:" pattern
108-
const detailsMatch = action.match(/^Provide more details about:\s*(.+)$/);
109-
if (detailsMatch) {
110-
return {
111-
description: "Provide more details about",
112-
functionOrDetails: detailsMatch[1].trim()
113-
};
114-
}
115-
116-
// Check for "Analyze the task:" pattern
117-
const analyzeMatch = action.match(/^Analyze the task:\s*(.+)$/);
118-
if (analyzeMatch) {
106+
// Check for any colon pattern - split on first colon
107+
const colonIndex = action.indexOf(':');
108+
if (colonIndex !== -1) {
119109
return {
120-
description: "Analyze the task",
121-
functionOrDetails: analyzeMatch[1].trim()
110+
description: action.substring(0, colonIndex).trim(),
111+
functionOrDetails: action.substring(colonIndex + 1).trim()
122112
};
123113
}
124114

125-
// If no pattern matches, return the full action as description
115+
// If no colon found, return the full action as description
126116
return {
127117
description: action,
128118
functionOrDetails: null
129119
};
130120
}
121+
/**
122+
* Clean text by converting any non-alphanumeric character to spaces
123+
* @param text The text string to clean
124+
* @returns Cleaned text string with only letters, numbers, and spaces
125+
*/
126+
static cleanTextToSpaces(text: string): string {
127+
if (!text) return '';
128+
129+
// Replace any non-alphanumeric character with a space
130+
let cleanedText = text.replace(/[^a-zA-Z0-9]/g, ' ');
131131

132+
// Clean up multiple spaces and trim
133+
cleanedText = cleanedText.replace(/\s+/g, ' ').trim();
134+
135+
return cleanedText;
136+
}
132137
/**
133138
* Submit an input task to create a new plan
134139
* @param description Task description

0 commit comments

Comments
 (0)