Skip to content

Commit 3dbeaa4

Browse files
committed
refactor: clean up migration code and improve widget display formatting
- Remove obsolete migrate_agent_runs_to_session_ids function from agents commands - Add trailing empty line removal logic to ReadResultWidget for cleaner code display - Improve code presentation consistency in UI components
1 parent 5e9738c commit 3dbeaa4

File tree

2 files changed

+5
-60
lines changed

2 files changed

+5
-60
lines changed

src-tauri/src/commands/agents.rs

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -698,66 +698,6 @@ pub async fn list_agent_runs_with_metrics(
698698
Ok(runs_with_metrics)
699699
}
700700

701-
/// Migration function for existing agent_runs data
702-
#[tauri::command]
703-
pub async fn migrate_agent_runs_to_session_ids(db: State<'_, AgentDb>) -> Result<String, String> {
704-
let conn = db.0.lock().map_err(|e| e.to_string())?;
705-
706-
// Get all agent_runs that have empty session_id but have output data
707-
let mut stmt = conn.prepare(
708-
"SELECT id, output FROM agent_runs WHERE session_id = '' AND output != ''"
709-
).map_err(|e| e.to_string())?;
710-
711-
let rows = stmt.query_map([], |row| {
712-
Ok((row.get::<_, i64>(0)?, row.get::<_, String>(1)?))
713-
}).map_err(|e| e.to_string())?;
714-
715-
let mut migrated_count = 0;
716-
let mut failed_count = 0;
717-
718-
for row_result in rows {
719-
let (run_id, output) = row_result.map_err(|e| e.to_string())?;
720-
721-
// Extract session ID from JSONL output
722-
let mut session_id = String::new();
723-
for line in output.lines() {
724-
if let Ok(json) = serde_json::from_str::<JsonValue>(line) {
725-
if let Some(sid) = json.get("sessionId").and_then(|s| s.as_str()) {
726-
session_id = sid.to_string();
727-
break;
728-
}
729-
}
730-
}
731-
732-
if !session_id.is_empty() {
733-
// Update the run with the extracted session ID
734-
match conn.execute(
735-
"UPDATE agent_runs SET session_id = ?1 WHERE id = ?2",
736-
params![session_id, run_id],
737-
) {
738-
Ok(_) => {
739-
migrated_count += 1;
740-
info!("Migrated agent_run {} with session_id {}", run_id, session_id);
741-
}
742-
Err(e) => {
743-
error!("Failed to update agent_run {}: {}", run_id, e);
744-
failed_count += 1;
745-
}
746-
}
747-
} else {
748-
warn!("Could not extract session ID from agent_run {}", run_id);
749-
failed_count += 1;
750-
}
751-
}
752-
753-
let message = format!(
754-
"Migration completed: {} runs migrated, {} failed",
755-
migrated_count, failed_count
756-
);
757-
info!("{}", message);
758-
Ok(message)
759-
}
760-
761701
/// Execute a CC agent with streaming output
762702
#[tauri::command]
763703
pub async fn execute_agent(

src/components/ToolWidgets.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,11 @@ export const ReadResultWidget: React.FC<{ content: string; filePath?: string }>
474474
}
475475
}
476476

477+
// Remove trailing empty lines
478+
while (codeLines.length > 0 && codeLines[codeLines.length - 1] === '') {
479+
codeLines.pop();
480+
}
481+
477482
return {
478483
codeContent: codeLines.join('\n'),
479484
startLineNumber: minLineNumber === Infinity ? 1 : minLineNumber

0 commit comments

Comments
 (0)