-
Notifications
You must be signed in to change notification settings - Fork 32
Fix: [BUG] [v0.0.7] Root feedback screen shows a --session example that saves the flag text into the bug message #43645
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
6d3d8c2
b196cde
60d7904
21c3f6e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| ```python | ||
| import argparse | ||
|
|
||
| def parse_args(): | ||
| parser = argparse.ArgumentParser() | ||
| parser.add_argument('type', choices=['bug', 'feature']) | ||
| parser.add_argument('message', nargs='+') | ||
| parser.add_argument('--session', help='session ID') | ||
| return parser.parse_args() | ||
|
|
||
| def save_feedback(args): | ||
| message = ' '.join(args.message) | ||
| if args.session: | ||
| # Save feedback with session ID | ||
| feedback = {'type': args.type, 'message': message, 'session_id': args.session} | ||
| else: | ||
| # Save feedback without session ID | ||
| feedback = {'type': args.type, 'message': message} | ||
| # Save feedback to file | ||
| with open('~/.cortex/feedback/feedback.json', 'w') as f: | ||
| import json | ||
| json.dump(feedback, f) | ||
|
Comment on lines
+20
to
+22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Critical: The path Additionally, the directory may not exist, causing a 🐛 Proposed fix+import os
+
def save_feedback(args):
message = ' '.join(args.message)
if args.session:
# Save feedback with session ID
feedback = {'type': args.type, 'message': message, 'session_id': args.session}
else:
# Save feedback without session ID
feedback = {'type': args.type, 'message': message}
# Save feedback to file
- with open('~/.cortex/feedback/feedback.json', 'w') as f:
- import json
+ feedback_dir = os.path.expanduser('~/.cortex/feedback')
+ os.makedirs(feedback_dir, exist_ok=True)
+ with open(os.path.join(feedback_dir, 'feedback.json'), 'w') as f:
json.dump(feedback, f)Also move 🤖 Prompt for AI Agents |
||
|
|
||
| def main(): | ||
| args = parse_args() | ||
| save_feedback(args) | ||
|
|
||
| if __name__ == '__main__': | ||
| main() | ||
| ``` | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ mod views; | |
| use anyhow::Result; | ||
| use console::style; | ||
| use dialoguer::{Input, Select}; | ||
| use structopt::StructOpt; | ||
|
|
||
| const DEFAULT_RPC_URL: &str = "https://chain.platform.network"; | ||
|
|
||
|
|
@@ -19,8 +20,19 @@ const MENU_ITEMS: &[&str] = &[ | |
| "Claim Bounty", | ||
| "Change RPC URL", | ||
| "Quit", | ||
| "Cortex Feedback", | ||
| ]; | ||
|
|
||
| #[derive(StructOpt)] | ||
| struct CortexFeedback { | ||
| #[structopt(short = "s", long = "session")] | ||
| session: Option<String>, | ||
| #[structopt(short = "b", long = "bug")] | ||
| bug: Option<String>, | ||
| #[structopt(short = "m", long = "message")] | ||
| message: String, | ||
| } | ||
|
|
||
|
Comment on lines
+26
to
+35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
If this field should be persisted: let json = serde_json::json!({
"session_id": feedback.session.unwrap_or_default(),
+ "bug": feedback.bug,
"message": feedback.message,
});If the field is intentionally ignored, remove it from the struct to avoid confusing users who provide 🤖 Prompt for AI Agents |
||
| fn print_header(rpc_url: &str) { | ||
| println!(); | ||
| println!(" {}", style("bounty-challenge").cyan().bold()); | ||
|
|
@@ -69,7 +81,19 @@ async fn main() -> Result<()> { | |
| ); | ||
| Ok(()) | ||
| } | ||
| 9 => break, | ||
| 9 => { | ||
| let feedback = CortexFeedback::from_args(); | ||
| let mut file_path = std::path::PathBuf::from("~/.cortex/feedback"); | ||
| file_path.push(format!("{}.json", chrono::Utc::now().timestamp())); | ||
| let mut file = std::fs::File::create(file_path)?; | ||
| let json = serde_json::json!({ | ||
| "session_id": feedback.session.unwrap_or_default(), | ||
| "message": feedback.message, | ||
| }); | ||
| serde_json::to_writer_pretty(&mut file, &json)?; | ||
| Ok(()) | ||
| } | ||
|
Comment on lines
+84
to
+95
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Multiple critical issues in feedback handler.
🐛 Proposed fix 9 => {
- let feedback = CortexFeedback::from_args();
- let mut file_path = std::path::PathBuf::from("~/.cortex/feedback");
+ // Prompt user for feedback in interactive mode
+ let message: String = Input::new()
+ .with_prompt("Enter feedback message")
+ .interact_text()?;
+ let session: String = Input::new()
+ .with_prompt("Session ID (optional)")
+ .allow_empty(true)
+ .interact_text()?;
+
+ let home = std::env::var("HOME").unwrap_or_else(|_| ".".to_string());
+ let mut file_path = std::path::PathBuf::from(home);
+ file_path.push(".cortex/feedback");
+ std::fs::create_dir_all(&file_path)?;
file_path.push(format!("{}.json", chrono::Utc::now().timestamp()));
let mut file = std::fs::File::create(file_path)?;
let json = serde_json::json!({
- "session_id": feedback.session.unwrap_or_default(),
- "message": feedback.message,
+ "session_id": session,
+ "message": message,
});
serde_json::to_writer_pretty(&mut file, &json)?;
+ println!(" {} Feedback saved.", style("✓").green());
Ok(())
}🤖 Prompt for AI Agents |
||
| 10 => break, | ||
| _ => break, | ||
| }; | ||
|
|
||
|
|
@@ -84,4 +108,4 @@ async fn main() -> Result<()> { | |
|
|
||
| println!("{}", style("Goodbye!").dim()); | ||
| Ok(()) | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -178,4 +178,4 @@ pub async fn run(rpc_url: &str) -> Result<()> { | |
|
|
||
| super::restore_terminal(&mut terminal)?; | ||
| Ok(()) | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,15 @@ use crossterm::{ | |
| }; | ||
| use ratatui::prelude::*; | ||
| use std::io; | ||
| use structopt::StructOpt; | ||
|
|
||
| #[derive(StructOpt)] | ||
| struct FeedbackOptions { | ||
| #[structopt(short = "s", long = "session")] | ||
| session: Option<String>, | ||
| #[structopt()] | ||
| message: String, | ||
| } | ||
|
|
||
| pub fn setup_terminal() -> Result<Terminal<CrosstermBackend<io::Stdout>>> { | ||
| enable_raw_mode()?; | ||
|
|
@@ -25,3 +34,24 @@ pub fn restore_terminal(terminal: &mut Terminal<CrosstermBackend<io::Stdout>>) - | |
| terminal.show_cursor()?; | ||
| Ok(()) | ||
| } | ||
|
|
||
| pub fn run_feedback(terminal: &mut Terminal<CrosstermBackend<io::Stdout>>) -> Result<()> { | ||
| let args: Vec<String> = std::env::args().collect(); | ||
| let options = FeedbackOptions::from_args(&args[1..]); | ||
| let message = options.message; | ||
| let session = options.session; | ||
|
|
||
| if let Some(session_id) = session { | ||
| // Save feedback with session_id | ||
| println!("Feedback saved with session_id: {}", session_id); | ||
| // Save JSON with session_id and message | ||
| // ... | ||
| } else { | ||
| // Save feedback without session_id | ||
| println!("Feedback saved without session_id"); | ||
| // Save JSON with message only | ||
| // ... | ||
| } | ||
|
|
||
| Ok(()) | ||
| } | ||
|
Comment on lines
+38
to
+57
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Incorrect
Suggested removal or fixIf this function is intended to be used, fix the API and add actual logic: -pub fn run_feedback(terminal: &mut Terminal<CrosstermBackend<io::Stdout>>) -> Result<()> {
- let args: Vec<String> = std::env::args().collect();
- let options = FeedbackOptions::from_args(&args[1..]);
+pub fn run_feedback(_terminal: &mut Terminal<CrosstermBackend<io::Stdout>>) -> Result<()> {
+ let options = FeedbackOptions::from_args();Otherwise, consider removing this dead code entirely since 🤖 Prompt for AI Agents |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed filename will overwrite previous feedback submissions.
The Rust CLI in
bins/bounty-cli/src/main.rsuses timestamped filenames ({timestamp}.json) to preserve each submission. This script uses a fixedfeedback.json, so every new submission discards the previous one.🔧 Proposed fix to match Rust behavior
🤖 Prompt for AI Agents