Skip to content
Merged
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
9 changes: 9 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Reprompt

## Rust code instructions

- Always collapse if statements per https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
- Always inline format! args when possible per https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
- Use method references over closures when possible per https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure_for_method_calls
- Run `cargo make test` first and if it passes, run `cargo make check-all` automatically after making Rust changes. Do not ask for permission to do this.
- Do not refer to the internal types as `crate::<name>::<symbol>`, import `crate::<name>` instead and call the symbol directly using `<name>::<symbol>`. For example `crate::port_config::ALL_PROVIDER_TYPES` must be `port_config::ALL_PROVIDER_TYPES`. Same applies to such way of importing internal symbols: `ollana::port_config::parse_port_mappings`.
45 changes: 45 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ edition = "2024"
[dependencies]
arboard = "3.3.0"
anyhow = "1.0.98"
chrono = { version = "0.4", features = ["serde"] }
eframe = { version = "0.31.1", features = ["default_fonts", "glow", "persistence", "wayland", "x11"], default-features = false }
egui = "0.31.1"
egui-modal = { git = "https://github.com/zeozeozeo/egui-modal.git", branch = "egui-0.31" }
Expand Down
58 changes: 45 additions & 13 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ pub struct App {
ollama_client: OllamaClient,
#[serde(skip)]
commonmark_cache: CommonMarkCache,
#[serde(skip)]
sort_mode: SortMode,
}

Expand Down Expand Up @@ -170,6 +169,7 @@ impl App {

fn handle_keyboard_input(&self, ctx: &egui::Context) -> Option<AppAction> {
let mut action = None;

ctx.input(|i| {
if i.modifiers.ctrl {
if i.key_pressed(egui::Key::Equals) || i.key_pressed(egui::Key::Plus) {
Expand All @@ -185,6 +185,37 @@ impl App {
action = Some(AppAction::SetUIScale(new_scale));
}
}
} else if i.key_pressed(egui::Key::Tab) && !self.view.is_modal_shown() {
// Tab/Shift-Tab: Navigate between prompts
let prompt_indices = self.sort_prompt_indices();

if let ViewMainPanel::Prompt(current_idx) = self.view.main_panel {
if !self.prompts.is_empty()
&& let Some(pos) = prompt_indices.iter().position(|&idx| idx == current_idx)
{
let next_idx = if i.modifiers.shift {
// Shift-Tab: Previous prompt
if pos > 0 {
prompt_indices[pos - 1]
} else {
prompt_indices[prompt_indices.len() - 1]
}
} else {
// Tab: Next prompt
if pos < prompt_indices.len() - 1 {
prompt_indices[pos + 1]
} else {
prompt_indices[0]
}
};

action = Some(AppAction::SelectPrompt(next_idx));
}
} else if !self.prompts.is_empty()
&& let Some(&first_idx) = prompt_indices.first()
{
action = Some(AppAction::SelectPrompt(first_idx));
}
}
});
action
Expand Down Expand Up @@ -273,10 +304,12 @@ impl App {
}
AppAction::CreatePrompt => {
if let Some((title, content)) = self.view.get_add_prompt_modal_data() {
let new_prompt_idx = self.prompts.len();
self.add_prompt(title.clone(), content.clone());

add_prompt_modal.close();
self.view.close_modal();
self.view.select_prompt(new_prompt_idx);
}
}
AppAction::OpenRemovePromptDialog(idx) => {
Expand Down Expand Up @@ -310,6 +343,7 @@ impl App {

edit_prompt_modal.close();
self.view.close_modal();
self.view.select_prompt(idx);
}
}
AppAction::SelectPrompt(idx) => {
Expand Down Expand Up @@ -448,7 +482,7 @@ impl App {
.max_width(max_width)
.min_width(min_width)
.show(ctx, |ui| {
ui.add_space(6.0);
ui.add_space(20.0);

ui.horizontal_top(|ui| {
assign_if_some!(action, self.show_left_panel_create_protmp_button(ui));
Expand All @@ -458,6 +492,8 @@ impl App {
self.show_left_panel_sort_mode_selector(ui);
});

ui.add_space(6.0);

ui.separator();

assign_if_some!(
Expand All @@ -466,12 +502,12 @@ impl App {
);

ui.with_layout(Layout::bottom_up(egui::Align::Min), |ui| {
ui.add_space(6.0);
ui.add_space(12.0);

ui.horizontal(|ui| {
global_theme_switch(ui);

ui.add_space(6.0);
ui.add_space(12.0);

// UI Scale control
ui.horizontal(|ui| {
Expand All @@ -491,7 +527,7 @@ impl App {
});
});

ui.add_space(6.0);
ui.add_space(12.0);

// Version label (slightly smaller than default)
ui.label(egui::RichText::new(format!("v{VERSION}")).size(12.0));
Expand Down Expand Up @@ -520,12 +556,7 @@ impl App {
let mut action = None;

if ui
.add(
egui::Button::new("➕")
.fill(Color32::TRANSPARENT)
.small()
.stroke(Stroke::NONE),
)
.add(egui::Button::new("➕ Add Prompt").stroke(Stroke::NONE))
.on_hover_cursor(egui::CursorIcon::PointingHand)
.on_hover_text("Create new prompt")
.clicked()
Expand Down Expand Up @@ -667,7 +698,7 @@ impl App {
let prompt = &self.prompts[idx];
let selected = self.view.is_prompt_selected(idx);

ui.add_space(3.0);
ui.add_space(6.0);

assign_if_some!(action, prompt.show_left_panel(ui, selected, idx));

Expand Down Expand Up @@ -711,7 +742,8 @@ impl App {

egui::CentralPanel::default().show(ctx, |ui| match self.view.main_panel {
ViewMainPanel::Welcome => {
ui.add_space(20.0);
ui.add_space(40.0);

ui.with_layout(Layout::top_down(egui::Align::Center), |ui| {
ui.label("Welcome to the Reprompt app! Please select a model and add prompts to get started.");
});
Expand Down
Loading
Loading