@@ -14,6 +14,7 @@ public partial class AddTaskWindow : Window
1414 private bool _isClarificationRound = false ; // State for clarification
1515 private string _originalTaskDescription = string . Empty ; // To store original task if clarification is needed
1616 private bool _isLlmConfigErrorNotified = false ; // Flag to track if user has been notified of LLM config error
17+ private readonly IntentRecognizer _intentRecognizer = new IntentRecognizer ( ) ;
1718
1819 public string TaskDescription { get ; private set ; }
1920 public int SelectedListIndex { get ; private set ; } // 0-indexed
@@ -128,7 +129,7 @@ private void ResetClarificationButton_Click(object sender, RoutedEventArgs e)
128129
129130 private async void AddTaskButton_Click ( object sender , RoutedEventArgs e )
130131 {
131- string currentTaskDescription = TaskDescriptionTextBox . Text . Trim ( ) ;
132+ string currentTaskDescription = NormalizeTaskText ( TaskDescriptionTextBox . Text ) ;
132133 SelectedListIndex = ListSelectorComboBox . SelectedIndex ;
133134 string configErrorSubstring = "LLM dummy response (Configuration Error: API key missing or placeholder)" ;
134135
@@ -182,6 +183,7 @@ private async void AddTaskButton_Click(object sender, RoutedEventArgs e)
182183 // Prioritization & Task Creation (either directly or after clarification)
183184 TaskDescription = currentTaskDescription ; // Final task description
184185 var ( llmImportance , llmUrgency ) = await _llmService . GetTaskPriorityAsync ( TaskDescription ) ;
186+ var ( ruleImportance , ruleUrgency ) = _intentRecognizer . EstimatePriority ( TaskDescription ) ;
185187
186188 // Check for LLM configuration error after priority analysis
187189 // string configErrorSubstring has been defined above
@@ -195,18 +197,20 @@ private async void AddTaskButton_Click(object sender, RoutedEventArgs e)
195197 }
196198
197199 // --- LLM Suggestion Logic ---
198- int suggestedIndex = GetIndexFromPriority ( llmImportance , llmUrgency ) ;
200+ var ( finalImportanceByAi , finalUrgencyByAi , sourceTag ) = MergePriority ( llmImportance , llmUrgency , ruleImportance , ruleUrgency ) ;
201+ int suggestedIndex = GetIndexFromPriority ( finalImportanceByAi , finalUrgencyByAi ) ;
199202 ListSelectorComboBox . SelectedIndex = suggestedIndex ;
200203
201204 if ( suggestedIndex != - 1 && ListSelectorComboBox . SelectedItem != null )
202205 {
203- LlmSuggestionText . Text = $ "LLM Suggests: { ListSelectorComboBox . SelectedItem as string } ";
206+ string label = ListSelectorComboBox . SelectedItem as string ;
207+ LlmSuggestionText . Text = $ "AI建议象限({ sourceTag } ): { label } ";
204208 LlmSuggestionText . Visibility = Visibility . Visible ;
205209 }
206210 else
207211 {
208212 // Handle cases where suggestion is ambiguous or mapping fails
209- LlmSuggestionText . Text = "LLM suggestion unavailable. " ;
213+ LlmSuggestionText . Text = "AI建议暂不可用,请手动选择象限。 " ;
210214 LlmSuggestionText . Visibility = Visibility . Collapsed ; // Or Visible with a different message
211215 }
212216 // --- End LLM Suggestion Logic ---
@@ -283,7 +287,7 @@ public static int GetIndexFromPriority(string importance, string urgency)
283287
284288 // Default or fallback for Medium/Unknown - could be -1 to indicate no selection
285289 // Or a specific category like "Important & Urgent"
286- return 0 ; // Defaulting to "Important & Urgent" for now
290+ return 1 ; // 对未知结果偏向“重要不紧急”,降低默认紧急打扰
287291 }
288292
289293 // Helper method to map ComboBox index back to Importance/Urgency strings
@@ -312,5 +316,59 @@ private void CloseButton_Click(object sender, RoutedEventArgs e)
312316 this . DialogResult = false ;
313317 this . Close ( ) ;
314318 }
319+
320+ private static bool IsKnownPriority ( string value )
321+ {
322+ if ( string . IsNullOrWhiteSpace ( value ) )
323+ return false ;
324+
325+ string v = value . Trim ( ) . ToLowerInvariant ( ) ;
326+ return v == "high" || v == "medium" || v == "low" ;
327+ }
328+
329+ private ( string importance , string urgency , string sourceTag ) MergePriority (
330+ string llmImportance ,
331+ string llmUrgency ,
332+ string ruleImportance ,
333+ string ruleUrgency )
334+ {
335+ bool llmValid = IsKnownPriority ( llmImportance ) && IsKnownPriority ( llmUrgency )
336+ && ! ContainsDummy ( llmImportance )
337+ && ! ContainsDummy ( llmUrgency ) ;
338+
339+ if ( llmValid )
340+ {
341+ return ( llmImportance , llmUrgency , "LLM" ) ;
342+ }
343+
344+ bool ruleValid = IsKnownPriority ( ruleImportance ) && IsKnownPriority ( ruleUrgency ) ;
345+ if ( ruleValid )
346+ {
347+ return ( ruleImportance , ruleUrgency , "规则" ) ;
348+ }
349+
350+ return ( "Medium" , "Low" , "默认" ) ;
351+ }
352+
353+ private static bool ContainsDummy ( string value )
354+ {
355+ return ! string . IsNullOrWhiteSpace ( value ) &&
356+ value . IndexOf ( "dummy response" , StringComparison . OrdinalIgnoreCase ) >= 0 ;
357+ }
358+
359+ private string NormalizeTaskText ( string raw )
360+ {
361+ if ( string . IsNullOrWhiteSpace ( raw ) )
362+ return string . Empty ;
363+
364+ string trimmed = raw . Trim ( ) ;
365+ string extracted = _intentRecognizer . ExtractTaskDescription ( trimmed ) ;
366+ if ( ! string . IsNullOrWhiteSpace ( extracted ) )
367+ {
368+ return extracted . Trim ( ) ;
369+ }
370+
371+ return trimmed ;
372+ }
315373 }
316374} // Closing brace for namespace TimeTask
0 commit comments