Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion crates/goose-cli/src/commands/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,32 @@ use regex::Regex;
use std::fs;
use std::io::Write;
use std::path::PathBuf;

use crate::session::Session;
use crate::ui;
use anyhow::Result;
Comment on lines +11 to +13
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conflicting imports: line 5 imports Session from goose::session, and line 11 imports Session from crate::session. These are two different types and will cause a compilation error. Additionally, line 13 duplicates the anyhow::Result import already present on line 2.

Copilot uses AI. Check for mistakes.
const TRUNCATED_DESC_LENGTH: usize = 60;

pub fn handle_command(command: &str, session: &mut Session) -> Result<()> {
if command.trim() == "/clear" {
// Reset the session context usage
session.reset_context_usage();

Comment on lines +18 to +20
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The handle_command function references session.reset_context_usage(), but the actual goose::session::Session struct doesn't have this method. The method only exists on the duplicate Session struct incorrectly added to task_execution_display/mod.rs.

Suggested change
// Reset the session context usage
session.reset_context_usage();

Copilot uses AI. Check for mistakes.
// Reset the UI progress bar to zero
ui::reset_progress_bar();
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The module crate::ui does not exist in the goose-cli crate. Calling ui::reset_progress_bar() will result in a compilation error.

Copilot uses AI. Check for mistakes.

println!("Context cleared.");
return Ok(());
}

// Existing command handling code here...

println!("Command not recognized: {}", command);
Ok(())
}
Comment on lines +16 to +32
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The handle_command function is defined but never integrated into the CLI's command handling flow. There's no evidence this function is called from the session input handling code, so the /clear command won't actually be processed.

Copilot uses AI. Check for mistakes.




pub async fn remove_sessions(sessions: Vec<Session>) -> Result<()> {
println!("The following sessions will be removed:");
for session in &sessions {
Expand Down
50 changes: 50 additions & 0 deletions crates/goose-cli/src/session/task_execution_display/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,56 @@ fn process_output_for_display(output: &str) -> String {
safe_truncate(&clean_output, OUTPUT_PREVIEW_LENGTH)
}

pub struct Session {
pub id: String,
pub name: String,
pub token_usage: usize,
pub max_token_limit: usize,
pub other_usage_metrics: usize,
pub messages_count: usize,
pub context_data_size: usize,
// Add other relevant session fields here
}

impl Session {
pub fn new(id: String, name: String, max_token_limit: usize) -> Self {
Self {
id,
name,
token_usage: 0,
max_token_limit,
other_usage_metrics: 0,
messages_count: 0,
context_data_size: 0,
// Initialize other fields as needed
}
}

pub fn add_tokens(&mut self, count: usize) {
self.token_usage += count;
// Possibly add checks against max_token_limit
}

pub fn add_message(&mut self) {
self.messages_count += 1;
}

pub fn reset_context_usage(&mut self) {
self.token_usage = 0;
self.other_usage_metrics = 0;
self.messages_count = 0;
self.context_data_size = 0;
// Reset other context/session related state if applicable
}

pub fn is_token_limit_reached(&self) -> bool {
self.token_usage >= self.max_token_limit
}

// Add more existing methods relevant to session management
}
Comment on lines +52 to +99
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This introduces a duplicate Session struct. The goose::session module already defines a Session struct in session_manager.rs with fields like id, name, total_tokens, accumulated_total_tokens, etc. Creating a duplicate struct here will cause type conflicts and won't work with existing code that uses goose::session::Session.

Copilot uses AI. Check for mistakes.


pub fn format_task_execution_notification(
data: &Value,
) -> Option<(String, Option<String>, Option<String>)> {
Expand Down
30 changes: 30 additions & 0 deletions ui/desktop/src/components/context_management/ProgressBar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React, { useState, useImperativeHandle, forwardRef } from 'react';

export interface ProgressBarHandle {
resetProgressBar: () => void;
}

const ProgressBar = forwardRef<ProgressBarHandle>((props, ref) => {
const [progress, setProgress] = useState(0); // percentage 0-100
const [tokensUsed, setTokensUsed] = useState(0);

// Expose resetProgressBar method to parent components via ref
useImperativeHandle(ref, () => ({
resetProgressBar() {
setProgress(0);
setTokensUsed(0);
},
}));

// Simulate progress text display and progress bar
return (
<div>
<div style={{ marginBottom: '8px' }}>
Context Usage: {progress}% ({tokensUsed} tokens)
</div>
<progress value={progress} max={100} style={{ width: '100%' }} />
</div>
);
});
Comment on lines +7 to +28
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The props parameter is unused. Additionally, there's no mechanism to update progress or tokensUsed state from external data sources. The component initializes state to 0 but never receives updates, making it non-functional. Consider accepting progress and tokensUsed as props or providing a way to update them from a parent component or context.

Suggested change
const ProgressBar = forwardRef<ProgressBarHandle>((props, ref) => {
const [progress, setProgress] = useState(0); // percentage 0-100
const [tokensUsed, setTokensUsed] = useState(0);
// Expose resetProgressBar method to parent components via ref
useImperativeHandle(ref, () => ({
resetProgressBar() {
setProgress(0);
setTokensUsed(0);
},
}));
// Simulate progress text display and progress bar
return (
<div>
<div style={{ marginBottom: '8px' }}>
Context Usage: {progress}% ({tokensUsed} tokens)
</div>
<progress value={progress} max={100} style={{ width: '100%' }} />
</div>
);
});
export interface ProgressBarProps {
progress: number; // percentage 0-100
tokensUsed: number;
onReset?: () => void;
}
const ProgressBar = forwardRef<ProgressBarHandle, ProgressBarProps>(
({ progress, tokensUsed, onReset }, ref) => {
// Expose resetProgressBar method to parent components via ref
useImperativeHandle(ref, () => ({
resetProgressBar() {
if (onReset) {
onReset();
}
},
}));
// Display progress text and progress bar
return (
<div>
<div style={{ marginBottom: '8px' }}>
Context Usage: {progress}% ({tokensUsed} tokens)
</div>
<progress value={progress} max={100} style={{ width: '100%' }} />
</div>
);
}
);

Copilot uses AI. Check for mistakes.

export default ProgressBar;
Loading