Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8abf0b4493 | ||
|
|
6b1a1742b2 | ||
|
|
90b9ab6670 | ||
|
|
e64328aa98 |
No files matched your search
@@ -3,6 +3,32 @@
|
|||||||
All notable changes to CodeCraft. Versions follow [Semantic Versioning](https://semver.org/);
|
All notable changes to CodeCraft. Versions follow [Semantic Versioning](https://semver.org/);
|
||||||
until 1.0, minor versions may contain breaking changes.
|
until 1.0, minor versions may contain breaking changes.
|
||||||
|
|
||||||
|
## [v202611-00082] – 2026-11-27
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- **The web UI uses Ant Design.** Buttons, fields, drop-downs, check boxes, tabs, dialogs and notices are Ant Design components for a uniform look. Their colours come from the app's theme variables, so all themes and the light/dark switch keep working; the language of the components follows the app. The first load grows by about 260 KB (gzip).
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- **Factory board:** every column has its own vertical scrollbar; its title stays visible.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Deleting the chat that is open left an empty page (the chat view rendered fewer hooks than before).
|
||||||
|
|
||||||
|
## [v202611-00081] – 2026-11-27
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- **Force a queued message.** While the agent works, a message you send is queued and delivered at the agent's next step. A further Enter on the empty input (terminal client and web UI) or Ctrl+Enter with text (web UI) now interrupts the running step and delivers the queued messages at once, so the model reads them immediately; the queue list in the web UI has a "Force now" button for the same. New endpoint `POST /api/sessions/{id}/queue/force`.
|
||||||
|
- **Web UI:** Ctrl+J inserts a new line in the message field, like Shift+Enter (and like Ctrl+J / Shift+Enter in the terminal client).
|
||||||
|
- **Terminal client:** messages waiting for the agent are shown above the input field (also for followed server chats).
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- **Terminal client: long input and long questions are cut off.** The input field now wraps at its width instead of hiding the part beyond the edge, and questions, their options and your own answer in the question dialog wrap as well.
|
||||||
|
|
||||||
## [v202611-00080] – 2026-11-21
|
## [v202611-00080] – 2026-11-21
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<img alt="Version v202611-00080" src="https://img.shields.io/badge/version-v202611--00080-d69e2e?style=flat-square">
|
<img alt="Version v202611-00082" src="https://img.shields.io/badge/version-v202611--00082-d69e2e?style=flat-square">
|
||||||
<img alt="License: MIT" src="https://img.shields.io/badge/license-MIT-689d6a?style=flat-square">
|
<img alt="License: MIT" src="https://img.shields.io/badge/license-MIT-689d6a?style=flat-square">
|
||||||
<img alt="Rust backend" src="https://img.shields.io/badge/backend-Rust-b7410e?style=flat-square&logo=rust">
|
<img alt="Rust backend" src="https://img.shields.io/badge/backend-Rust-b7410e?style=flat-square&logo=rust">
|
||||||
<img alt="React PWA" src="https://img.shields.io/badge/frontend-React%20PWA-2d81ff?style=flat-square&logo=react">
|
<img alt="React PWA" src="https://img.shields.io/badge/frontend-React%20PWA-2d81ff?style=flat-square&logo=react">
|
||||||
|
|||||||
+227
-18
@@ -15,7 +15,7 @@ use ratatui::Frame;
|
|||||||
use ratatui::layout::{Constraint, Layout, Rect};
|
use ratatui::layout::{Constraint, Layout, Rect};
|
||||||
use ratatui::style::{Modifier, Style};
|
use ratatui::style::{Modifier, Style};
|
||||||
use ratatui::text::{Line, Span};
|
use ratatui::text::{Line, Span};
|
||||||
use ratatui::widgets::{Block, BorderType, Borders, Clear, Paragraph};
|
use ratatui::widgets::{Block, BorderType, Borders, Clear, Paragraph, Wrap};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
@@ -115,6 +115,10 @@ pub struct App {
|
|||||||
busy_since: Instant,
|
busy_since: Instant,
|
||||||
cancel: Option<CancellationToken>,
|
cancel: Option<CancellationToken>,
|
||||||
queue: VecDeque<String>,
|
queue: VecDeque<String>,
|
||||||
|
/// The messages of a followed server chat that wait for its agent (from the server's queue).
|
||||||
|
remote_queue: Vec<String>,
|
||||||
|
/// The running turn is interrupted so that the queued messages are sent at once.
|
||||||
|
forcing: bool,
|
||||||
dialog: Dialog,
|
dialog: Dialog,
|
||||||
session: LocalSession,
|
session: LocalSession,
|
||||||
effort: Option<String>,
|
effort: Option<String>,
|
||||||
@@ -211,6 +215,28 @@ fn wrap(text: &str, width: usize) -> Vec<String> {
|
|||||||
out
|
out
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Break text into rows of at most `width` display columns exactly where they fill up (nothing is trimmed, so
|
||||||
|
/// typed spaces stay visible); newlines start a new row.
|
||||||
|
fn hard_wrap(text: &str, width: usize) -> Vec<String> {
|
||||||
|
let width = width.max(1);
|
||||||
|
let mut out = Vec::new();
|
||||||
|
for raw in text.split('\n') {
|
||||||
|
let mut line = String::new();
|
||||||
|
let mut w = 0;
|
||||||
|
for ch in raw.chars() {
|
||||||
|
let cw = unicode_width::UnicodeWidthChar::width(ch).unwrap_or(0);
|
||||||
|
if w + cw > width && !line.is_empty() {
|
||||||
|
out.push(std::mem::take(&mut line));
|
||||||
|
w = 0;
|
||||||
|
}
|
||||||
|
line.push(ch);
|
||||||
|
w += cw;
|
||||||
|
}
|
||||||
|
out.push(line);
|
||||||
|
}
|
||||||
|
out
|
||||||
|
}
|
||||||
|
|
||||||
/// Inline markdown: `code` and **bold**.
|
/// Inline markdown: `code` and **bold**.
|
||||||
fn inline(text: &str, th: &Theme, base: Style) -> Vec<Span<'static>> {
|
fn inline(text: &str, th: &Theme, base: Style) -> Vec<Span<'static>> {
|
||||||
let mut spans = Vec::new();
|
let mut spans = Vec::new();
|
||||||
@@ -340,6 +366,8 @@ impl App {
|
|||||||
busy_since: Instant::now(),
|
busy_since: Instant::now(),
|
||||||
cancel: None,
|
cancel: None,
|
||||||
queue: VecDeque::new(),
|
queue: VecDeque::new(),
|
||||||
|
remote_queue: Vec::new(),
|
||||||
|
forcing: false,
|
||||||
dialog: Dialog::None,
|
dialog: Dialog::None,
|
||||||
todos: session.todos.clone(),
|
todos: session.todos.clone(),
|
||||||
context: session.context_tokens,
|
context: session.context_tokens,
|
||||||
@@ -408,7 +436,14 @@ impl App {
|
|||||||
self.busy_since = Instant::now();
|
self.busy_since = Instant::now();
|
||||||
} else {
|
} else {
|
||||||
self.cancel = None;
|
self.cancel = None;
|
||||||
if let Some(next) = self.queue.pop_front() {
|
if self.forcing {
|
||||||
|
// Interrupted on purpose: everything that waited goes out as one message.
|
||||||
|
self.forcing = false;
|
||||||
|
let all: Vec<String> = self.queue.drain(..).collect();
|
||||||
|
if !all.is_empty() {
|
||||||
|
self.send(all.join("\n\n"));
|
||||||
|
}
|
||||||
|
} else if let Some(next) = self.queue.pop_front() {
|
||||||
self.send(next);
|
self.send(next);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -488,6 +523,10 @@ impl App {
|
|||||||
let text = self.editor.take();
|
let text = self.editor.take();
|
||||||
let trimmed = text.trim().to_string();
|
let trimmed = text.trim().to_string();
|
||||||
if trimmed.is_empty() && self.images.is_empty() {
|
if trimmed.is_empty() && self.images.is_empty() {
|
||||||
|
// A further Enter on the empty field delivers the waiting messages at once.
|
||||||
|
if self.busy && self.has_queue() {
|
||||||
|
self.force_queue();
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if trimmed.starts_with('/') && self.slash(&trimmed) {
|
if trimmed.starts_with('/') && self.slash(&trimmed) {
|
||||||
@@ -506,6 +545,27 @@ impl App {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn has_queue(&self) -> bool {
|
||||||
|
if self.remote.is_some() { !self.remote_queue.is_empty() } else { !self.queue.is_empty() }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Interrupt the running step and deliver the queued messages now (the model reads them at once).
|
||||||
|
fn force_queue(&mut self) {
|
||||||
|
if let (Some(server), Some(r)) = (self.env.server.clone(), &self.remote) {
|
||||||
|
let id = r.id.clone();
|
||||||
|
let (tx, rx) = oneshot::channel();
|
||||||
|
tokio::spawn(async move {
|
||||||
|
let _ = tx.send(remote::force_queue(&server, &id).await.map(|_| String::new()));
|
||||||
|
});
|
||||||
|
self.pending_note = Some(rx);
|
||||||
|
self.status = t("forcing").into();
|
||||||
|
} else if let Some(c) = &self.cancel {
|
||||||
|
self.forcing = true;
|
||||||
|
c.cancel();
|
||||||
|
self.status = t("forcing").into();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Custom commands (server, project, built-in): "/name args" -> prompt.
|
/// Custom commands (server, project, built-in): "/name args" -> prompt.
|
||||||
fn expand_command(&mut self, text: &str) -> Option<String> {
|
fn expand_command(&mut self, text: &str) -> Option<String> {
|
||||||
let rest = text.strip_prefix('/')?;
|
let rest = text.strip_prefix('/')?;
|
||||||
@@ -849,6 +909,7 @@ impl App {
|
|||||||
|
|
||||||
fn leave_remote(&mut self) {
|
fn leave_remote(&mut self) {
|
||||||
if self.remote.take().is_some() {
|
if self.remote.take().is_some() {
|
||||||
|
self.remote_queue.clear();
|
||||||
self.items.clear();
|
self.items.clear();
|
||||||
self.todos = Value::Null;
|
self.todos = Value::Null;
|
||||||
self.busy = false;
|
self.busy = false;
|
||||||
@@ -860,6 +921,10 @@ impl App {
|
|||||||
fn send_remote(&mut self, text: String) {
|
fn send_remote(&mut self, text: String) {
|
||||||
let (Some(server), Some(r)) = (self.env.server.clone(), &self.remote) else { return };
|
let (Some(server), Some(r)) = (self.env.server.clone(), &self.remote) else { return };
|
||||||
let id = r.id.clone();
|
let id = r.id.clone();
|
||||||
|
if self.busy {
|
||||||
|
self.remote_queue.push(text.clone());
|
||||||
|
self.status = format!("{} ({})", t("queued"), self.remote_queue.len());
|
||||||
|
}
|
||||||
let (tx, rx) = oneshot::channel();
|
let (tx, rx) = oneshot::channel();
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
let _ = tx.send(remote::prompt(&server, &id, &text).await.map(|_| String::new()));
|
let _ = tx.send(remote::prompt(&server, &id, &text).await.map(|_| String::new()));
|
||||||
@@ -932,6 +997,7 @@ impl App {
|
|||||||
self.busy = false;
|
self.busy = false;
|
||||||
self.dialog = Dialog::None;
|
self.dialog = Dialog::None;
|
||||||
self.remote = Some(r);
|
self.remote = Some(r);
|
||||||
|
self.remote_queue.clear();
|
||||||
self.pending_snapshot = None;
|
self.pending_snapshot = None;
|
||||||
}
|
}
|
||||||
Err(e) => self.items.push(Item::Error(format!("{e:#}"))),
|
Err(e) => self.items.push(Item::Error(format!("{e:#}"))),
|
||||||
@@ -962,6 +1028,7 @@ impl App {
|
|||||||
let head = self.items.first().filter(|i| matches!(i, Item::Info(s) if s.starts_with("server chat:"))).map(|i| if let Item::Info(s) = i { s.clone() } else { String::new() });
|
let head = self.items.first().filter(|i| matches!(i, Item::Info(s) if s.starts_with("server chat:"))).map(|i| if let Item::Info(s) = i { s.clone() } else { String::new() });
|
||||||
self.items = head.map(Item::Info).into_iter().chain(items).collect();
|
self.items = head.map(Item::Info).into_iter().chain(items).collect();
|
||||||
self.busy = snap.busy;
|
self.busy = snap.busy;
|
||||||
|
self.remote_queue = snap.queue.clone();
|
||||||
if snap.busy && !was_busy {
|
if snap.busy && !was_busy {
|
||||||
self.busy_since = Instant::now();
|
self.busy_since = Instant::now();
|
||||||
}
|
}
|
||||||
@@ -1700,10 +1767,37 @@ impl App {
|
|||||||
let th = theme::get();
|
let th = theme::get();
|
||||||
let area = f.area();
|
let area = f.area();
|
||||||
f.render_widget(Block::default().style(Style::default().bg(th.bg0).fg(th.fg1)), area);
|
f.render_widget(Block::default().style(Style::default().bg(th.bg0).fg(th.fg1)), area);
|
||||||
let input_h = (self.editor.lines.len() as u16).clamp(1, 8) + 2;
|
// The input wraps at the width of the field (one column stays free for the cursor).
|
||||||
|
let wrap_w = (area.width.saturating_sub(3) as usize).max(1);
|
||||||
|
let layout = self.editor.layout(wrap_w);
|
||||||
|
let input_h = (layout.len() as u16).clamp(1, 8) + 2;
|
||||||
|
// Messages that wait for the agent are shown above the input.
|
||||||
|
let queued: Vec<String> = if self.remote.is_some() { self.remote_queue.clone() } else { self.queue.iter().cloned().collect() };
|
||||||
|
let mut queue_lines: Vec<Line> = Vec::new();
|
||||||
|
if !queued.is_empty() {
|
||||||
|
let w = (area.width as usize).saturating_sub(6).max(10);
|
||||||
|
let mut more = 0;
|
||||||
|
for (n, msg) in queued.iter().enumerate() {
|
||||||
|
let rows = wrap(msg, w);
|
||||||
|
if queue_lines.len() + rows.len() > 5 {
|
||||||
|
more = queued.len() - n;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
for (r, row) in rows.into_iter().enumerate() {
|
||||||
|
queue_lines.push(Line::from(vec![Span::styled(if r == 0 { " ↳ " } else { " " }, Style::default().fg(th.accent2)), Span::styled(row, Style::default().fg(th.fg2))]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if more > 0 {
|
||||||
|
queue_lines.push(Line::from(Span::styled(format!(" … +{more}"), Style::default().fg(th.muted))));
|
||||||
|
}
|
||||||
|
if self.busy {
|
||||||
|
queue_lines.push(Line::from(Span::styled(format!(" {}", t("force_hint")), Style::default().fg(th.muted))));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let queue_h = queue_lines.len() as u16;
|
||||||
let todo_items: Vec<&Value> = self.todos.as_array().map(|a| a.iter().collect()).unwrap_or_default();
|
let todo_items: Vec<&Value> = self.todos.as_array().map(|a| a.iter().collect()).unwrap_or_default();
|
||||||
let todo_h = if todo_items.iter().any(|t| t["status"] != "completed") { (todo_items.len() as u16).min(6) } else { 0 };
|
let todo_h = if todo_items.iter().any(|t| t["status"] != "completed") { (todo_items.len() as u16).min(6) } else { 0 };
|
||||||
let [head, hist, todos, act, input, status] = Layout::vertical([Constraint::Length(1), Constraint::Min(3), Constraint::Length(todo_h), Constraint::Length(1), Constraint::Length(input_h), Constraint::Length(1)]).areas(area);
|
let [head, hist, todos, act, queue_area, input, status] = Layout::vertical([Constraint::Length(1), Constraint::Min(3), Constraint::Length(todo_h), Constraint::Length(1), Constraint::Length(queue_h), Constraint::Length(input_h), Constraint::Length(1)]).areas(area);
|
||||||
|
|
||||||
// Header.
|
// Header.
|
||||||
let cwd = self.session.cwd.replace(&crate::conf::home().display().to_string(), "~");
|
let cwd = self.session.cwd.replace(&crate::conf::home().display().to_string(), "~");
|
||||||
@@ -1769,12 +1863,15 @@ impl App {
|
|||||||
Span::styled(format!(" {} ", SPINNER[self.tick % SPINNER.len()]), Style::default().fg(th.accent2)),
|
Span::styled(format!(" {} ", SPINNER[self.tick % SPINNER.len()]), Style::default().fg(th.accent2)),
|
||||||
Span::styled(format!("{}…", t("working")), Style::default().fg(th.accent2)),
|
Span::styled(format!("{}…", t("working")), Style::default().fg(th.accent2)),
|
||||||
Span::styled(format!(" ({secs}s · ~{} tokens) · {}", self.step_chars / 4, t("interrupt")), Style::default().fg(th.muted)),
|
Span::styled(format!(" ({secs}s · ~{} tokens) · {}", self.step_chars / 4, t("interrupt")), Style::default().fg(th.muted)),
|
||||||
Span::styled(if self.queue.is_empty() { String::new() } else { format!(" · {} {}", self.queue.len(), t("queued")) }, Style::default().fg(th.muted)),
|
Span::styled({ let n = if self.remote.is_some() { self.remote_queue.len() } else { self.queue.len() }; if n == 0 { String::new() } else { format!(" · {} {}", n, t("queued")) } }, Style::default().fg(th.muted)),
|
||||||
])
|
])
|
||||||
} else {
|
} else {
|
||||||
Line::from(Span::styled(format!(" {}", self.status), Style::default().fg(th.muted)))
|
Line::from(Span::styled(format!(" {}", self.status), Style::default().fg(th.muted)))
|
||||||
};
|
};
|
||||||
f.render_widget(Paragraph::new(activity), act);
|
f.render_widget(Paragraph::new(activity), act);
|
||||||
|
if queue_h > 0 {
|
||||||
|
f.render_widget(Paragraph::new(queue_lines), queue_area);
|
||||||
|
}
|
||||||
|
|
||||||
// Input.
|
// Input.
|
||||||
let mode_col = match self.session.mode.as_str() {
|
let mode_col = match self.session.mode.as_str() {
|
||||||
@@ -1793,16 +1890,17 @@ impl App {
|
|||||||
let inner = block.inner(input);
|
let inner = block.inner(input);
|
||||||
f.render_widget(block, input);
|
f.render_widget(block, input);
|
||||||
let visible = inner.height as usize;
|
let visible = inner.height as usize;
|
||||||
let first = self.editor.row.saturating_sub(visible.saturating_sub(1));
|
let (crow, ccol) = self.editor.cursor_in(&layout);
|
||||||
let text: Vec<Line> = if self.editor.is_empty() {
|
let first = crow.saturating_sub(visible.saturating_sub(1));
|
||||||
vec![Line::from(Span::styled(if self.busy { t("busy_placeholder") } else { t("placeholder") }, Style::default().fg(th.muted)))]
|
if self.editor.is_empty() {
|
||||||
|
let hint = Line::from(Span::styled(if self.busy { t("busy_placeholder") } else { t("placeholder") }, Style::default().fg(th.muted)));
|
||||||
|
f.render_widget(Paragraph::new(hint).wrap(Wrap { trim: false }), inner);
|
||||||
} else {
|
} else {
|
||||||
self.editor.lines[first..].iter().take(visible).map(|l| Line::from(Span::styled(l.clone(), Style::default().fg(th.fg0)))).collect()
|
let text: Vec<Line> = layout[first..].iter().take(visible).map(|r| Line::from(Span::styled(self.editor.row_text(*r), Style::default().fg(th.fg0)))).collect();
|
||||||
};
|
f.render_widget(Paragraph::new(text), inner);
|
||||||
let scroll_x = self.editor.cursor_x().saturating_sub(inner.width.saturating_sub(1) as usize) as u16;
|
}
|
||||||
f.render_widget(Paragraph::new(text).scroll((0, scroll_x)), inner);
|
|
||||||
if matches!(self.dialog, Dialog::None) {
|
if matches!(self.dialog, Dialog::None) {
|
||||||
f.set_cursor_position((inner.x + self.editor.cursor_x() as u16 - scroll_x, inner.y + (self.editor.row - first) as u16));
|
f.set_cursor_position((inner.x + (ccol as u16).min(inner.width.saturating_sub(1)), inner.y + (crow - first) as u16));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Status line.
|
// Status line.
|
||||||
@@ -1882,14 +1980,39 @@ impl App {
|
|||||||
}
|
}
|
||||||
Dialog::Question { questions, idx, sel, custom, .. } => {
|
Dialog::Question { questions, idx, sel, custom, .. } => {
|
||||||
let q = &questions[*idx];
|
let q = &questions[*idx];
|
||||||
let mut lines = vec![Line::from(Span::styled(q.question.clone(), Style::default().fg(th.fg0).add_modifier(Modifier::BOLD))), Line::default()];
|
// Everything wraps at the width of the box (it is 90 columns wide, less on small terminals).
|
||||||
|
let w = (90.min(area.width.saturating_sub(4)) as usize).saturating_sub(2).max(10);
|
||||||
|
let mut lines: Vec<Line> = wrap(&q.question, w).into_iter().map(|l| Line::from(Span::styled(l, Style::default().fg(th.fg0).add_modifier(Modifier::BOLD)))).collect();
|
||||||
|
lines.push(Line::default());
|
||||||
for (i, o) in q.options.iter().enumerate() {
|
for (i, o) in q.options.iter().enumerate() {
|
||||||
let st = if i == *sel && custom.is_empty() { Style::default().fg(th.on_accent).bg(th.accent) } else { Style::default().fg(th.fg1) };
|
let on = i == *sel && custom.is_empty();
|
||||||
lines.push(Line::from(vec![Span::styled(format!(" {}. {} ", i + 1, o.label), st), Span::styled(format!(" {}", o.description), Style::default().fg(th.muted))]));
|
let prefix = format!(" {}. {} ", i + 1, o.label);
|
||||||
|
let full = if o.description.is_empty() { prefix.clone() } else { format!("{prefix} {}", o.description) };
|
||||||
|
for (r, row) in wrap(&full, w.saturating_sub(4)).into_iter().enumerate() {
|
||||||
|
let row = if r == 0 { row } else { format!(" {row}") };
|
||||||
|
if on {
|
||||||
|
lines.push(Line::from(Span::styled(row, Style::default().fg(th.on_accent).bg(th.accent))));
|
||||||
|
} else if r == 0 {
|
||||||
|
let cut = row.char_indices().nth(prefix.chars().count()).map(|(b, _)| b).unwrap_or(row.len());
|
||||||
|
lines.push(Line::from(vec![Span::styled(row[..cut].to_string(), Style::default().fg(th.fg1)), Span::styled(row[cut..].to_string(), Style::default().fg(th.muted))]));
|
||||||
|
} else {
|
||||||
|
lines.push(Line::from(Span::styled(row, Style::default().fg(th.muted))));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
lines.push(Line::default());
|
lines.push(Line::default());
|
||||||
lines.push(Line::from(Span::styled(format!("> {custom}_"), Style::default().fg(th.fg0))));
|
// The own answer: wrapped as typed; only its last rows are shown when it gets long.
|
||||||
lines.push(Line::from(Span::styled(t("question_keys"), Style::default().fg(th.muted))));
|
let typed = hard_wrap(&format!("> {custom}_"), w);
|
||||||
|
let skip = typed.len().saturating_sub(6);
|
||||||
|
if skip > 0 {
|
||||||
|
lines.push(Line::from(Span::styled(" …", Style::default().fg(th.muted))));
|
||||||
|
}
|
||||||
|
for row in typed.into_iter().skip(skip) {
|
||||||
|
lines.push(Line::from(Span::styled(row, Style::default().fg(th.fg0))));
|
||||||
|
}
|
||||||
|
for row in wrap(t("question_keys"), w) {
|
||||||
|
lines.push(Line::from(Span::styled(row, Style::default().fg(th.muted))));
|
||||||
|
}
|
||||||
let title = format!("{} {}/{}", t("question"), idx + 1, questions.len());
|
let title = format!("{} {}/{}", t("question"), idx + 1, questions.len());
|
||||||
let inner = boxed(f, &title, 90, lines.len() as u16 + 2, th.blue);
|
let inner = boxed(f, &title, 90, lines.len() as u16 + 2, th.blue);
|
||||||
f.render_widget(Paragraph::new(lines), inner);
|
f.render_widget(Paragraph::new(lines), inner);
|
||||||
@@ -2044,3 +2167,89 @@ impl App {
|
|||||||
self.status = s;
|
self.status = s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod wrap_tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn hard_wrap_keeps_every_character() {
|
||||||
|
let rows = hard_wrap("abc def ghi", 5);
|
||||||
|
assert_eq!(rows.join(""), "abc def ghi");
|
||||||
|
assert!(rows.iter().all(|r| UnicodeWidthStr::width(r.as_str()) <= 5));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn hard_wrap_counts_wide_characters() {
|
||||||
|
let rows = hard_wrap("日本語日本語", 4);
|
||||||
|
assert_eq!(rows, vec!["日本", "語日", "本語"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod render_tests {
|
||||||
|
use super::*;
|
||||||
|
use crate::agent::Env;
|
||||||
|
use ratatui::Terminal;
|
||||||
|
use ratatui::backend::TestBackend;
|
||||||
|
|
||||||
|
fn app() -> App {
|
||||||
|
let cfg: crate::conf::Config = serde_json::from_str("{}").expect("empty config");
|
||||||
|
let env = Env {
|
||||||
|
cfg,
|
||||||
|
server: None,
|
||||||
|
server_cfg: None,
|
||||||
|
catalog: Default::default(),
|
||||||
|
modes: crate::agent::builtin_modes(),
|
||||||
|
permissions: Default::default(),
|
||||||
|
base_prompt: String::new(),
|
||||||
|
auto_prompt: String::new(),
|
||||||
|
remote_tools: Vec::new(),
|
||||||
|
server_skills: Vec::new(),
|
||||||
|
memory: String::new(),
|
||||||
|
};
|
||||||
|
let session = LocalSession { id: "t".into(), title: String::new(), cwd: "/tmp".into(), model: String::new(), mode: "build".into(), permission_mode: "default".into(), created_at: 0, updated_at: 0, messages: Vec::new(), usage: Default::default(), cost: 0.0, todos: Value::Null, context_tokens: 0 };
|
||||||
|
let (tx, _rx) = mpsc::unbounded_channel();
|
||||||
|
App::new(Arc::new(env), session, tx)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn screen(app: &mut App, w: u16, h: u16) -> String {
|
||||||
|
let mut term = Terminal::new(TestBackend::new(w, h)).unwrap();
|
||||||
|
term.draw(|f| app.draw(f)).unwrap();
|
||||||
|
let buf = term.backend().buffer().clone();
|
||||||
|
(0..h).map(|y| (0..w).map(|x| buf[(x, y)].symbol().to_string()).collect::<String>()).collect::<Vec<_>>().join("\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn queued_messages_show_above_the_input_and_wrap() {
|
||||||
|
let mut a = app();
|
||||||
|
a.busy = true;
|
||||||
|
a.queue.push_back("Das ist eine lange wartende Nachricht, die ueber mehrere Zeilen umbrechen muss weil sie so lang ist".into());
|
||||||
|
a.queue.push_back("zweite".into());
|
||||||
|
let s = screen(&mut a, 50, 20);
|
||||||
|
assert!(s.contains("↳ Das ist eine lange"), "{s}");
|
||||||
|
assert!(s.contains("↳ zweite"), "{s}");
|
||||||
|
assert!(s.contains("sofort zustellen") || s.contains("deliver now"), "{s}");
|
||||||
|
let q = s.lines().position(|l| l.contains("↳ Das")).unwrap();
|
||||||
|
let input = s.lines().position(|l| l.contains('╭') && l.contains("build")).unwrap();
|
||||||
|
assert!(q < input, "the queue is above the input\n{s}");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn long_question_and_options_wrap_instead_of_being_cut() {
|
||||||
|
let mut a = app();
|
||||||
|
let (tx, _rx) = oneshot::channel();
|
||||||
|
a.dialog = Dialog::Question {
|
||||||
|
questions: vec![Question { question: "Soll der Builder das Limit auf sechs Mebibyte anheben oder lieber einzelne Grammatiken weglassen, obwohl die Spec das verbietet?".into(), header: String::new(), options: vec![codecraft_core::types::QuestionOption { label: "Limit anheben".into(), description: "Das Archiv bleibt vollstaendig und waechst auf knapp fuenf Mebibyte an".into() }], multi_select: false }],
|
||||||
|
idx: 0,
|
||||||
|
sel: 0,
|
||||||
|
custom: "eine sehr lange eigene Antwort die in dem Feld nicht mehr in eine Zeile passt und deshalb umbrechen muss".into(),
|
||||||
|
answers: Default::default(),
|
||||||
|
reply: Some(tx),
|
||||||
|
};
|
||||||
|
let s = screen(&mut a, 60, 30);
|
||||||
|
for part in ["Mebibyte anheben", "weglassen", "knapp", "Antwort", "umbrechen muss"] {
|
||||||
|
assert!(s.contains(part), "missing {part}\n{s}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+99
-5
@@ -1,6 +1,6 @@
|
|||||||
//! Multi-line input field with history.
|
//! Multi-line input field with history.
|
||||||
|
|
||||||
use unicode_width::UnicodeWidthStr;
|
use unicode_width::UnicodeWidthChar;
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Editor {
|
pub struct Editor {
|
||||||
@@ -211,9 +211,103 @@ impl Editor {
|
|||||||
self.col = start + with.chars().count();
|
self.col = start + with.chars().count();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Cursor position in display columns (for the terminal cursor).
|
/// The text as it is shown at `width` columns: every logical line is broken into rows, preferably after a
|
||||||
pub fn cursor_x(&self) -> usize {
|
/// space, otherwise inside a long word. Each row is (line index, first char, end char).
|
||||||
let line = &self.lines[self.row];
|
pub fn layout(&self, width: usize) -> Vec<(usize, usize, usize)> {
|
||||||
UnicodeWidthStr::width(&line[..byte_idx(line, self.col)])
|
let width = width.max(1);
|
||||||
|
let mut rows = Vec::new();
|
||||||
|
for (i, line) in self.lines.iter().enumerate() {
|
||||||
|
let chars: Vec<char> = line.chars().collect();
|
||||||
|
if chars.is_empty() {
|
||||||
|
rows.push((i, 0, 0));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
let mut start = 0;
|
||||||
|
while start < chars.len() {
|
||||||
|
let mut w = 0;
|
||||||
|
let mut end = start;
|
||||||
|
let mut last_space = None;
|
||||||
|
while end < chars.len() {
|
||||||
|
let cw = UnicodeWidthChar::width(chars[end]).unwrap_or(0);
|
||||||
|
if w + cw > width && end > start {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
w += cw;
|
||||||
|
end += 1;
|
||||||
|
if chars[end - 1] == ' ' {
|
||||||
|
last_space = Some(end);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if end < chars.len() {
|
||||||
|
if let Some(sp) = last_space.filter(|sp| *sp > start) {
|
||||||
|
end = sp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rows.push((i, start, end));
|
||||||
|
start = end;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rows
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The text of one row of `layout`.
|
||||||
|
pub fn row_text(&self, (line, a, b): (usize, usize, usize)) -> String {
|
||||||
|
self.lines[line].chars().skip(a).take(b - a).collect()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Cursor in the wrapped view: (row index in `layout`, display column).
|
||||||
|
pub fn cursor_in(&self, layout: &[(usize, usize, usize)]) -> (usize, usize) {
|
||||||
|
for (n, &(line, a, b)) in layout.iter().enumerate() {
|
||||||
|
let last = layout.get(n + 1).is_none_or(|next| next.0 != line);
|
||||||
|
if line == self.row && self.col >= a && (self.col < b || (last && self.col <= b)) {
|
||||||
|
let w: usize = self.lines[line].chars().skip(a).take(self.col - a).map(|c| UnicodeWidthChar::width(c).unwrap_or(0)).sum();
|
||||||
|
return (n, w);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
(layout.len().saturating_sub(1), 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
fn editor(text: &str) -> Editor {
|
||||||
|
let mut e = Editor { lines: vec![String::new()], ..Default::default() };
|
||||||
|
e.set(text);
|
||||||
|
e
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn long_line_wraps_at_spaces() {
|
||||||
|
let e = editor("aaa bbb ccc ddd");
|
||||||
|
let rows: Vec<String> = e.layout(8).into_iter().map(|r| e.row_text(r)).collect();
|
||||||
|
assert_eq!(rows, vec!["aaa bbb ", "ccc ddd"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn long_word_breaks_inside() {
|
||||||
|
let e = editor("abcdefghij");
|
||||||
|
let rows: Vec<String> = e.layout(4).into_iter().map(|r| e.row_text(r)).collect();
|
||||||
|
assert_eq!(rows, vec!["abcd", "efgh", "ij"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn empty_lines_keep_a_row_and_nothing_is_lost() {
|
||||||
|
let e = editor("one\n\ntwo words here");
|
||||||
|
let l = e.layout(6);
|
||||||
|
let joined: String = l.iter().map(|r| e.row_text(*r)).collect::<Vec<_>>().join("|");
|
||||||
|
assert_eq!(joined, "one||two |words |here");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn cursor_follows_the_wrap() {
|
||||||
|
let mut e = editor("aaa bbb ccc ddd");
|
||||||
|
let l = e.layout(8);
|
||||||
|
assert_eq!(e.cursor_in(&l), (1, 7)); // end of the text, second row
|
||||||
|
e.col = 8; // before "ccc"
|
||||||
|
assert_eq!(e.cursor_in(&l), (1, 0));
|
||||||
|
e.col = 3;
|
||||||
|
assert_eq!(e.cursor_in(&l), (0, 3));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+3
-1
@@ -14,7 +14,7 @@ pub fn system_lang() -> String {
|
|||||||
|
|
||||||
/// (key, English, German)
|
/// (key, English, German)
|
||||||
const TEXTS: &[(&str, &str, &str)] = &[
|
const TEXTS: &[(&str, &str, &str)] = &[
|
||||||
("placeholder", "Message… (/ commands, @ files, Shift+Enter new line)", "Nachricht… (/ Befehle, @ Dateien, Shift+Enter neue Zeile)"),
|
("placeholder", "Message… (/ commands, @ files, Shift+Enter or Ctrl+J new line)", "Nachricht… (/ Befehle, @ Dateien, Shift+Enter oder Strg+J neue Zeile)"),
|
||||||
("busy_placeholder", "Message is queued and sent after this turn…", "Nachricht wird nach diesem Schritt gesendet…"),
|
("busy_placeholder", "Message is queued and sent after this turn…", "Nachricht wird nach diesem Schritt gesendet…"),
|
||||||
("permission", "Permission required", "Freigabe erforderlich"),
|
("permission", "Permission required", "Freigabe erforderlich"),
|
||||||
("perm_keys", "[y] allow once [a] always in this session [n] reject [f] reject with feedback", "[y] einmal erlauben [a] immer in dieser Session [n] ablehnen [f] ablehnen mit Hinweis"),
|
("perm_keys", "[y] allow once [a] always in this session [n] reject [f] reject with feedback", "[y] einmal erlauben [a] immer in dieser Session [n] ablehnen [f] ablehnen mit Hinweis"),
|
||||||
@@ -36,6 +36,8 @@ const TEXTS: &[(&str, &str, &str)] = &[
|
|||||||
("choose_theme", "Choose a theme", "Theme wählen"),
|
("choose_theme", "Choose a theme", "Theme wählen"),
|
||||||
("filter", "type to filter", "tippen zum Filtern"),
|
("filter", "type to filter", "tippen zum Filtern"),
|
||||||
("queued", "queued", "in der Warteschlange"),
|
("queued", "queued", "in der Warteschlange"),
|
||||||
|
("force_hint", "Enter on the empty field: deliver now (interrupts the running step)", "Enter im leeren Feld: sofort zustellen (unterbricht den laufenden Schritt)"),
|
||||||
|
("forcing", "interrupting – the queued message is sent now", "unterbreche – die Nachricht wird jetzt gesendet"),
|
||||||
("welcome", "Welcome to CodeCraft", "Willkommen bei CodeCraft"),
|
("welcome", "Welcome to CodeCraft", "Willkommen bei CodeCraft"),
|
||||||
("setup_title", "Set up CodeCraft", "CodeCraft einrichten"),
|
("setup_title", "Set up CodeCraft", "CodeCraft einrichten"),
|
||||||
("setup_intro", "Where should the models come from? You can add more later with /setup.", "Woher sollen die Modelle kommen? Weitere kannst du später mit /setup hinzufügen."),
|
("setup_intro", "Where should the models come from? You can add more later with /setup.", "Woher sollen die Modelle kommen? Weitere kannst du später mit /setup hinzufügen."),
|
||||||
|
|||||||
+17
-1
@@ -32,6 +32,8 @@ pub struct Snapshot {
|
|||||||
pub todos: Value,
|
pub todos: Value,
|
||||||
/// Open permission and question requests of this chat (and its subagents).
|
/// Open permission and question requests of this chat (and its subagents).
|
||||||
pub pending: Vec<Value>,
|
pub pending: Vec<Value>,
|
||||||
|
/// Messages waiting for the agent (text of each).
|
||||||
|
pub queue: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn short(s: &str, n: usize) -> String {
|
fn short(s: &str, n: usize) -> String {
|
||||||
@@ -80,7 +82,16 @@ pub async fn snapshot(server: &Server, id: &str) -> Result<Snapshot> {
|
|||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|e| e["session_id"].as_str() == Some(id) || e["root_session_id"].as_str() == Some(id))
|
.filter(|e| e["session_id"].as_str() == Some(id) || e["root_session_id"].as_str() == Some(id))
|
||||||
.collect();
|
.collect();
|
||||||
Ok(Snapshot { messages, busy: s["busy"].as_bool().unwrap_or(false), title: s["session"]["title"].as_str().unwrap_or("").to_string(), todos: s["session"]["todos"].clone(), pending })
|
let queue = s["queue"]
|
||||||
|
.as_array()
|
||||||
|
.map(|a| {
|
||||||
|
a.iter()
|
||||||
|
.filter(|i| i["source"].as_str() != Some("background"))
|
||||||
|
.map(|i| i["parts"].as_array().map(|p| p.iter().filter_map(|x| x["text"].as_str()).collect::<Vec<_>>().join(" ")).unwrap_or_default())
|
||||||
|
.collect()
|
||||||
|
})
|
||||||
|
.unwrap_or_default();
|
||||||
|
Ok(Snapshot { messages, busy: s["busy"].as_bool().unwrap_or(false), title: s["session"]["title"].as_str().unwrap_or("").to_string(), todos: s["session"]["todos"].clone(), pending, queue })
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn open(server: &Server, id: &str) -> Result<Remote> {
|
pub async fn open(server: &Server, id: &str) -> Result<Remote> {
|
||||||
@@ -118,6 +129,11 @@ pub async fn abort(server: &Server, id: &str) -> Result<()> {
|
|||||||
server.post(&format!("/sessions/{id}/abort"), json!({})).await.map(|_| ())
|
server.post(&format!("/sessions/{id}/abort"), json!({})).await.map(|_| ())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Interrupt the running step and deliver the queued messages at once.
|
||||||
|
pub async fn force_queue(server: &Server, id: &str) -> Result<()> {
|
||||||
|
server.post(&format!("/sessions/{id}/queue/force"), json!({})).await.map(|_| ())
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn compact(server: &Server, id: &str) -> Result<()> {
|
pub async fn compact(server: &Server, id: &str) -> Result<()> {
|
||||||
server.post(&format!("/sessions/{id}/compact"), json!({})).await.map(|_| ())
|
server.post(&format!("/sessions/{id}/compact"), json!({})).await.map(|_| ())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,6 +113,7 @@ pub fn router(app: AppState) -> Router {
|
|||||||
.route("/sessions/{id}/shares", get(get_shares).put(put_shares))
|
.route("/sessions/{id}/shares", get(get_shares).put(put_shares))
|
||||||
.route("/sessions/{id}/queue", get(get_queue))
|
.route("/sessions/{id}/queue", get(get_queue))
|
||||||
.route("/sessions/{id}/queue/flush", post(flush_queue))
|
.route("/sessions/{id}/queue/flush", post(flush_queue))
|
||||||
|
.route("/sessions/{id}/queue/force", post(force_queue))
|
||||||
.route("/sessions/{id}/queue/{item}", delete(delete_queue_item))
|
.route("/sessions/{id}/queue/{item}", delete(delete_queue_item))
|
||||||
.route("/permissions/{id}", post(reply_permission))
|
.route("/permissions/{id}", post(reply_permission))
|
||||||
.route("/permissions/{id}/explain", post(explain_permission))
|
.route("/permissions/{id}/explain", post(explain_permission))
|
||||||
@@ -1359,6 +1360,12 @@ async fn flush_queue(Extension(user): Extension<User>, State(app): State<AppStat
|
|||||||
Ok(Json(json!({"started": runner::flush_queue(app.clone(), &id)?})))
|
Ok(Json(json!({"started": runner::flush_queue(app.clone(), &id)?})))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Interrupt the running step and deliver the queued messages at once.
|
||||||
|
async fn force_queue(Extension(user): Extension<User>, State(app): State<AppState>, Path(id): Path<String>) -> ApiResult {
|
||||||
|
writable(&app, &user, &id)?;
|
||||||
|
Ok(Json(json!({"forced": runner::force_queue(app.clone(), &id)?})))
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) async fn do_compact(app: AppState, id: String) {
|
pub(crate) async fn do_compact(app: AppState, id: String) {
|
||||||
let cancel = tokio_util::sync::CancellationToken::new();
|
let cancel = tokio_util::sync::CancellationToken::new();
|
||||||
app.with_runtime(&id, |r| r.cancel = Some(cancel.clone()));
|
app.with_runtime(&id, |r| r.cancel = Some(cancel.clone()));
|
||||||
|
|||||||
@@ -45,6 +45,9 @@ pub struct Runtime {
|
|||||||
pub step: Option<Value>,
|
pub step: Option<Value>,
|
||||||
/// Reasoning effort chosen for the current turn (overrides the model's default).
|
/// Reasoning effort chosen for the current turn (overrides the model's default).
|
||||||
pub effort: Option<String>,
|
pub effort: Option<String>,
|
||||||
|
/// The user interrupted the turn to deliver the queued messages at once: they start the next turn
|
||||||
|
/// even though the run was cancelled.
|
||||||
|
pub force_queue: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct App {
|
pub struct App {
|
||||||
|
|||||||
+21
-1
@@ -112,7 +112,8 @@ pub fn submit(app: Arc<App>, session_id: String, parts: Vec<Part>, source: &str)
|
|||||||
let leftover = app.with_runtime(&session_id, |r| {
|
let leftover = app.with_runtime(&session_id, |r| {
|
||||||
r.cancel = None;
|
r.cancel = None;
|
||||||
r.effort = None;
|
r.effort = None;
|
||||||
if cancel.is_cancelled() { Vec::new() } else { take_queue(&app, &session_id) }
|
let forced = std::mem::take(&mut r.force_queue);
|
||||||
|
if cancel.is_cancelled() && !forced { Vec::new() } else { take_queue(&app, &session_id) }
|
||||||
});
|
});
|
||||||
app.emit(Event::SessionStatus { session_id: session_id.clone(), busy: false });
|
app.emit(Event::SessionStatus { session_id: session_id.clone(), busy: false });
|
||||||
if leftover.is_empty() && !cancel.is_cancelled() {
|
if leftover.is_empty() && !cancel.is_cancelled() {
|
||||||
@@ -139,6 +140,25 @@ pub fn flush_queue(app: Arc<App>, session_id: &str) -> Result<bool> {
|
|||||||
Ok(true)
|
Ok(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Deliver the queued messages now: the running step is interrupted and the messages start the next turn
|
||||||
|
/// at once (instead of waiting for the agent's next step). Without a running turn this is `flush_queue`.
|
||||||
|
/// Returns false when nothing is queued.
|
||||||
|
pub fn force_queue(app: Arc<App>, session_id: &str) -> Result<bool> {
|
||||||
|
if app.store.queue_list(session_id).unwrap_or_default().is_empty() {
|
||||||
|
return Ok(false);
|
||||||
|
}
|
||||||
|
if !app.is_busy(session_id) {
|
||||||
|
return flush_queue(app, session_id);
|
||||||
|
}
|
||||||
|
app.with_runtime(session_id, |r| {
|
||||||
|
if let Some(c) = &r.cancel {
|
||||||
|
r.force_queue = true;
|
||||||
|
c.cancel();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Ok(true)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn abort(app: &App, session_id: &str) {
|
pub fn abort(app: &App, session_id: &str) {
|
||||||
app.with_runtime(session_id, |r| {
|
app.with_runtime(session_id, |r| {
|
||||||
if let Some(c) = &r.cancel {
|
if let Some(c) = &r.cancel {
|
||||||
|
|||||||
Generated
+976
-1
File diff suppressed because it is too large.
Load diff
@@ -21,6 +21,7 @@
|
|||||||
"@xterm/addon-fit": "^0.11.0",
|
"@xterm/addon-fit": "^0.11.0",
|
||||||
"@xterm/addon-web-links": "^0.12.0",
|
"@xterm/addon-web-links": "^0.12.0",
|
||||||
"@xterm/xterm": "^6.0.0",
|
"@xterm/xterm": "^6.0.0",
|
||||||
|
"antd": "^6.7.2",
|
||||||
"codemirror": "^6.0.2",
|
"codemirror": "^6.0.2",
|
||||||
"occt-import-js": "^0.0.23",
|
"occt-import-js": "^0.0.23",
|
||||||
"react": "^19.3.1",
|
"react": "^19.3.1",
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { Button, Checkbox, Input } from "antd";
|
||||||
|
import { Modal } from "../ui/Modal";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { patch } from "../api";
|
import { patch } from "../api";
|
||||||
import { toast } from "../dialogs";
|
import { toast } from "../dialogs";
|
||||||
@@ -38,8 +40,7 @@ export function ChatSkillsDialog({ sessionId, cwd, active, onClose }: { sessionI
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="modal-backdrop" onClick={onClose}>
|
<Modal onClose={onClose} className="draft-modal" role="dialog" aria-label={t("skills.chatTitle")}>
|
||||||
<div className="modal draft-modal" role="dialog" aria-label={t("skills.chatTitle")} onClick={(e) => e.stopPropagation()}>
|
|
||||||
<h3>{t("skills.chatTitle")}</h3>
|
<h3>{t("skills.chatTitle")}</h3>
|
||||||
<div className="hint" style={{ marginBottom: 8 }}>
|
<div className="hint" style={{ marginBottom: 8 }}>
|
||||||
{t("skills.chatHint")}
|
{t("skills.chatHint")}
|
||||||
@@ -50,31 +51,29 @@ export function ChatSkillsDialog({ sessionId, cwd, active, onClose }: { sessionI
|
|||||||
<div className="empty">{t("skills.empty")}</div>
|
<div className="empty">{t("skills.empty")}</div>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
{all.length > 6 && <input autoFocus style={{ width: "100%" }} placeholder={t("skills.filter")} value={filter} onChange={(e) => setFilter(e.target.value)} />}
|
{all.length > 6 && <Input autoFocus style={{ width: "100%" }} placeholder={t("skills.filter")} value={filter} onChange={(e) => setFilter(e.target.value)} />}
|
||||||
<div className="issue-list">
|
<div className="issue-list">
|
||||||
{shown.map((s) => (
|
{shown.map((s) => (
|
||||||
<label key={s.name} className="row" style={{ gap: 8, alignItems: "flex-start", padding: "2px 0" }}>
|
<Checkbox key={s.name} className="row" style={{ gap: 8, alignItems: "flex-start", padding: "2px 0" }} checked={picked.includes(s.name)} onChange={() => toggle(s.name)}>
|
||||||
<input type="checkbox" checked={picked.includes(s.name)} onChange={() => toggle(s.name)} />
|
|
||||||
<span>
|
<span>
|
||||||
<code>{s.name}</code>
|
<code>{s.name}</code>
|
||||||
{s.files.length > 0 && <span className="hint"> · {t("skills.files", { n: s.files.length })}</span>}
|
{s.files.length > 0 && <span className="hint"> · {t("skills.files", { n: s.files.length })}</span>}
|
||||||
<div className="hint">{s.description}</div>
|
<div className="hint">{s.description}</div>
|
||||||
</span>
|
</span>
|
||||||
</label>
|
</Checkbox>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
{picked.length > 4 && <div className="notice">{t("skills.manyActive")}</div>}
|
{picked.length > 4 && <div className="notice">{t("skills.manyActive")}</div>}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<div className="row" style={{ marginTop: 10, justifyContent: "flex-end", gap: 6 }}>
|
<div className="row" style={{ marginTop: 10, justifyContent: "flex-end", gap: 6 }}>
|
||||||
<button onClick={onClose} disabled={busy}>
|
<Button onClick={onClose} disabled={busy}>
|
||||||
{t("common.cancel")}
|
{t("common.cancel")}
|
||||||
</button>
|
</Button>
|
||||||
<button className="primary" onClick={() => void save()} disabled={busy}>
|
<Button type="primary" onClick={() => void save()} disabled={busy}>
|
||||||
{busy ? <Spinner small /> : <Icon name="check" />} {t("common.save")}
|
{busy ? <Spinner small /> : <Icon name="check" />} {t("common.save")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
</Modal>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { Button } from "antd";
|
||||||
import { lazy, Suspense, useCallback, useEffect, useRef, useState } from "react";
|
import { lazy, Suspense, useCallback, useEffect, useRef, useState } from "react";
|
||||||
import { del, get, post, put } from "../api";
|
import { del, get, post, put } from "../api";
|
||||||
import { confirmDialog, toast } from "../dialogs";
|
import { confirmDialog, toast } from "../dialogs";
|
||||||
@@ -132,30 +133,30 @@ export function ChatTabBar({ state }: { state: Tabs }) {
|
|||||||
</button>
|
</button>
|
||||||
{terms.map((x, i) => (
|
{terms.map((x, i) => (
|
||||||
<span key={x.id} className={`chat-tab ${tab === x.id ? "active" : ""} ${x.alive ? "" : "dead"}`}>
|
<span key={x.id} className={`chat-tab ${tab === x.id ? "active" : ""} ${x.alive ? "" : "dead"}`}>
|
||||||
<button role="tab" aria-selected={tab === x.id} className="ghost" onClick={() => setTab(x.id)} title={x.cwd}>
|
<Button type="text" role="tab" aria-selected={tab === x.id} onClick={() => setTab(x.id)} title={x.cwd}>
|
||||||
<Icon name="terminal" /> {t("terminal.tab", { n: i + 1 })}
|
<Icon name="terminal" /> {t("terminal.tab", { n: i + 1 })}
|
||||||
</button>
|
</Button>
|
||||||
<button className="ghost close" onClick={() => void closeTerminal(x, i + 1)} aria-label={t("terminal.close")} title={t("terminal.close")}>
|
<Button type="text" className="close" onClick={() => void closeTerminal(x, i + 1)} aria-label={t("terminal.close")} title={t("terminal.close")}>
|
||||||
<Icon name="close" size={12} />
|
<Icon name="close" size={12} />
|
||||||
</button>
|
</Button>
|
||||||
</span>
|
</span>
|
||||||
))}
|
))}
|
||||||
{files.map((f) => (
|
{files.map((f) => (
|
||||||
<span key={f.id} className={`chat-tab ${tab === f.id ? "active" : ""}`}>
|
<span key={f.id} className={`chat-tab ${tab === f.id ? "active" : ""}`}>
|
||||||
<button role="tab" aria-selected={tab === f.id} className="ghost" onClick={() => setTab(f.id)} title={f.dir}>
|
<Button type="text" role="tab" aria-selected={tab === f.id} onClick={() => setTab(f.id)} title={f.dir}>
|
||||||
<Icon name="folder" /> {basename(f.dir)}
|
<Icon name="folder" /> {basename(f.dir)}
|
||||||
</button>
|
</Button>
|
||||||
<button className="ghost close" onClick={() => closeFiles(f.id)} aria-label={t("files.closeTab")} title={t("files.closeTab")}>
|
<Button type="text" className="close" onClick={() => closeFiles(f.id)} aria-label={t("files.closeTab")} title={t("files.closeTab")}>
|
||||||
<Icon name="close" size={12} />
|
<Icon name="close" size={12} />
|
||||||
</button>
|
</Button>
|
||||||
</span>
|
</span>
|
||||||
))}
|
))}
|
||||||
<button className="ghost chat-tab-add" onClick={() => void openTerminal()} title={t("terminal.new")} aria-label={t("terminal.new")}>
|
<Button type="text" className="chat-tab-add" onClick={() => void openTerminal()} title={t("terminal.new")} aria-label={t("terminal.new")}>
|
||||||
<Icon name="plus" /> <Icon name="terminal" />
|
<Icon name="plus" /> <Icon name="terminal" />
|
||||||
</button>
|
</Button>
|
||||||
<button className="ghost chat-tab-add" onClick={openFiles} title={t("files.newTab")} aria-label={t("files.newTab")}>
|
<Button type="text" className="chat-tab-add" onClick={openFiles} title={t("files.newTab")} aria-label={t("files.newTab")}>
|
||||||
<Icon name="plus" /> <Icon name="folder" />
|
<Icon name="plus" /> <Icon name="folder" />
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { Button, Input } from "antd";
|
||||||
import { DraftBar, IssueBar, isDraftChat, isIssueChat } from "./FactoryDraft";
|
import { DraftBar, IssueBar, isDraftChat, isIssueChat } from "./FactoryDraft";
|
||||||
import { takePrefill } from "../share";
|
import { takePrefill } from "../share";
|
||||||
import { Icon } from "./Icon";
|
import { Icon } from "./Icon";
|
||||||
@@ -201,21 +202,21 @@ function ChatSearch({ sessionId, onPick, onClose }: { sessionId: string; onPick:
|
|||||||
<div className="chat-search" role="search">
|
<div className="chat-search" role="search">
|
||||||
<div className="row">
|
<div className="row">
|
||||||
<Icon name="search" />
|
<Icon name="search" />
|
||||||
<input autoFocus value={q} placeholder={t("chat.searchPlaceholder")} onChange={(e) => setQ(e.target.value)} onKeyDown={(e) => e.key === "Escape" && onClose()} aria-label={t("chat.search")} />
|
<Input autoFocus value={q} placeholder={t("chat.searchPlaceholder")} onChange={(e) => setQ(e.target.value)} onKeyDown={(e) => e.key === "Escape" && onClose()} aria-label={t("chat.search")} />
|
||||||
<button className="small ghost" onClick={onClose} aria-label={t("common.close")}>
|
<Button type="text" size="small" onClick={onClose} aria-label={t("common.close")}>
|
||||||
<Icon name="close" />
|
<Icon name="close" />
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
{hits && (
|
{hits && (
|
||||||
<div className="chat-search-hits">
|
<div className="chat-search-hits">
|
||||||
<div className="hint">{hits.length ? t("chat.searchHits", { n: hits.length }) : t("chat.searchNone")}</div>
|
<div className="hint">{hits.length ? t("chat.searchHits", { n: hits.length }) : t("chat.searchNone")}</div>
|
||||||
{hits.map((h) => (
|
{hits.map((h) => (
|
||||||
<button key={h.id} onClick={() => onPick(h.id)}>
|
<Button key={h.id} onClick={() => onPick(h.id)}>
|
||||||
<span className="who">
|
<span className="who">
|
||||||
{t(h.role === "assistant" ? "chat.agent" : "chat.you")} · {new Date(h.created_at).toLocaleString(undefined, { dateStyle: "short", timeStyle: "short" })}
|
{t(h.role === "assistant" ? "chat.agent" : "chat.you")} · {new Date(h.created_at).toLocaleString(undefined, { dateStyle: "short", timeStyle: "short" })}
|
||||||
</span>
|
</span>
|
||||||
<span className="snippet">{h.snippet}</span>
|
<span className="snippet">{h.snippet}</span>
|
||||||
</button>
|
</Button>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
@@ -535,9 +536,9 @@ function OlderLoader({ sessionId, afterSummary, scrollRef }: { sessionId: string
|
|||||||
{loading ? (
|
{loading ? (
|
||||||
<Spinner small />
|
<Spinner small />
|
||||||
) : (
|
) : (
|
||||||
<button className="small ghost" onClick={() => void load()}>
|
<Button type="text" size="small" onClick={() => void load()}>
|
||||||
<Icon name="arrow-up" /> {t(afterSummary ? "chat.showBeforeSummary" : "chat.loadOlder")}
|
<Icon name="arrow-up" /> {t(afterSummary ? "chat.showBeforeSummary" : "chat.loadOlder")}
|
||||||
</button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -719,6 +720,9 @@ export function ChatView({ sessionId, onMenu, onClosePane }: { sessionId: string
|
|||||||
return () => ro.disconnect();
|
return () => ro.disconnect();
|
||||||
}, [hasSession, sessionId]);
|
}, [hasSession, sessionId]);
|
||||||
|
|
||||||
|
// Before the early returns: a chat that is deleted while open must render the same hooks.
|
||||||
|
const [rewinding, setRewinding] = useState<Message>();
|
||||||
|
|
||||||
if (loadError) return <div className="empty">{loadError}</div>;
|
if (loadError) return <div className="empty">{loadError}</div>;
|
||||||
if (!session) return <div className="empty">{t("common.loading")}</div>;
|
if (!session) return <div className="empty">{t("common.loading")}</div>;
|
||||||
|
|
||||||
@@ -762,7 +766,6 @@ export function ChatView({ sessionId, onMenu, onClosePane }: { sessionId: string
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const [rewinding, setRewinding] = useState<Message>();
|
|
||||||
const rewind = (m: Message) => setRewinding(m);
|
const rewind = (m: Message) => setRewinding(m);
|
||||||
rewindRef.current = rewind;
|
rewindRef.current = rewind;
|
||||||
const rewindDone = async () => {
|
const rewindDone = async () => {
|
||||||
@@ -834,9 +837,9 @@ export function ChatView({ sessionId, onMenu, onClosePane }: { sessionId: string
|
|||||||
return (
|
return (
|
||||||
<ChatCtx.Provider value={{ sessionId, canFork: !session.parent_id && !readOnly && !busy, canReply: !readOnly }}>
|
<ChatCtx.Provider value={{ sessionId, canFork: !session.parent_id && !readOnly && !busy, canReply: !readOnly }}>
|
||||||
<div className="topbar" data-color={session.color}>
|
<div className="topbar" data-color={session.color}>
|
||||||
<button className="ghost menu-btn" onClick={onMenu} aria-label={t("nav.menu")}>
|
<Button type="text" className="menu-btn" onClick={onMenu} aria-label={t("nav.menu")}>
|
||||||
<Icon name="menu" />
|
<Icon name="menu" />
|
||||||
</button>
|
</Button>
|
||||||
<div className="grow">
|
<div className="grow">
|
||||||
<h1 onDoubleClick={() => !readOnly && setEditingTitle(true)} title={readOnly ? undefined : t("chat.renameHint")}>
|
<h1 onDoubleClick={() => !readOnly && setEditingTitle(true)} title={readOnly ? undefined : t("chat.renameHint")}>
|
||||||
{session.parent_id && (
|
{session.parent_id && (
|
||||||
@@ -847,9 +850,9 @@ export function ChatView({ sessionId, onMenu, onClosePane }: { sessionId: string
|
|||||||
{session.icon && <Icon name={session.icon} className="chat-icon" />}
|
{session.icon && <Icon name={session.icon} className="chat-icon" />}
|
||||||
{session.title || t("session.untitled")}
|
{session.title || t("session.untitled")}
|
||||||
{!readOnly && (
|
{!readOnly && (
|
||||||
<button className="ghost small title-edit" onClick={() => setEditingTitle(true)} title={t("rename.title")} aria-label={t("rename.title")}>
|
<Button type="text" size="small" className="title-edit" onClick={() => setEditingTitle(true)} title={t("rename.title")} aria-label={t("rename.title")}>
|
||||||
<Icon name="edit" />
|
<Icon name="edit" />
|
||||||
</button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</h1>
|
</h1>
|
||||||
<div className="path">{session.cwd}</div>
|
<div className="path">{session.cwd}</div>
|
||||||
@@ -886,27 +889,27 @@ export function ChatView({ sessionId, onMenu, onClosePane }: { sessionId: string
|
|||||||
{!readOnly && (
|
{!readOnly && (
|
||||||
<>
|
<>
|
||||||
{!session.parent_id && (
|
{!session.parent_id && (
|
||||||
<button className="small ghost hide-mobile" onClick={() => setSharing(true)} title={t("share.title")}>
|
<Button type="text" size="small" className="hide-mobile" onClick={() => setSharing(true)} title={t("share.title")}>
|
||||||
<Icon name="share" />
|
<Icon name="share" />
|
||||||
</button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
<button
|
<Button type="text" size="small"
|
||||||
className="small ghost hide-mobile"
|
className="hide-mobile"
|
||||||
onClick={() => void tabs.openTerminal()}
|
onClick={() => void tabs.openTerminal()}
|
||||||
title={t("terminal.here")}
|
title={t("terminal.here")}
|
||||||
>
|
>
|
||||||
<Icon name="terminal" />
|
<Icon name="terminal" />
|
||||||
</button>
|
</Button>
|
||||||
<button className={`small ghost ${searching ? "active" : ""}`} onClick={() => setSearching(!searching)} title={t("chat.search")} aria-label={t("chat.search")}>
|
<Button type="text" size="small" className={searching ? "active" : ""} onClick={() => setSearching(!searching)} title={t("chat.search")} aria-label={t("chat.search")}>
|
||||||
<Icon name="search" />
|
<Icon name="search" />
|
||||||
</button>
|
</Button>
|
||||||
<button className="small ghost hide-mobile" onClick={tabs.openFiles} title={t("files.newTab")}>
|
<Button type="text" size="small" className="hide-mobile" onClick={tabs.openFiles} title={t("files.newTab")}>
|
||||||
<Icon name="folder" />
|
<Icon name="folder" />
|
||||||
</button>
|
</Button>
|
||||||
{!session.parent_id && (
|
{!session.parent_id && (
|
||||||
<button className="small ghost hide-mobile" onClick={forkSession} disabled={busy} title={t("chat.fork")}>
|
<Button type="text" size="small" className="hide-mobile" onClick={forkSession} disabled={busy} title={t("chat.fork")}>
|
||||||
<Icon name="fork" />
|
<Icon name="fork" />
|
||||||
</button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
<details className="menu-pop">
|
<details className="menu-pop">
|
||||||
<summary className="small ghost" title={t("chat.more")} aria-label={t("chat.more")}>
|
<summary className="small ghost" title={t("chat.more")} aria-label={t("chat.more")}>
|
||||||
@@ -1021,18 +1024,18 @@ export function ChatView({ sessionId, onMenu, onClosePane }: { sessionId: string
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</details>
|
</details>
|
||||||
<button className="small ghost hide-mobile" onClick={() => post(`/sessions/${sessionId}/compact`).catch((e) => toast(e.message))} disabled={busy} title={t("command.compact")}>
|
<Button type="text" size="small" className="hide-mobile" onClick={() => post(`/sessions/${sessionId}/compact`).catch((e) => toast(e.message))} disabled={busy} title={t("command.compact")}>
|
||||||
<Icon name="compact" />
|
<Icon name="compact" />
|
||||||
</button>
|
</Button>
|
||||||
<button className="small ghost danger hide-mobile" onClick={remove} title={t("chat.delete")}>
|
<Button type="text" danger size="small" className="hide-mobile" onClick={remove} title={t("chat.delete")}>
|
||||||
<Icon name="trash" />
|
<Icon name="trash" />
|
||||||
</button>
|
</Button>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{onClosePane && (
|
{onClosePane && (
|
||||||
<button className="small ghost" onClick={onClosePane} title={t("chat.closePane")} aria-label={t("chat.closePane")}>
|
<Button type="text" size="small" onClick={onClosePane} title={t("chat.closePane")} aria-label={t("chat.closePane")}>
|
||||||
<Icon name="close" />
|
<Icon name="close" />
|
||||||
</button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
{gallery && (
|
{gallery && (
|
||||||
@@ -1124,33 +1127,32 @@ export function ChatView({ sessionId, onMenu, onClosePane }: { sessionId: string
|
|||||||
{errors?.map((e) => (
|
{errors?.map((e) => (
|
||||||
<div key={e.id} className="error-box" role="alert">
|
<div key={e.id} className="error-box" role="alert">
|
||||||
<span>{e.message}</span>
|
<span>{e.message}</span>
|
||||||
<button className="small ghost" onClick={() => dismissError(sessionId, e.id)} aria-label={t("common.close")}>
|
<Button type="text" size="small" onClick={() => dismissError(sessionId, e.id)} aria-label={t("common.close")}>
|
||||||
<Icon name="close" />
|
<Icon name="close" />
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
{session.agent === "plan" && !busy && lastIsAssistant && (
|
{session.agent === "plan" && !busy && lastIsAssistant && (
|
||||||
<div className="row" style={{ justifyContent: "center", margin: "12px 0" }}>
|
<div className="row" style={{ justifyContent: "center", margin: "12px 0" }}>
|
||||||
<button
|
<Button type="primary"
|
||||||
className="primary"
|
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
await update({ agent: "build" });
|
await update({ agent: "build" });
|
||||||
await send(t("plan.implementPrompt"), []);
|
await send(t("plan.implementPrompt"), []);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{t("plan.implement")}
|
{t("plan.implement")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
{(!following || scrolled) && (
|
{(!following || scrolled) && (
|
||||||
<div className="jump-latest">
|
<div className="jump-latest">
|
||||||
<button onClick={jumpPrevOwn} title={t("chat.jumpPrevOwn")} aria-label={t("chat.jumpPrevOwn")}>
|
<Button onClick={jumpPrevOwn} title={t("chat.jumpPrevOwn")} aria-label={t("chat.jumpPrevOwn")}>
|
||||||
<Icon name="arrow-up" />
|
<Icon name="arrow-up" />
|
||||||
</button>
|
</Button>
|
||||||
{!following && <button className="primary" onClick={jumpToLatest} title={t("chat.jumpLatest")} aria-label={t("chat.jumpLatest")}>
|
{!following && <Button type="primary" onClick={jumpToLatest} title={t("chat.jumpLatest")} aria-label={t("chat.jumpLatest")}>
|
||||||
<Icon name="arrow-down" />
|
<Icon name="arrow-down" />
|
||||||
</button>}
|
</Button>}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { Button, Segmented } from "antd";
|
||||||
|
import { Select } from "../ui/Select";
|
||||||
import { TemplatePicker } from "./TemplatePicker";
|
import { TemplatePicker } from "./TemplatePicker";
|
||||||
import { Icon } from "./Icon";
|
import { Icon } from "./Icon";
|
||||||
import { formatSize, imageSrc } from "./FileFigure";
|
import { formatSize, imageSrc } from "./FileFigure";
|
||||||
@@ -5,6 +7,8 @@ import { uploadBatch } from "../uploads";
|
|||||||
import { useEffect, useMemo, useRef, useState } from "react";
|
import { useEffect, useMemo, useRef, useState } from "react";
|
||||||
import { useAgents, useFetch, useModels } from "../hooks";
|
import { useAgents, useFetch, useModels } from "../hooks";
|
||||||
import { useT, type Key } from "../i18n";
|
import { useT, type Key } from "../i18n";
|
||||||
|
import { useStore } from "../store";
|
||||||
|
import { post } from "../api";
|
||||||
import type { ImageData, Session } from "../types";
|
import type { ImageData, Session } from "../types";
|
||||||
import { ModelSelect } from "./ModelSelect";
|
import { ModelSelect } from "./ModelSelect";
|
||||||
import { EffortSelect } from "./Regenerate";
|
import { EffortSelect } from "./Regenerate";
|
||||||
@@ -55,7 +59,7 @@ export function Composer({
|
|||||||
busy: boolean;
|
busy: boolean;
|
||||||
text: string;
|
text: string;
|
||||||
setText: (s: string) => void;
|
setText: (s: string) => void;
|
||||||
onSend: (text: string, images: ImageData[], effort?: string) => void;
|
onSend: (text: string, images: ImageData[], effort?: string) => void | Promise<void>;
|
||||||
onAbort: () => void;
|
onAbort: () => void;
|
||||||
onUpdate: (patch: Partial<Session>) => void;
|
onUpdate: (patch: Partial<Session>) => void;
|
||||||
}) {
|
}) {
|
||||||
@@ -145,11 +149,20 @@ export function Composer({
|
|||||||
return [...mine, ...cmds].slice(0, 12);
|
return [...mine, ...cmds].slice(0, 12);
|
||||||
}, [text, cmdData, snippets, t, mention, mentionHits]);
|
}, [text, cmdData, snippets, t, mention, mentionHits]);
|
||||||
|
|
||||||
const send = () => {
|
// Messages waiting for the agent: a further Enter on the empty field (or Ctrl+Enter with text) delivers them at once.
|
||||||
|
const queued = useStore((s) => (s.queue[session.id] ?? []).length);
|
||||||
|
const force = () => post(`/sessions/${session.id}/queue/force`).catch((e) => toast(e.message));
|
||||||
|
|
||||||
|
const send = (thenForce = false) => {
|
||||||
|
if (!text.trim() && images.length === 0 && files.length === 0 && busy && queued > 0) {
|
||||||
|
void force();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if ((!text.trim() && images.length === 0 && files.length === 0) || uploading > 0) return;
|
if ((!text.trim() && images.length === 0 && files.length === 0) || uploading > 0) return;
|
||||||
// Files are referenced by path; the agent reads them with its tools.
|
// Files are referenced by path; the agent reads them with its tools.
|
||||||
const refs = files.length ? `\n\n${t("composer.attachedFiles")}\n${files.map((f) => `- ${f.path} (${formatSize(f.size)})`).join("\n")}` : "";
|
const refs = files.length ? `\n\n${t("composer.attachedFiles")}\n${files.map((f) => `- ${f.path} (${formatSize(f.size)})`).join("\n")}` : "";
|
||||||
onSend(`${text}${refs}`, images, effort);
|
const sent = onSend(`${text}${refs}`, images, effort);
|
||||||
|
if (thenForce && busy) void Promise.resolve(sent).then(force);
|
||||||
setEffort("");
|
setEffort("");
|
||||||
setImages([]);
|
setImages([]);
|
||||||
setFiles([]);
|
setFiles([]);
|
||||||
@@ -174,11 +187,22 @@ export function Composer({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Ctrl+J inserts a new line (like Shift+Enter, and like Ctrl+J / Shift+Enter in the terminal client).
|
||||||
|
if (e.key.toLowerCase() === "j" && e.ctrlKey && !e.altKey && !e.metaKey && !e.nativeEvent.isComposing) {
|
||||||
|
e.preventDefault();
|
||||||
|
const el = e.currentTarget as HTMLTextAreaElement;
|
||||||
|
const a = el.selectionStart ?? text.length;
|
||||||
|
const b = el.selectionEnd ?? a;
|
||||||
|
setText(`${text.slice(0, a)}\n${text.slice(b)}`);
|
||||||
|
requestAnimationFrame(() => ref.current?.setSelectionRange(a + 1, a + 1));
|
||||||
|
return;
|
||||||
|
}
|
||||||
// Enter sends on desktop; on touch devices Enter inserts a newline.
|
// Enter sends on desktop; on touch devices Enter inserts a newline.
|
||||||
const touch = matchMedia("(pointer: coarse)").matches;
|
const touch = matchMedia("(pointer: coarse)").matches;
|
||||||
if (e.key === "Enter" && !e.shiftKey && !touch && !e.nativeEvent.isComposing) {
|
if (e.key === "Enter" && !e.shiftKey && !touch && !e.nativeEvent.isComposing) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
send();
|
// Ctrl/Cmd+Enter while the agent works: queue the message and interrupt the step so it is read at once.
|
||||||
|
send(e.ctrlKey || e.metaKey);
|
||||||
}
|
}
|
||||||
if (e.key === "Escape" && busy) onAbort();
|
if (e.key === "Escape" && busy) onAbort();
|
||||||
};
|
};
|
||||||
@@ -274,9 +298,9 @@ export function Composer({
|
|||||||
<div className="att file" key={f.path} title={f.path}>
|
<div className="att file" key={f.path} title={f.path}>
|
||||||
<span><Icon name="file" /> {f.name}</span>
|
<span><Icon name="file" /> {f.name}</span>
|
||||||
<small>{formatSize(f.size)}</small>
|
<small>{formatSize(f.size)}</small>
|
||||||
<button onClick={() => removeFile(f.path)} aria-label={t("common.remove")}>
|
<Button onClick={() => removeFile(f.path)} aria-label={t("common.remove")}>
|
||||||
<Icon name="close" />
|
<Icon name="close" />
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
{uploading > 0 && (
|
{uploading > 0 && (
|
||||||
@@ -287,9 +311,9 @@ export function Composer({
|
|||||||
{images.map((img, i) => (
|
{images.map((img, i) => (
|
||||||
<div className="att" key={i}>
|
<div className="att" key={i}>
|
||||||
<img src={imageSrc(img)} alt="" />
|
<img src={imageSrc(img)} alt="" />
|
||||||
<button onClick={() => setImages((cur) => cur.filter((_, j) => j !== i))} aria-label={t("common.remove")}>
|
<Button onClick={() => setImages((cur) => cur.filter((_, j) => j !== i))} aria-label={t("common.remove")}>
|
||||||
<Icon name="close" />
|
<Icon name="close" />
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
@@ -330,7 +354,7 @@ export function Composer({
|
|||||||
/>
|
/>
|
||||||
<div className="composer-bar">
|
<div className="composer-bar">
|
||||||
<div className="composer-options">
|
<div className="composer-options">
|
||||||
<select
|
<Select
|
||||||
className="mode-select"
|
className="mode-select"
|
||||||
value={session.agent}
|
value={session.agent}
|
||||||
onChange={(e) => onUpdate({ agent: e.target.value })}
|
onChange={(e) => onUpdate({ agent: e.target.value })}
|
||||||
@@ -343,18 +367,21 @@ export function Composer({
|
|||||||
{a.name}
|
{a.name}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</Select>
|
||||||
{session.agent === "craft" && (
|
{session.agent === "craft" && (
|
||||||
<div className="mode-tabs" role="tablist" aria-label={t("craft.mode")} title={t("craft.modeHint")}>
|
<Segmented
|
||||||
<button className={session.clean_room !== false ? "active" : ""} onClick={() => onUpdate({ clean_room: true })}>
|
size="small"
|
||||||
{t("craft.cleanRoom")}
|
aria-label={t("craft.mode")}
|
||||||
</button>
|
title={t("craft.modeHint")}
|
||||||
<button className={session.clean_room === false ? "active deep" : ""} onClick={() => onUpdate({ clean_room: false })}>
|
value={session.clean_room === false ? "deep" : "clean"}
|
||||||
{t("craft.deep")}
|
onChange={(v) => onUpdate({ clean_room: v === "clean" })}
|
||||||
</button>
|
options={[
|
||||||
</div>
|
{ value: "clean", label: t("craft.cleanRoom") },
|
||||||
|
{ value: "deep", label: t("craft.deep") },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
<select
|
<Select
|
||||||
value={session.permission_mode}
|
value={session.permission_mode}
|
||||||
onChange={(e) => onUpdate({ permission_mode: e.target.value as Session["permission_mode"] })}
|
onChange={(e) => onUpdate({ permission_mode: e.target.value as Session["permission_mode"] })}
|
||||||
title={t("composer.permissionMode")}
|
title={t("composer.permissionMode")}
|
||||||
@@ -363,12 +390,12 @@ export function Composer({
|
|||||||
<option value="default">{t("permissionMode.default")}</option>
|
<option value="default">{t("permissionMode.default")}</option>
|
||||||
<option value="accept_edits">{t("permissionMode.accept_edits")}</option>
|
<option value="accept_edits">{t("permissionMode.accept_edits")}</option>
|
||||||
<option value="bypass">{t("permissionMode.bypass")}</option>
|
<option value="bypass">{t("permissionMode.bypass")}</option>
|
||||||
</select>
|
</Select>
|
||||||
<ModelSelect value={session.model} onChange={(m) => onUpdate({ model: m })} title={t("composer.model")} />
|
<ModelSelect value={session.model} onChange={(m) => onUpdate({ model: m })} title={t("composer.model")} />
|
||||||
{reasoning && <EffortSelect value={effort} onChange={setEffort} compact />}
|
{reasoning && <EffortSelect value={effort} onChange={setEffort} compact />}
|
||||||
<button className="ghost" style={{ padding: "3px 6px" }} onClick={() => setPicker(true)} title={t("templates.title")}>
|
<Button type="text" style={{ padding: "3px 6px" }} onClick={() => setPicker(true)} title={t("templates.title")}>
|
||||||
<Icon name="template" />
|
<Icon name="template" />
|
||||||
</button>
|
</Button>
|
||||||
{picker && (
|
{picker && (
|
||||||
<TemplatePicker
|
<TemplatePicker
|
||||||
onClose={() => setPicker(false)}
|
onClose={() => setPicker(false)}
|
||||||
@@ -379,15 +406,15 @@ export function Composer({
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<button
|
<Button
|
||||||
className={`ghost ${preview ? "active" : ""}`}
|
type="text" className={preview ? "active" : ""}
|
||||||
style={{ padding: "3px 6px" }}
|
style={{ padding: "3px 6px" }}
|
||||||
onClick={() => setPreview(!preview)}
|
onClick={() => setPreview(!preview)}
|
||||||
aria-pressed={preview}
|
aria-pressed={preview}
|
||||||
title={t(preview ? "composer.previewEdit" : "composer.preview")}
|
title={t(preview ? "composer.previewEdit" : "composer.preview")}
|
||||||
>
|
>
|
||||||
<Icon name={preview ? "edit" : "eye"} />
|
<Icon name={preview ? "edit" : "eye"} />
|
||||||
</button>
|
</Button>
|
||||||
<VoiceButton onText={(d) => setText(text ? `${text.replace(/\s+$/, "")} ${d}` : d)} onInterim={setInterim} />
|
<VoiceButton onText={(d) => setText(text ? `${text.replace(/\s+$/, "")} ${d}` : d)} onInterim={setInterim} />
|
||||||
<label className="ghost" style={{ cursor: "pointer", padding: "3px 6px" }} title={t("composer.attach")}>
|
<label className="ghost" style={{ cursor: "pointer", padding: "3px 6px" }} title={t("composer.attach")}>
|
||||||
<Icon name="clip" />
|
<Icon name="clip" />
|
||||||
@@ -396,13 +423,13 @@ export function Composer({
|
|||||||
</div>
|
</div>
|
||||||
<div className="composer-actions">
|
<div className="composer-actions">
|
||||||
{busy && (
|
{busy && (
|
||||||
<button className="danger" onClick={onAbort} title="Esc">
|
<Button danger onClick={onAbort} title="Esc">
|
||||||
<Icon name="stop" /> {t("composer.stop")}
|
<Icon name="stop" /> {t("composer.stop")}
|
||||||
</button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
<button className="primary" onClick={send} disabled={uploading > 0 || (!text.trim() && images.length === 0 && files.length === 0)}>
|
<Button type="primary" onClick={() => send()} disabled={uploading > 0 || (!text.trim() && images.length === 0 && files.length === 0)}>
|
||||||
{busy ? t("composer.queue") : t("composer.send")}
|
{busy ? t("composer.queue") : t("composer.send")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { Button, Input } from "antd";
|
||||||
|
import { Select } from "../ui/Select";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { get } from "../api";
|
import { get } from "../api";
|
||||||
import { getLang, useT } from "../i18n";
|
import { getLang, useT } from "../i18n";
|
||||||
@@ -132,44 +134,44 @@ export function CronBuilder({ value, onChange }: { value: string; onChange: (cro
|
|||||||
<div className="cron-builder">
|
<div className="cron-builder">
|
||||||
<div className="cron-modes" role="radiogroup" aria-label={t("cron.label")}>
|
<div className="cron-modes" role="radiogroup" aria-label={t("cron.label")}>
|
||||||
{modes.map((m) => (
|
{modes.map((m) => (
|
||||||
<button key={m} type="button" role="radio" aria-checked={s.mode === m} className={`chip-btn ${s.mode === m ? "active" : ""}`} onClick={() => set({ mode: m })}>
|
<Button key={m} role="radio" aria-checked={s.mode === m} size="small" shape="round" type={s.mode === m ? "primary" : "default"} onClick={() => set({ mode: m })}>
|
||||||
{t(`cron.mode.${m}` as const)}
|
{t(`cron.mode.${m}` as const)}
|
||||||
</button>
|
</Button>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
<div className="cron-fields">
|
<div className="cron-fields">
|
||||||
{s.mode === "minutes" && (
|
{s.mode === "minutes" && (
|
||||||
<label>
|
<label>
|
||||||
{t("cron.every")}
|
{t("cron.every")}
|
||||||
<select value={s.every} onChange={(e) => set({ every: Number(e.target.value) })}>
|
<Select value={s.every} onChange={(e) => set({ every: Number(e.target.value) })}>
|
||||||
{MINUTE_STEPS.map((n) => (
|
{MINUTE_STEPS.map((n) => (
|
||||||
<option key={n} value={n}>
|
<option key={n} value={n}>
|
||||||
{n}
|
{n}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</Select>
|
||||||
{t("cron.minutes")}
|
{t("cron.minutes")}
|
||||||
</label>
|
</label>
|
||||||
)}
|
)}
|
||||||
{s.mode === "hourly" && (
|
{s.mode === "hourly" && (
|
||||||
<label>
|
<label>
|
||||||
{t("cron.atMinute")}
|
{t("cron.atMinute")}
|
||||||
<input type="number" min={0} max={59} value={s.minute} onChange={(e) => set({ minute: Math.min(59, Math.max(0, Number(e.target.value) || 0)) })} />
|
<Input type="number" min={0} max={59} value={s.minute} onChange={(e) => set({ minute: Math.min(59, Math.max(0, Number(e.target.value) || 0)) })} />
|
||||||
</label>
|
</label>
|
||||||
)}
|
)}
|
||||||
{s.mode === "weekly" && (
|
{s.mode === "weekly" && (
|
||||||
<div className="cron-days" role="group" aria-label={t("cron.days")}>
|
<div className="cron-days" role="group" aria-label={t("cron.days")}>
|
||||||
{WEEK.map((d) => (
|
{WEEK.map((d) => (
|
||||||
<button
|
<Button
|
||||||
key={d}
|
key={d}
|
||||||
type="button"
|
|
||||||
aria-pressed={s.days.includes(d)}
|
aria-pressed={s.days.includes(d)}
|
||||||
className={`chip-btn ${s.days.includes(d) ? "active" : ""}`}
|
size="small" shape="round" type={s.days.includes(d) ? "primary" : "default"}
|
||||||
title={dayName(d, "long")}
|
title={dayName(d, "long")}
|
||||||
onClick={() => set({ days: s.days.includes(d) ? s.days.filter((x) => x !== d) : [...s.days, d] })}
|
onClick={() => set({ days: s.days.includes(d) ? s.days.filter((x) => x !== d) : [...s.days, d] })}
|
||||||
>
|
>
|
||||||
{dayName(d, "short")}
|
{dayName(d, "short")}
|
||||||
</button>
|
</Button>
|
||||||
))}
|
))}
|
||||||
<button type="button" className="link-btn" onClick={() => set({ days: [1, 2, 3, 4, 5] })}>
|
<button type="button" className="link-btn" onClick={() => set({ days: [1, 2, 3, 4, 5] })}>
|
||||||
{t("cron.workdays")}
|
{t("cron.workdays")}
|
||||||
@@ -179,24 +181,24 @@ export function CronBuilder({ value, onChange }: { value: string; onChange: (cro
|
|||||||
{s.mode === "monthly" && (
|
{s.mode === "monthly" && (
|
||||||
<label>
|
<label>
|
||||||
{t("cron.onDay")}
|
{t("cron.onDay")}
|
||||||
<select value={s.dom} onChange={(e) => set({ dom: Number(e.target.value) })}>
|
<Select value={s.dom} onChange={(e) => set({ dom: Number(e.target.value) })}>
|
||||||
{Array.from({ length: 31 }, (_, i) => i + 1).map((d) => (
|
{Array.from({ length: 31 }, (_, i) => i + 1).map((d) => (
|
||||||
<option key={d} value={d}>
|
<option key={d} value={d}>
|
||||||
{d}.
|
{d}.
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</Select>
|
||||||
</label>
|
</label>
|
||||||
)}
|
)}
|
||||||
{(s.mode === "daily" || s.mode === "weekly" || s.mode === "monthly") && (
|
{(s.mode === "daily" || s.mode === "weekly" || s.mode === "monthly") && (
|
||||||
<label>
|
<label>
|
||||||
{t("cron.at")}
|
{t("cron.at")}
|
||||||
<input type="time" value={s.time} onChange={(e) => e.target.value && set({ time: e.target.value })} />
|
<Input type="time" value={s.time} onChange={(e) => e.target.value && set({ time: e.target.value })} />
|
||||||
</label>
|
</label>
|
||||||
)}
|
)}
|
||||||
{s.mode === "custom" && (
|
{s.mode === "custom" && (
|
||||||
<label className="cron-custom">
|
<label className="cron-custom">
|
||||||
<input className="mono" value={s.custom} placeholder="0 3 * * *" spellCheck={false} onChange={(e) => set({ custom: e.target.value })} />
|
<Input className="mono" value={s.custom} placeholder="0 3 * * *" spellCheck={false} onChange={(e) => set({ custom: e.target.value })} />
|
||||||
<small className="hint">{t("cron.customHint")}</small>
|
<small className="hint">{t("cron.customHint")}</small>
|
||||||
</label>
|
</label>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { Checkbox } from "antd";
|
||||||
export function Diff({ diff }: { diff: string }) {
|
export function Diff({ diff }: { diff: string }) {
|
||||||
const lines = diff.replace(/\n+$/, "").split("\n");
|
const lines = diff.replace(/\n+$/, "").split("\n");
|
||||||
return (
|
return (
|
||||||
@@ -43,10 +44,9 @@ export function HunkDiff({ diff, selected, onToggle }: { diff: string; selected:
|
|||||||
))}
|
))}
|
||||||
{hunks.map((h, i) => (
|
{hunks.map((h, i) => (
|
||||||
<div key={i} className={`hunk-block ${selected[i] ? "" : "off"}`}>
|
<div key={i} className={`hunk-block ${selected[i] ? "" : "off"}`}>
|
||||||
<label className="hunk-head">
|
<Checkbox className="hunk-head" checked={!!selected[i]} onChange={() => onToggle(i)}>
|
||||||
<input type="checkbox" checked={!!selected[i]} onChange={() => onToggle(i)} />
|
|
||||||
<span>{h[0]}</span>
|
<span>{h[0]}</span>
|
||||||
</label>
|
</Checkbox>
|
||||||
{h.slice(1).map((l, j) => (
|
{h.slice(1).map((l, j) => (
|
||||||
<div key={j} className={l.startsWith("+") ? "add" : l.startsWith("-") ? "del" : ""}>
|
<div key={j} className={l.startsWith("+") ? "add" : l.startsWith("-") ? "del" : ""}>
|
||||||
{l || " "}
|
{l || " "}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { Button, Checkbox, Input, Segmented } from "antd";
|
||||||
|
import { Select } from "../ui/Select";
|
||||||
import { useEffect, useMemo, useState } from "react";
|
import { useEffect, useMemo, useState } from "react";
|
||||||
import { get, post, put } from "../api";
|
import { get, post, put } from "../api";
|
||||||
import { fmtCompact, fmtCost, fmtRelative, useT } from "../i18n";
|
import { fmtCompact, fmtCost, fmtRelative, useT } from "../i18n";
|
||||||
@@ -166,19 +168,17 @@ export function Factory({ onMenu, overlayId }: { onMenu: () => void; overlayId?:
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="topbar">
|
<div className="topbar">
|
||||||
<button className="ghost menu-btn" onClick={onMenu} aria-label={t("nav.menu")}>
|
<Button type="text" className="menu-btn" onClick={onMenu} aria-label={t("nav.menu")}>
|
||||||
<Icon name="menu" />
|
<Icon name="menu" />
|
||||||
</button>
|
</Button>
|
||||||
<div className="grow">
|
<div className="grow">
|
||||||
<h1>{t("factory.title")}</h1>
|
<h1>{t("factory.title")}</h1>
|
||||||
</div>
|
</div>
|
||||||
<div className="segmented">
|
<Segmented
|
||||||
{(["overview", "settings"] as const).map((x) => (
|
value={tab}
|
||||||
<button key={x} className={tab === x ? "active" : ""} onClick={() => setTab(x)}>
|
onChange={(x) => setTab(x)}
|
||||||
{t(`factory.tab.${x}` as any)}
|
options={(["overview", "settings"] as const).map((x) => ({ value: x, label: t(`factory.tab.${x}` as any) }))}
|
||||||
</button>
|
/>
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div className="page">
|
<div className="page">
|
||||||
<div className="page-inner" style={{ maxWidth: tab === "overview" ? "none" : 1280 }}>
|
<div className="page-inner" style={{ maxWidth: tab === "overview" ? "none" : 1280 }}>
|
||||||
@@ -373,13 +373,13 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
|
|||||||
{recreate && <RecreateDialog onClose={() => setRecreate(false)} />}
|
{recreate && <RecreateDialog onClose={() => setRecreate(false)} />}
|
||||||
<p>{t("factory.empty")}</p>
|
<p>{t("factory.empty")}</p>
|
||||||
<div className="row" style={{ gap: 8, justifyContent: "center" }}>
|
<div className="row" style={{ gap: 8, justifyContent: "center" }}>
|
||||||
<button className="primary" onClick={newProject} disabled={busy}>
|
<Button type="primary" onClick={newProject} disabled={busy}>
|
||||||
<Icon name="plus" /> {t("factory.newProject")}
|
<Icon name="plus" /> {t("factory.newProject")}
|
||||||
</button>
|
</Button>
|
||||||
<button onClick={() => setRecreate(true)} disabled={busy}>
|
<Button onClick={() => setRecreate(true)} disabled={busy}>
|
||||||
<Icon name="search" /> {t("recreate.button")}
|
<Icon name="search" /> {t("recreate.button")}
|
||||||
</button>
|
</Button>
|
||||||
<button onClick={onSettings}>{t("factory.tab.settings")}</button>
|
<Button onClick={onSettings}>{t("factory.tab.settings")}</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -515,7 +515,7 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="factory-repos">
|
<div className="factory-repos">
|
||||||
<select className="factory-repo-select" value={repo} onChange={(e) => setRepo(e.target.value)} aria-label={t("factory.project")}>
|
<Select className="factory-repo-select" value={repo} onChange={(e) => setRepo(e.target.value)} aria-label={t("factory.project")}>
|
||||||
<option value="">
|
<option value="">
|
||||||
{t("factory.allRepos")} ({data.issues.length})
|
{t("factory.allRepos")} ({data.issues.length})
|
||||||
</option>
|
</option>
|
||||||
@@ -525,7 +525,7 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
|
|||||||
{r.version ? ` · v${r.version}` : ""} ({data.issues.filter((i) => i.repo === r.url).length}){r.enabled ? "" : " – off"}
|
{r.version ? ` · v${r.version}` : ""} ({data.issues.filter((i) => i.repo === r.url).length}){r.enabled ? "" : " – off"}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</Select>
|
||||||
{(() => {
|
{(() => {
|
||||||
const r = data.repos.find((x) => x.url === repo);
|
const r = data.repos.find((x) => x.url === repo);
|
||||||
if (!r) return null;
|
if (!r) return null;
|
||||||
@@ -542,24 +542,24 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
|
|||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
})()}
|
})()}
|
||||||
<button className="small primary" onClick={newProject} disabled={busy}>
|
<Button type="primary" size="small" onClick={newProject} disabled={busy}>
|
||||||
<Icon name="plus" /> {t("factory.newProject")}
|
<Icon name="plus" /> {t("factory.newProject")}
|
||||||
</button>
|
</Button>
|
||||||
<button className="small" onClick={() => setRecreate(true)} disabled={busy} title={t("recreate.hint")}>
|
<Button size="small" onClick={() => setRecreate(true)} disabled={busy} title={t("recreate.hint")}>
|
||||||
<Icon name="search" /> {t("recreate.button")}
|
<Icon name="search" /> {t("recreate.button")}
|
||||||
</button>
|
</Button>
|
||||||
<button className="small" onClick={() => issueChat("feature")} disabled={busy} title={t("issues.featureHint")}>
|
<Button size="small" onClick={() => issueChat("feature")} disabled={busy} title={t("issues.featureHint")}>
|
||||||
<Icon name="sparkle" /> {t("issues.feature")}
|
<Icon name="sparkle" /> {t("issues.feature")}
|
||||||
</button>
|
</Button>
|
||||||
<button className="small" onClick={() => issueChat("slice")} disabled={busy} title={t("issues.sliceHint")}>
|
<Button size="small" onClick={() => issueChat("slice")} disabled={busy} title={t("issues.sliceHint")}>
|
||||||
<Icon name="sparkle" /> {t("issues.slice")}
|
<Icon name="sparkle" /> {t("issues.slice")}
|
||||||
</button>
|
</Button>
|
||||||
<button className="small" onClick={startRelease} disabled={busy} title={t("release.hint")}>
|
<Button size="small" onClick={startRelease} disabled={busy} title={t("release.hint")}>
|
||||||
<Icon name="download" /> {t("release.button")}
|
<Icon name="download" /> {t("release.button")}
|
||||||
</button>
|
</Button>
|
||||||
<button className="small" onClick={poll} disabled={busy} title={t("factory.pollNow")}>
|
<Button size="small" onClick={poll} disabled={busy} title={t("factory.pollNow")}>
|
||||||
<Icon name="refresh" /> {t("factory.pollNow")}
|
<Icon name="refresh" /> {t("factory.pollNow")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="factory-board">
|
<div className="factory-board">
|
||||||
@@ -568,9 +568,9 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
|
|||||||
{t("factory.col.backlog")} <span className="chip">{backlogShown.length}</span>
|
{t("factory.col.backlog")} <span className="chip">{backlogShown.length}</span>
|
||||||
</h4>
|
</h4>
|
||||||
{backlogShown.length > 1 && (
|
{backlogShown.length > 1 && (
|
||||||
<button className="small" onClick={() => void enqueue(backlogShown.filter((i) => i.allowed))} disabled={busy || !backlogShown.some((i) => i.allowed)} title={t("factory.backlog.queueAllHint")}>
|
<Button size="small" onClick={() => void enqueue(backlogShown.filter((i) => i.allowed))} disabled={busy || !backlogShown.some((i) => i.allowed)} title={t("factory.backlog.queueAllHint")}>
|
||||||
<Icon name="plus" /> {t("factory.backlog.queueAll")}
|
<Icon name="plus" /> {t("factory.backlog.queueAll")}
|
||||||
</button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
{backlogShown.map((i) => (
|
{backlogShown.map((i) => (
|
||||||
<div key={`${i.repo}#${i.number}`} className="factory-card backlog">
|
<div key={`${i.repo}#${i.number}`} className="factory-card backlog">
|
||||||
@@ -580,9 +580,9 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
|
|||||||
<a href={i.url || issueUrl(i.repo, i.number)} target="_blank" rel="noreferrer" title={i.title}>
|
<a href={i.url || issueUrl(i.repo, i.number)} target="_blank" rel="noreferrer" title={i.title}>
|
||||||
<b>{i.title || `#${i.number}`}</b>
|
<b>{i.title || `#${i.number}`}</b>
|
||||||
</a>
|
</a>
|
||||||
<button className="small" onClick={() => void enqueue([i])} disabled={busy || !i.allowed} title={i.allowed ? t("factory.backlog.queueHint") : t("factory.backlog.notAllowed", { user: i.author })}>
|
<Button size="small" onClick={() => void enqueue([i])} disabled={busy || !i.allowed} title={i.allowed ? t("factory.backlog.queueHint") : t("factory.backlog.notAllowed", { user: i.author })}>
|
||||||
<Icon name="plus" /> {t("factory.backlog.queue")}
|
<Icon name="plus" /> {t("factory.backlog.queue")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
{backlogShown.length === 0 && <span className="hint">{t("factory.backlog.empty")}</span>}
|
{backlogShown.length === 0 && <span className="hint">{t("factory.backlog.empty")}</span>}
|
||||||
@@ -677,26 +677,26 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
|
|||||||
{selected && !phaseRunning && (
|
{selected && !phaseRunning && (
|
||||||
<>
|
<>
|
||||||
<span className="hint">{t("factory.restartAt")}</span>
|
<span className="hint">{t("factory.restartAt")}</span>
|
||||||
<button className="small" onClick={() => restart("new")} disabled={busy}>
|
<Button size="small" onClick={() => restart("new")} disabled={busy}>
|
||||||
{t("factory.col.review")}
|
{t("factory.col.review")}
|
||||||
</button>
|
</Button>
|
||||||
<button className="small" onClick={() => restart("approved")} disabled={busy}>
|
<Button size="small" onClick={() => restart("approved")} disabled={busy}>
|
||||||
{t("factory.col.build")}
|
{t("factory.col.build")}
|
||||||
</button>
|
</Button>
|
||||||
<button className="small" onClick={() => restart("qa")} disabled={busy || !selected.branch}>
|
<Button size="small" onClick={() => restart("qa")} disabled={busy || !selected.branch}>
|
||||||
{t("factory.col.qa")}
|
{t("factory.col.qa")}
|
||||||
</button>
|
</Button>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{selected && !["review", "building", "testing"].includes(selected.state) && (
|
{selected && !["review", "building", "testing"].includes(selected.state) && (
|
||||||
<button className="small" onClick={removeIssue} disabled={busy} title={t("factory.removeHint")}>
|
<Button size="small" onClick={removeIssue} disabled={busy} title={t("factory.removeHint")}>
|
||||||
<Icon name="trash" /> {t("factory.remove")}
|
<Icon name="trash" /> {t("factory.remove")}
|
||||||
</button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
{selected && selected.state === "done" && selected.merged && (
|
{selected && selected.state === "done" && selected.merged && (
|
||||||
<button className="small" onClick={closeIssue} disabled={busy}>
|
<Button size="small" onClick={closeIssue} disabled={busy}>
|
||||||
<Icon name="check" /> {t("factory.close")}
|
<Icon name="check" /> {t("factory.close")}
|
||||||
</button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
{selected && (
|
{selected && (
|
||||||
<>
|
<>
|
||||||
@@ -728,16 +728,16 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
|
|||||||
<span className="spacer" />
|
<span className="spacer" />
|
||||||
{pr.state === "open" && selected?.state === "done" && (
|
{pr.state === "open" && selected?.state === "done" && (
|
||||||
<>
|
<>
|
||||||
<select value={prMethod} onChange={(e) => setPrMethod(e.target.value)} disabled={busy}>
|
<Select value={prMethod} onChange={(e) => setPrMethod(e.target.value)} disabled={busy}>
|
||||||
{["merge", "squash", "rebase"].map((m) => (
|
{["merge", "squash", "rebase"].map((m) => (
|
||||||
<option key={m} value={m}>
|
<option key={m} value={m}>
|
||||||
{t(`factory.merge.${m}` as any)}
|
{t(`factory.merge.${m}` as any)}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</Select>
|
||||||
<button className="small primary" onClick={mergePr} disabled={busy || pr.mergeable === false}>
|
<Button type="primary" size="small" onClick={mergePr} disabled={busy || pr.mergeable === false}>
|
||||||
{t("factory.mergeBtn")}
|
{t("factory.mergeBtn")}
|
||||||
</button>
|
</Button>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
@@ -785,9 +785,9 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
|
|||||||
</td>
|
</td>
|
||||||
<td>{fmtCost(r.cost, "USD")}</td>
|
<td>{fmtCost(r.cost, "USD")}</td>
|
||||||
<td>
|
<td>
|
||||||
<button className="small" onClick={() => openFactoryChat(r.session_id)}>
|
<Button size="small" onClick={() => openFactoryChat(r.session_id)}>
|
||||||
<Icon name="eye" /> {t("factory.openChat")}
|
<Icon name="eye" /> {t("factory.openChat")}
|
||||||
</button>
|
</Button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
))}
|
))}
|
||||||
@@ -825,14 +825,14 @@ function PhaseSkills({ value, onChange }: { value: string[]; onChange: (v: strin
|
|||||||
</button>
|
</button>
|
||||||
))}
|
))}
|
||||||
{rest.length > 0 && value.length < 10 && (
|
{rest.length > 0 && value.length < 10 && (
|
||||||
<select value="" onChange={(e) => e.target.value && onChange([...value, e.target.value])}>
|
<Select value="" onChange={(e) => e.target.value && onChange([...value, e.target.value])}>
|
||||||
<option value="">{t("factory.skillAdd")}</option>
|
<option value="">{t("factory.skillAdd")}</option>
|
||||||
{rest.map((s) => (
|
{rest.map((s) => (
|
||||||
<option key={s.name} value={s.name} title={s.description}>
|
<option key={s.name} value={s.name} title={s.description}>
|
||||||
{s.name}
|
{s.name}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</Select>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="hint">{t("factory.skillsHint")}</div>
|
<div className="hint">{t("factory.skillsHint")}</div>
|
||||||
@@ -851,33 +851,33 @@ function PhaseForm({ phase, value, onChange }: { phase: Phase; value: PhaseCfg;
|
|||||||
</label>
|
</label>
|
||||||
<label>
|
<label>
|
||||||
<span>{t("factory.agent")}</span>
|
<span>{t("factory.agent")}</span>
|
||||||
<select value={value.agent} onChange={(e) => onChange({ agent: e.target.value })}>
|
<Select value={value.agent} onChange={(e) => onChange({ agent: e.target.value })}>
|
||||||
<option value="codecraft">CodeCraft</option>
|
<option value="codecraft">CodeCraft</option>
|
||||||
<option value="claude-code">Claude Code</option>
|
<option value="claude-code">Claude Code</option>
|
||||||
</select>
|
</Select>
|
||||||
</label>
|
</label>
|
||||||
<label>
|
<label>
|
||||||
<span>{t("factory.mode")}</span>
|
<span>{t("factory.mode")}</span>
|
||||||
<select value={value.permission_mode} onChange={(e) => onChange({ permission_mode: e.target.value })}>
|
<Select value={value.permission_mode} onChange={(e) => onChange({ permission_mode: e.target.value })}>
|
||||||
{MODES.map((m) => (
|
{MODES.map((m) => (
|
||||||
<option key={m} value={m}>
|
<option key={m} value={m}>
|
||||||
{t(`permissionMode.${m}` as any)}
|
{t(`permissionMode.${m}` as any)}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</Select>
|
||||||
</label>
|
</label>
|
||||||
<label>
|
<label>
|
||||||
<span>{t("factory.timeout")}</span>
|
<span>{t("factory.timeout")}</span>
|
||||||
<input type="number" min={1} value={value.timeout_minutes} onChange={(e) => onChange({ timeout_minutes: Number(e.target.value) || 60 })} />
|
<Input type="number" min={1} value={value.timeout_minutes} onChange={(e) => onChange({ timeout_minutes: Number(e.target.value) || 60 })} />
|
||||||
</label>
|
</label>
|
||||||
<label>
|
<label>
|
||||||
<span>{t("factory.attempts")}</span>
|
<span>{t("factory.attempts")}</span>
|
||||||
<input type="number" min={1} max={10} value={value.max_attempts} title={t("factory.attemptsHint")} onChange={(e) => onChange({ max_attempts: Math.max(1, Number(e.target.value) || 1) })} />
|
<Input type="number" min={1} max={10} value={value.max_attempts} title={t("factory.attemptsHint")} onChange={(e) => onChange({ max_attempts: Math.max(1, Number(e.target.value) || 1) })} />
|
||||||
</label>
|
</label>
|
||||||
<PhaseSkills value={value.skills ?? []} onChange={(skills) => onChange({ skills })} />
|
<PhaseSkills value={value.skills ?? []} onChange={(skills) => onChange({ skills })} />
|
||||||
<label>
|
<label>
|
||||||
<span>{t("factory.extraPrompt")}</span>
|
<span>{t("factory.extraPrompt")}</span>
|
||||||
<textarea rows={3} value={value.extra_prompt} onChange={(e) => onChange({ extra_prompt: e.target.value })} />
|
<Input.TextArea rows={3} value={value.extra_prompt} onChange={(e) => onChange({ extra_prompt: e.target.value })} />
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -933,8 +933,7 @@ function FactorySettings() {
|
|||||||
<div className="row" style={{ gap: 8, flexWrap: "wrap" }}>
|
<div className="row" style={{ gap: 8, flexWrap: "wrap" }}>
|
||||||
<h3 style={{ margin: 0 }}>{c.name || KIND_NAME[c.kind]}</h3>
|
<h3 style={{ margin: 0 }}>{c.name || KIND_NAME[c.kind]}</h3>
|
||||||
<span className="spacer" />
|
<span className="spacer" />
|
||||||
<button
|
<Button size="small"
|
||||||
className="small"
|
|
||||||
disabled={busy !== undefined}
|
disabled={busy !== undefined}
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
act(`c${i}`, async () => {
|
act(`c${i}`, async () => {
|
||||||
@@ -947,9 +946,8 @@ function FactorySettings() {
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
{busy === `c${i}` ? <Spinner small /> : <Icon name="plug" />} {t("factory.testConn")}
|
{busy === `c${i}` ? <Spinner small /> : <Icon name="plug" />} {t("factory.testConn")}
|
||||||
</button>
|
</Button>
|
||||||
<button
|
<Button size="small"
|
||||||
className="small"
|
|
||||||
title={t("common.delete")}
|
title={t("common.delete")}
|
||||||
aria-label={t("common.delete")}
|
aria-label={t("common.delete")}
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
@@ -957,35 +955,35 @@ function FactorySettings() {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Icon name="trash" />
|
<Icon name="trash" />
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<div className="factory-form">
|
<div className="factory-form">
|
||||||
<label>
|
<label>
|
||||||
<span>{t("factory.connName")}</span>
|
<span>{t("factory.connName")}</span>
|
||||||
<input value={c.name} onChange={(e) => upConn(i, { name: e.target.value })} />
|
<Input value={c.name} onChange={(e) => upConn(i, { name: e.target.value })} />
|
||||||
</label>
|
</label>
|
||||||
<label>
|
<label>
|
||||||
<span>{t("factory.kind")}</span>
|
<span>{t("factory.kind")}</span>
|
||||||
<select value={c.kind} onChange={(e) => upConn(i, { kind: e.target.value as Connection["kind"] })}>
|
<Select value={c.kind} onChange={(e) => upConn(i, { kind: e.target.value as Connection["kind"] })}>
|
||||||
{Object.entries(KIND_NAME).map(([k, n]) => (
|
{Object.entries(KIND_NAME).map(([k, n]) => (
|
||||||
<option key={k} value={k}>
|
<option key={k} value={k}>
|
||||||
{n}
|
{n}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</Select>
|
||||||
</label>
|
</label>
|
||||||
<label>
|
<label>
|
||||||
<span>{t("factory.serviceUrl")}</span>
|
<span>{t("factory.serviceUrl")}</span>
|
||||||
<input value={c.url} placeholder={URL_PLACEHOLDER[c.kind]} onChange={(e) => upConn(i, { url: e.target.value })} />
|
<Input value={c.url} placeholder={URL_PLACEHOLDER[c.kind]} onChange={(e) => upConn(i, { url: e.target.value })} />
|
||||||
</label>
|
</label>
|
||||||
<label>
|
<label>
|
||||||
<span>{t("factory.token")}</span>
|
<span>{t("factory.token")}</span>
|
||||||
<input type="password" autoComplete="new-password" value={c.token} placeholder={t("factory.tokenPlaceholder")} onChange={(e) => upConn(i, { token: e.target.value })} onFocus={(e) => c.token.startsWith("•") && e.currentTarget.select()} />
|
<Input.Password autoComplete="new-password" value={c.token} placeholder={t("factory.tokenPlaceholder")} onChange={(e) => upConn(i, { token: e.target.value })} onFocus={(e) => c.token.startsWith("•") && e.currentTarget.select()} />
|
||||||
<span className="hint">{c.token.startsWith("•") ? t("factory.tokenSet") : t(`factory.tokenHint.${c.kind}` as any)}</span>
|
<span className="hint">{c.token.startsWith("•") ? t("factory.tokenSet") : t(`factory.tokenHint.${c.kind}` as any)}</span>
|
||||||
</label>
|
</label>
|
||||||
<label>
|
<label>
|
||||||
<span>{t("factory.defaultOwner")}</span>
|
<span>{t("factory.defaultOwner")}</span>
|
||||||
<input list={`orgs-${c.id}`} value={c.owner} placeholder={t("draft.ownerPlaceholder")} onChange={(e) => upConn(i, { owner: e.target.value })} />
|
<Input list={`orgs-${c.id}`} value={c.owner} placeholder={t("draft.ownerPlaceholder")} onChange={(e) => upConn(i, { owner: e.target.value })} />
|
||||||
<datalist id={`orgs-${c.id}`}>
|
<datalist id={`orgs-${c.id}`}>
|
||||||
{(orgs[c.id] ?? []).map((o) => (
|
{(orgs[c.id] ?? []).map((o) => (
|
||||||
<option key={o} value={o} />
|
<option key={o} value={o} />
|
||||||
@@ -995,9 +993,9 @@ function FactorySettings() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
<button onClick={() => setConns([...conns, blankConn()])}>
|
<Button onClick={() => setConns([...conns, blankConn()])}>
|
||||||
<Icon name="plus" /> {t("factory.addConn")}
|
<Icon name="plus" /> {t("factory.addConn")}
|
||||||
</button>
|
</Button>
|
||||||
|
|
||||||
<h3 className="factory-h">{t("factory.defaults")}</h3>
|
<h3 className="factory-h">{t("factory.defaults")}</h3>
|
||||||
<div className="hint" style={{ marginBottom: 8 }}>{t("factory.defaultsHint")}</div>
|
<div className="hint" style={{ marginBottom: 8 }}>{t("factory.defaultsHint")}</div>
|
||||||
@@ -1020,12 +1018,10 @@ function FactorySettings() {
|
|||||||
<h3 style={{ margin: 0 }}>{r.url ? repoName(r.url) : t("factory.newRepo")}</h3>
|
<h3 style={{ margin: 0 }}>{r.url ? repoName(r.url) : t("factory.newRepo")}</h3>
|
||||||
<span className="chip">{KIND_NAME[conns.find((c) => c.id === r.connection)?.kind ?? r.kind] ?? r.kind}</span>
|
<span className="chip">{KIND_NAME[conns.find((c) => c.id === r.connection)?.kind ?? r.kind] ?? r.kind}</span>
|
||||||
<span className="spacer" />
|
<span className="spacer" />
|
||||||
<label className="switch">
|
<Checkbox className="switch" checked={r.enabled} onChange={(e) => up(i, { enabled: e.target.checked })}>
|
||||||
<input type="checkbox" checked={r.enabled} onChange={(e) => up(i, { enabled: e.target.checked })} />
|
|
||||||
<span>{t(r.enabled ? "jobs.on" : "jobs.off")}</span>
|
<span>{t(r.enabled ? "jobs.on" : "jobs.off")}</span>
|
||||||
</label>
|
</Checkbox>
|
||||||
<button
|
<Button size="small"
|
||||||
className="small"
|
|
||||||
disabled={busy !== undefined}
|
disabled={busy !== undefined}
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
act(`t${i}`, async () => {
|
act(`t${i}`, async () => {
|
||||||
@@ -1036,9 +1032,8 @@ function FactorySettings() {
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
{busy === `t${i}` ? <Spinner small /> : <Icon name="plug" />} {t("factory.test")}
|
{busy === `t${i}` ? <Spinner small /> : <Icon name="plug" />} {t("factory.test")}
|
||||||
</button>
|
</Button>
|
||||||
<button
|
<Button size="small"
|
||||||
className="small"
|
|
||||||
title={t("common.delete")}
|
title={t("common.delete")}
|
||||||
aria-label={t("common.delete")}
|
aria-label={t("common.delete")}
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
@@ -1046,12 +1041,12 @@ function FactorySettings() {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Icon name="trash" />
|
<Icon name="trash" />
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<div className="factory-form">
|
<div className="factory-form">
|
||||||
<label>
|
<label>
|
||||||
<span>{t("factory.connection")}</span>
|
<span>{t("factory.connection")}</span>
|
||||||
<select
|
<Select
|
||||||
value={r.connection}
|
value={r.connection}
|
||||||
onChange={(e) => up(i, { connection: e.target.value, kind: conns.find((c) => c.id === e.target.value)?.kind ?? r.kind })}
|
onChange={(e) => up(i, { connection: e.target.value, kind: conns.find((c) => c.id === e.target.value)?.kind ?? r.kind })}
|
||||||
>
|
>
|
||||||
@@ -1063,44 +1058,44 @@ function FactorySettings() {
|
|||||||
{c.name || KIND_NAME[c.kind]}
|
{c.name || KIND_NAME[c.kind]}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</Select>
|
||||||
</label>
|
</label>
|
||||||
{!r.connection && (
|
{!r.connection && (
|
||||||
<label>
|
<label>
|
||||||
<span>{t("factory.kind")}</span>
|
<span>{t("factory.kind")}</span>
|
||||||
<select value={r.kind} onChange={(e) => up(i, { kind: e.target.value })}>
|
<Select value={r.kind} onChange={(e) => up(i, { kind: e.target.value })}>
|
||||||
{Object.entries(KIND_NAME).map(([k, n]) => (
|
{Object.entries(KIND_NAME).map(([k, n]) => (
|
||||||
<option key={k} value={k}>
|
<option key={k} value={k}>
|
||||||
{n}
|
{n}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</Select>
|
||||||
</label>
|
</label>
|
||||||
)}
|
)}
|
||||||
<label>
|
<label>
|
||||||
<span>{t("factory.url")}</span>
|
<span>{t("factory.url")}</span>
|
||||||
<input value={r.url} placeholder="https://host/owner/repo.git" onChange={(e) => up(i, { url: e.target.value })} />
|
<Input value={r.url} placeholder="https://host/owner/repo.git" onChange={(e) => up(i, { url: e.target.value })} />
|
||||||
</label>
|
</label>
|
||||||
<label>
|
<label>
|
||||||
<span>{t("factory.repoToken")}</span>
|
<span>{t("factory.repoToken")}</span>
|
||||||
<input type="password" autoComplete="new-password" value={r.token} placeholder={t("factory.repoTokenPlaceholder")} onChange={(e) => up(i, { token: e.target.value })} onFocus={(e) => r.token.startsWith("•") && e.currentTarget.select()} />
|
<Input.Password autoComplete="new-password" value={r.token} placeholder={t("factory.repoTokenPlaceholder")} onChange={(e) => up(i, { token: e.target.value })} onFocus={(e) => r.token.startsWith("•") && e.currentTarget.select()} />
|
||||||
<span className="hint">{r.token.startsWith("•") ? t("factory.tokenSet") : t("factory.repoTokenHint")}</span>
|
<span className="hint">{r.token.startsWith("•") ? t("factory.tokenSet") : t("factory.repoTokenHint")}</span>
|
||||||
</label>
|
</label>
|
||||||
<label>
|
<label>
|
||||||
<span>{t("factory.label")}</span>
|
<span>{t("factory.label")}</span>
|
||||||
<input value={r.label} onChange={(e) => up(i, { label: e.target.value })} />
|
<Input value={r.label} onChange={(e) => up(i, { label: e.target.value })} />
|
||||||
</label>
|
</label>
|
||||||
<label>
|
<label>
|
||||||
<span>{t("factory.parallel")}</span>
|
<span>{t("factory.parallel")}</span>
|
||||||
<input type="number" min={1} max={4} value={r.max_parallel} onChange={(e) => up(i, { max_parallel: Number(e.target.value) || 1 })} />
|
<Input type="number" min={1} max={4} value={r.max_parallel} onChange={(e) => up(i, { max_parallel: Number(e.target.value) || 1 })} />
|
||||||
</label>
|
</label>
|
||||||
<label>
|
<label>
|
||||||
<span>{t("factory.rework")}</span>
|
<span>{t("factory.rework")}</span>
|
||||||
<input type="number" min={0} max={10} value={r.max_rework} title={t("factory.reworkHint")} onChange={(e) => up(i, { max_rework: Math.max(0, Number(e.target.value) || 0) })} />
|
<Input type="number" min={0} max={10} value={r.max_rework} title={t("factory.reworkHint")} onChange={(e) => up(i, { max_rework: Math.max(0, Number(e.target.value) || 0) })} />
|
||||||
</label>
|
</label>
|
||||||
<label>
|
<label>
|
||||||
<span>{t("factory.allowed")}</span>
|
<span>{t("factory.allowed")}</span>
|
||||||
<input value={r.allowed_users.join(", ")} placeholder={t("factory.allowedPlaceholder")} onChange={(e) => up(i, { allowed_users: e.target.value.split(",").map((u) => u.trim()).filter(Boolean) })} />
|
<Input value={r.allowed_users.join(", ")} placeholder={t("factory.allowedPlaceholder")} onChange={(e) => up(i, { allowed_users: e.target.value.split(",").map((u) => u.trim()).filter(Boolean) })} />
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div className="factory-phases">
|
<div className="factory-phases">
|
||||||
@@ -1111,11 +1106,10 @@ function FactorySettings() {
|
|||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
<div className="row" style={{ gap: 8, marginTop: 12 }}>
|
<div className="row" style={{ gap: 8, marginTop: 12 }}>
|
||||||
<button onClick={() => setRepos([...repos, blankRepo(conns.find((c) => c.id)?.id ?? "", conns.find((c) => c.id)?.kind ?? "gitea")])}>
|
<Button onClick={() => setRepos([...repos, blankRepo(conns.find((c) => c.id)?.id ?? "", conns.find((c) => c.id)?.kind ?? "gitea")])}>
|
||||||
<Icon name="plus" /> {t("factory.addRepo")}
|
<Icon name="plus" /> {t("factory.addRepo")}
|
||||||
</button>
|
</Button>
|
||||||
<button
|
<Button type="primary"
|
||||||
className="primary"
|
|
||||||
disabled={busy !== undefined}
|
disabled={busy !== undefined}
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
act("save", async () => {
|
act("save", async () => {
|
||||||
@@ -1125,7 +1119,7 @@ function FactorySettings() {
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
{busy === "save" ? <Spinner small /> : <Icon name="check" />} {t("common.save")}
|
{busy === "save" ? <Spinner small /> : <Icon name="check" />} {t("common.save")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { Button } from "antd";
|
||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
import { navigate } from "../router";
|
import { navigate } from "../router";
|
||||||
import { useT } from "../i18n";
|
import { useT } from "../i18n";
|
||||||
@@ -20,7 +21,7 @@ export function ChatOverlay({ id }: { id: string }) {
|
|||||||
// Esc closes – unless it is meant for a field, a dialog or the image viewer on top.
|
// Esc closes – unless it is meant for a field, a dialog or the image viewer on top.
|
||||||
const el = document.activeElement;
|
const el = document.activeElement;
|
||||||
const typing = el instanceof HTMLTextAreaElement || el instanceof HTMLInputElement || el instanceof HTMLSelectElement;
|
const typing = el instanceof HTMLTextAreaElement || el instanceof HTMLInputElement || el instanceof HTMLSelectElement;
|
||||||
if (e.key === "Escape" && !typing && !document.querySelector(".modal-backdrop, .viewer-overlay")) close();
|
if (e.key === "Escape" && !typing && !document.querySelector(".ant-modal-wrap, .modal-backdrop, .viewer-overlay")) close();
|
||||||
};
|
};
|
||||||
window.addEventListener("keydown", onKey);
|
window.addEventListener("keydown", onKey);
|
||||||
return () => window.removeEventListener("keydown", onKey);
|
return () => window.removeEventListener("keydown", onKey);
|
||||||
@@ -31,12 +32,12 @@ export function ChatOverlay({ id }: { id: string }) {
|
|||||||
<div className="chat-overlay-bar">
|
<div className="chat-overlay-bar">
|
||||||
<span className="hint">{t("factory.chatOverlay")}</span>
|
<span className="hint">{t("factory.chatOverlay")}</span>
|
||||||
<span className="spacer" />
|
<span className="spacer" />
|
||||||
<button className="small" onClick={() => navigate(`/s/${id}`)} title={t("factory.openFullHint")}>
|
<Button size="small" onClick={() => navigate(`/s/${id}`)} title={t("factory.openFullHint")}>
|
||||||
<Icon name="external" /> {t("factory.openFull")}
|
<Icon name="external" /> {t("factory.openFull")}
|
||||||
</button>
|
</Button>
|
||||||
<button className="small" onClick={close} aria-label={t("common.close")}>
|
<Button size="small" onClick={close} aria-label={t("common.close")}>
|
||||||
<Icon name="close" /> {t("common.close")}
|
<Icon name="close" /> {t("common.close")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<div className="chat-overlay-body">
|
<div className="chat-overlay-body">
|
||||||
<ChatView key={id} sessionId={id} onMenu={close} />
|
<ChatView key={id} sessionId={id} onMenu={close} />
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
import { Button, Checkbox, Input } from "antd";
|
||||||
|
import { Modal } from "../ui/Modal";
|
||||||
|
import { Select } from "../ui/Select";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { get, post } from "../api";
|
import { get, post } from "../api";
|
||||||
import { useT } from "../i18n";
|
import { useT } from "../i18n";
|
||||||
@@ -38,9 +41,9 @@ export function DraftBar({ sessionId }: { sessionId: string }) {
|
|||||||
<Icon name="scroll" />
|
<Icon name="scroll" />
|
||||||
<span>{t("draft.hint")}</span>
|
<span>{t("draft.hint")}</span>
|
||||||
<span className="spacer" />
|
<span className="spacer" />
|
||||||
<button className="small primary" onClick={() => setOpen(true)}>
|
<Button type="primary" size="small" onClick={() => setOpen(true)}>
|
||||||
<Icon name="check" /> {t("draft.create")}
|
<Icon name="check" /> {t("draft.create")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
{open && <CreateProjectDialog sessionId={sessionId} onClose={() => setOpen(false)} />}
|
{open && <CreateProjectDialog sessionId={sessionId} onClose={() => setOpen(false)} />}
|
||||||
</>
|
</>
|
||||||
@@ -77,11 +80,9 @@ function CreateProjectDialog({ sessionId, onClose }: { sessionId: string; onClos
|
|||||||
|
|
||||||
if (!draft)
|
if (!draft)
|
||||||
return (
|
return (
|
||||||
<div className="modal-backdrop">
|
<Modal >
|
||||||
<div className="modal">
|
|
||||||
<Spinner />
|
<Spinner />
|
||||||
</div>
|
</Modal>
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const conn = draft.connections.find((c) => c.id === connection);
|
const conn = draft.connections.find((c) => c.id === connection);
|
||||||
@@ -102,8 +103,7 @@ function CreateProjectDialog({ sessionId, onClose }: { sessionId: string; onClos
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="modal-backdrop" onClick={busy ? undefined : onClose}>
|
<Modal onClose={busy ? undefined : onClose} className="draft-modal" role="dialog" aria-label={t("draft.create")}>
|
||||||
<div className="modal draft-modal" role="dialog" aria-label={t("draft.create")} onClick={(e) => e.stopPropagation()}>
|
|
||||||
<h3>{t("draft.create")}</h3>
|
<h3>{t("draft.create")}</h3>
|
||||||
{draft.connections.length === 0 ? (
|
{draft.connections.length === 0 ? (
|
||||||
<div className="notice err">
|
<div className="notice err">
|
||||||
@@ -119,7 +119,7 @@ function CreateProjectDialog({ sessionId, onClose }: { sessionId: string; onClos
|
|||||||
<div className="factory-form">
|
<div className="factory-form">
|
||||||
<label>
|
<label>
|
||||||
<span>{t("draft.name")}</span>
|
<span>{t("draft.name")}</span>
|
||||||
<input
|
<Input
|
||||||
autoFocus
|
autoFocus
|
||||||
value={name}
|
value={name}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
@@ -130,7 +130,7 @@ function CreateProjectDialog({ sessionId, onClose }: { sessionId: string; onClos
|
|||||||
</label>
|
</label>
|
||||||
<label>
|
<label>
|
||||||
<span>{t("draft.slug")}</span>
|
<span>{t("draft.slug")}</span>
|
||||||
<input
|
<Input
|
||||||
value={slug}
|
value={slug}
|
||||||
className="mono"
|
className="mono"
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
@@ -141,11 +141,11 @@ function CreateProjectDialog({ sessionId, onClose }: { sessionId: string; onClos
|
|||||||
</label>
|
</label>
|
||||||
<label style={{ gridColumn: "1 / -1" }}>
|
<label style={{ gridColumn: "1 / -1" }}>
|
||||||
<span>{t("draft.description")}</span>
|
<span>{t("draft.description")}</span>
|
||||||
<input value={description} onChange={(e) => setDescription(e.target.value)} />
|
<Input value={description} onChange={(e) => setDescription(e.target.value)} />
|
||||||
</label>
|
</label>
|
||||||
<label>
|
<label>
|
||||||
<span>{t("draft.connection")}</span>
|
<span>{t("draft.connection")}</span>
|
||||||
<select
|
<Select
|
||||||
value={connection}
|
value={connection}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
setConnection(e.target.value);
|
setConnection(e.target.value);
|
||||||
@@ -157,11 +157,11 @@ function CreateProjectDialog({ sessionId, onClose }: { sessionId: string; onClos
|
|||||||
{c.name || c.kind} ({c.kind})
|
{c.name || c.kind} ({c.kind})
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</Select>
|
||||||
</label>
|
</label>
|
||||||
<label>
|
<label>
|
||||||
<span>{t("draft.owner")}</span>
|
<span>{t("draft.owner")}</span>
|
||||||
<input value={owner} placeholder={t("draft.ownerPlaceholder")} onChange={(e) => setOwner(e.target.value)} />
|
<Input value={owner} placeholder={t("draft.ownerPlaceholder")} onChange={(e) => setOwner(e.target.value)} />
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div className="hint" style={{ margin: "6px 0" }}>
|
<div className="hint" style={{ margin: "6px 0" }}>
|
||||||
@@ -174,15 +174,14 @@ function CreateProjectDialog({ sessionId, onClose }: { sessionId: string; onClos
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<div className="row" style={{ justifyContent: "flex-end", gap: 8, marginTop: 12 }}>
|
<div className="row" style={{ justifyContent: "flex-end", gap: 8, marginTop: 12 }}>
|
||||||
<button onClick={onClose} disabled={busy}>
|
<Button onClick={onClose} disabled={busy}>
|
||||||
{t("common.cancel")}
|
{t("common.cancel")}
|
||||||
</button>
|
</Button>
|
||||||
<button className="primary" onClick={create} disabled={!ready || busy}>
|
<Button type="primary" onClick={create} disabled={!ready || busy}>
|
||||||
{busy ? <Spinner small /> : <Icon name="check" />} {t("draft.createGo")}
|
{busy ? <Spinner small /> : <Icon name="check" />} {t("draft.createGo")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
</Modal>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,9 +208,9 @@ export function IssueBar({ sessionId }: { sessionId: string }) {
|
|||||||
<Icon name="scroll" />
|
<Icon name="scroll" />
|
||||||
<span>{t("issues.hint")}</span>
|
<span>{t("issues.hint")}</span>
|
||||||
<span className="spacer" />
|
<span className="spacer" />
|
||||||
<button className="small primary" onClick={() => setOpen(true)}>
|
<Button type="primary" size="small" onClick={() => setOpen(true)}>
|
||||||
<Icon name="check" /> {t("issues.create")}
|
<Icon name="check" /> {t("issues.create")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
{open && <CreateIssuesDialog sessionId={sessionId} onClose={() => setOpen(false)} />}
|
{open && <CreateIssuesDialog sessionId={sessionId} onClose={() => setOpen(false)} />}
|
||||||
</>
|
</>
|
||||||
@@ -241,11 +240,9 @@ function CreateIssuesDialog({ sessionId, onClose }: { sessionId: string; onClose
|
|||||||
|
|
||||||
if (!data)
|
if (!data)
|
||||||
return (
|
return (
|
||||||
<div className="modal-backdrop">
|
<Modal >
|
||||||
<div className="modal">
|
|
||||||
<Spinner />
|
<Spinner />
|
||||||
</div>
|
</Modal>
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const chosen = items.filter((i) => i.on && i.title.trim());
|
const chosen = items.filter((i) => i.on && i.title.trim());
|
||||||
@@ -268,8 +265,7 @@ function CreateIssuesDialog({ sessionId, onClose }: { sessionId: string; onClose
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="modal-backdrop" onClick={busy ? undefined : onClose}>
|
<Modal onClose={busy ? undefined : onClose} className="draft-modal" role="dialog" aria-label={t("issues.create")}>
|
||||||
<div className="modal draft-modal" role="dialog" aria-label={t("issues.create")} onClick={(e) => e.stopPropagation()}>
|
|
||||||
<h3>{t("issues.create")}</h3>
|
<h3>{t("issues.create")}</h3>
|
||||||
{!data.proposal ? (
|
{!data.proposal ? (
|
||||||
<div className="notice err">{t("issues.noProposal")}</div>
|
<div className="notice err">{t("issues.noProposal")}</div>
|
||||||
@@ -277,41 +273,38 @@ function CreateIssuesDialog({ sessionId, onClose }: { sessionId: string; onClose
|
|||||||
<>
|
<>
|
||||||
<label className="factory-form" style={{ display: "block" }}>
|
<label className="factory-form" style={{ display: "block" }}>
|
||||||
<span>{t("issues.spec")}</span>
|
<span>{t("issues.spec")}</span>
|
||||||
<input className="mono" value={spec} onChange={(e) => setSpec(e.target.value)} />
|
<Input className="mono" value={spec} onChange={(e) => setSpec(e.target.value)} />
|
||||||
</label>
|
</label>
|
||||||
<div className="issue-list">
|
<div className="issue-list">
|
||||||
{items.map((i, k) => (
|
{items.map((i, k) => (
|
||||||
<div key={k} className="issue-item">
|
<div key={k} className="issue-item">
|
||||||
<label className="row" style={{ gap: 8 }}>
|
<Checkbox className="row" style={{ gap: 8 }} checked={i.on} onChange={(e) => set(k, { on: e.target.checked })}>
|
||||||
<input type="checkbox" checked={i.on} onChange={(e) => set(k, { on: e.target.checked })} />
|
<Input style={{ flex: 1 }} value={i.title} onChange={(e) => set(k, { title: e.target.value })} />
|
||||||
<input style={{ flex: 1 }} value={i.title} onChange={(e) => set(k, { title: e.target.value })} />
|
</Checkbox>
|
||||||
</label>
|
|
||||||
<div className="hint">{i.scope}</div>
|
<div className="hint">{i.scope}</div>
|
||||||
{i.depends && i.depends.toLowerCase() !== "none" && <div className="hint">{t("issues.depends", { d: i.depends })}</div>}
|
{i.depends && i.depends.toLowerCase() !== "none" && <div className="hint">{t("issues.depends", { d: i.depends })}</div>}
|
||||||
<details>
|
<details>
|
||||||
<summary>{t("issues.description")}</summary>
|
<summary>{t("issues.description")}</summary>
|
||||||
<textarea rows={4} value={i.description} onChange={(e) => set(k, { description: e.target.value })} />
|
<Input.TextArea rows={4} value={i.description} onChange={(e) => set(k, { description: e.target.value })} />
|
||||||
</details>
|
</details>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
<label className="row" style={{ gap: 8, marginTop: 8 }}>
|
<Checkbox className="row" style={{ gap: 8, marginTop: 8 }} checked={start} onChange={(e) => setStart(e.target.checked)}>
|
||||||
<input type="checkbox" checked={start} onChange={(e) => setStart(e.target.checked)} />
|
|
||||||
<span>{t("issues.start")}</span>
|
<span>{t("issues.start")}</span>
|
||||||
</label>
|
</Checkbox>
|
||||||
<div className="hint">{t("issues.startHint")}</div>
|
<div className="hint">{t("issues.startHint")}</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<div className="row" style={{ justifyContent: "flex-end", gap: 8, marginTop: 12 }}>
|
<div className="row" style={{ justifyContent: "flex-end", gap: 8, marginTop: 12 }}>
|
||||||
<button onClick={onClose} disabled={busy}>
|
<Button onClick={onClose} disabled={busy}>
|
||||||
{t("common.cancel")}
|
{t("common.cancel")}
|
||||||
</button>
|
</Button>
|
||||||
<button className="primary" onClick={create} disabled={!data.proposal || chosen.length === 0 || !spec.trim() || busy}>
|
<Button type="primary" onClick={create} disabled={!data.proposal || chosen.length === 0 || !spec.trim() || busy}>
|
||||||
{busy ? <Spinner small /> : <Icon name="check" />} {t("issues.createGo", { n: chosen.length })}
|
{busy ? <Spinner small /> : <Icon name="check" />} {t("issues.createGo", { n: chosen.length })}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
</Modal>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -339,14 +332,13 @@ export function RecreateDialog({ onClose }: { onClose: () => void }) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="modal-backdrop" onClick={busy ? undefined : onClose}>
|
<Modal onClose={busy ? undefined : onClose} className="draft-modal" role="dialog" aria-label={t("recreate.title")}>
|
||||||
<div className="modal draft-modal" role="dialog" aria-label={t("recreate.title")} onClick={(e) => e.stopPropagation()}>
|
|
||||||
<h3>{t("recreate.title")}</h3>
|
<h3>{t("recreate.title")}</h3>
|
||||||
<div className="hint" style={{ marginBottom: 8 }}>{t("recreate.hint")}</div>
|
<div className="hint" style={{ marginBottom: 8 }}>{t("recreate.hint")}</div>
|
||||||
<div className="factory-form">
|
<div className="factory-form">
|
||||||
<label style={{ gridColumn: "1 / -1" }}>
|
<label style={{ gridColumn: "1 / -1" }}>
|
||||||
<span>{t("recreate.source")}</span>
|
<span>{t("recreate.source")}</span>
|
||||||
<input autoFocus value={source} placeholder="https://…" onChange={(e) => setSource(e.target.value)} />
|
<Input autoFocus value={source} placeholder="https://…" onChange={(e) => setSource(e.target.value)} />
|
||||||
</label>
|
</label>
|
||||||
<label style={{ gridColumn: "1 / -1" }}>
|
<label style={{ gridColumn: "1 / -1" }}>
|
||||||
<span>{t("recreate.files")}</span>
|
<span>{t("recreate.files")}</span>
|
||||||
@@ -354,18 +346,17 @@ export function RecreateDialog({ onClose }: { onClose: () => void }) {
|
|||||||
</label>
|
</label>
|
||||||
<label style={{ gridColumn: "1 / -1" }}>
|
<label style={{ gridColumn: "1 / -1" }}>
|
||||||
<span>{t("recreate.notes")}</span>
|
<span>{t("recreate.notes")}</span>
|
||||||
<textarea rows={4} value={notes} placeholder={t("recreate.notesPlaceholder")} onChange={(e) => setNotes(e.target.value)} />
|
<Input.TextArea rows={4} value={notes} placeholder={t("recreate.notesPlaceholder")} onChange={(e) => setNotes(e.target.value)} />
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div className="row" style={{ justifyContent: "flex-end", gap: 8, marginTop: 12 }}>
|
<div className="row" style={{ justifyContent: "flex-end", gap: 8, marginTop: 12 }}>
|
||||||
<button onClick={onClose} disabled={busy}>
|
<Button onClick={onClose} disabled={busy}>
|
||||||
{t("common.cancel")}
|
{t("common.cancel")}
|
||||||
</button>
|
</Button>
|
||||||
<button className="primary" onClick={start} disabled={busy || (!source.trim() && files.length === 0)}>
|
<Button type="primary" onClick={start} disabled={busy || (!source.trim() && files.length === 0)}>
|
||||||
{busy ? <Spinner small /> : <Icon name="search" />} {t("recreate.go")}
|
{busy ? <Spinner small /> : <Icon name="search" />} {t("recreate.go")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
</Modal>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { Button, Input } from "antd";
|
||||||
|
import { Modal } from "../ui/Modal";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { get, post } from "../api";
|
import { get, post } from "../api";
|
||||||
import { fmtRelative, useT } from "../i18n";
|
import { fmtRelative, useT } from "../i18n";
|
||||||
@@ -46,11 +48,9 @@ export function ReleaseDialog({ repo, onClose, onStarted }: { repo: string; onCl
|
|||||||
|
|
||||||
if (!pv)
|
if (!pv)
|
||||||
return (
|
return (
|
||||||
<div className="modal-backdrop">
|
<Modal >
|
||||||
<div className="modal">
|
|
||||||
<Spinner />
|
<Spinner />
|
||||||
</div>
|
</Modal>
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const start = async () => {
|
const start = async () => {
|
||||||
@@ -67,15 +67,14 @@ export function ReleaseDialog({ repo, onClose, onStarted }: { repo: string; onCl
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="modal-backdrop" onClick={busy ? undefined : onClose}>
|
<Modal onClose={busy ? undefined : onClose} className="draft-modal" role="dialog" aria-label={t("release.title")}>
|
||||||
<div className="modal draft-modal" role="dialog" aria-label={t("release.title")} onClick={(e) => e.stopPropagation()}>
|
|
||||||
<h3>
|
<h3>
|
||||||
{t("release.title")} – {repoName(repo)}
|
{t("release.title")} – {repoName(repo)}
|
||||||
</h3>
|
</h3>
|
||||||
<div className="hint">{t("release.current", { v: pv.current })}</div>
|
<div className="hint">{t("release.current", { v: pv.current })}</div>
|
||||||
<label className="factory-form" style={{ display: "block", margin: "8px 0" }}>
|
<label className="factory-form" style={{ display: "block", margin: "8px 0" }}>
|
||||||
<span>{t("release.version")}</span>
|
<span>{t("release.version")}</span>
|
||||||
<input className="mono" value={version} onChange={(e) => setVersion(e.target.value.trim().replace(/^v/, ""))} />
|
<Input className="mono" value={version} onChange={(e) => setVersion(e.target.value.trim().replace(/^v/, ""))} />
|
||||||
</label>
|
</label>
|
||||||
<div className="notice">{t("release.what")}</div>
|
<div className="notice">{t("release.what")}</div>
|
||||||
{pv.spec ? (
|
{pv.spec ? (
|
||||||
@@ -89,15 +88,14 @@ export function ReleaseDialog({ repo, onClose, onStarted }: { repo: string; onCl
|
|||||||
)}
|
)}
|
||||||
{pv.running && <div className="notice err">{t("release.running")}</div>}
|
{pv.running && <div className="notice err">{t("release.running")}</div>}
|
||||||
<div className="row" style={{ justifyContent: "flex-end", gap: 8, marginTop: 12 }}>
|
<div className="row" style={{ justifyContent: "flex-end", gap: 8, marginTop: 12 }}>
|
||||||
<button onClick={onClose} disabled={busy}>
|
<Button onClick={onClose} disabled={busy}>
|
||||||
{t("common.cancel")}
|
{t("common.cancel")}
|
||||||
</button>
|
</Button>
|
||||||
<button className="primary" onClick={start} disabled={busy || pv.running || !/^\d+\.\d+\.\d+$/.test(version)}>
|
<Button type="primary" onClick={start} disabled={busy || pv.running || !/^\d+\.\d+\.\d+$/.test(version)}>
|
||||||
{busy ? <Spinner small /> : <Icon name="check" />} {t("release.go", { v: version })}
|
{busy ? <Spinner small /> : <Icon name="check" />} {t("release.go", { v: version })}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
</Modal>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { Button, Segmented } from "antd";
|
||||||
import { lazy, Suspense, useEffect, useState } from "react";
|
import { lazy, Suspense, useEffect, useState } from "react";
|
||||||
import { get } from "../api";
|
import { get } from "../api";
|
||||||
import { useT } from "../i18n";
|
import { useT } from "../i18n";
|
||||||
@@ -33,13 +34,13 @@ function PdfPreview({ path }: { path: string }) {
|
|||||||
return (
|
return (
|
||||||
<div className="pdf-preview">
|
<div className="pdf-preview">
|
||||||
<div className="row pdf-nav">
|
<div className="row pdf-nav">
|
||||||
<button className="small" disabled={page <= 1} onClick={() => setPage(page - 1)}>
|
<Button size="small" disabled={page <= 1} onClick={() => setPage(page - 1)}>
|
||||||
‹
|
‹
|
||||||
</button>
|
</Button>
|
||||||
<span>{t("preview.page", { n: page, total: pages ?? "…" })}</span>
|
<span>{t("preview.page", { n: page, total: pages ?? "…" })}</span>
|
||||||
<button className="small" disabled={!pages || page >= pages} onClick={() => setPage(page + 1)}>
|
<Button size="small" disabled={!pages || page >= pages} onClick={() => setPage(page + 1)}>
|
||||||
›
|
›
|
||||||
</button>
|
</Button>
|
||||||
<span className="spacer" />
|
<span className="spacer" />
|
||||||
<a className="button small" href={`/api/files/raw?${q(path)}`} target="_blank" rel="noreferrer">
|
<a className="button small" href={`/api/files/raw?${q(path)}`} target="_blank" rel="noreferrer">
|
||||||
{t("preview.openBrowser")}
|
{t("preview.openBrowser")}
|
||||||
@@ -74,13 +75,12 @@ function DocPreview({ path }: { path: string }) {
|
|||||||
const s = data.sheets?.[sheet];
|
const s = data.sheets?.[sheet];
|
||||||
return (
|
return (
|
||||||
<div className="pdf-preview">
|
<div className="pdf-preview">
|
||||||
<div className="mode-tabs sheet-tabs">
|
<Segmented
|
||||||
{data.sheets?.map((x, i) => (
|
className="sheet-tabs seg-wrap"
|
||||||
<button key={x.name} className={i === sheet ? "active" : ""} onClick={() => setSheet(i)}>
|
value={sheet}
|
||||||
{x.name}
|
onChange={setSheet}
|
||||||
</button>
|
options={data.sheets?.map((x, i) => ({ value: i, label: x.name })) ?? []}
|
||||||
))}
|
/>
|
||||||
</div>
|
|
||||||
<div className="pane-scroll">
|
<div className="pane-scroll">
|
||||||
{s && (
|
{s && (
|
||||||
<table className="grid sheet">
|
<table className="grid sheet">
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { Button, Input, Segmented } from "antd";
|
||||||
|
import { Select } from "../ui/Select";
|
||||||
import { uploadBatch } from "../uploads";
|
import { uploadBatch } from "../uploads";
|
||||||
import { Icon } from "./Icon";
|
import { Icon } from "./Icon";
|
||||||
import { lazy, Suspense, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
import { lazy, Suspense, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||||
@@ -260,39 +262,39 @@ export function Files({ onMenu, embed }: { onMenu?: () => void; embed?: FilesEmb
|
|||||||
>
|
>
|
||||||
<div className="files-toolbar">
|
<div className="files-toolbar">
|
||||||
{roots.length > 1 && (
|
{roots.length > 1 && (
|
||||||
<select value={root?.path ?? ""} onChange={(e) => { const v = e.target.value; void confirmDiscard().then((ok): unknown => ok && load(v)); }} aria-label={t("images.folder")}>
|
<Select value={root?.path ?? ""} onChange={(e) => { const v = e.target.value; void confirmDiscard().then((ok): unknown => ok && load(v)); }} aria-label={t("images.folder")}>
|
||||||
{roots.map((r) => (
|
{roots.map((r) => (
|
||||||
<option key={r.path} value={r.path}>
|
<option key={r.path} value={r.path}>
|
||||||
{r.name}
|
{r.name}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</Select>
|
||||||
)}
|
)}
|
||||||
<input className="files-search" placeholder={t("files.search")} value={search} onChange={(e) => setSearch(e.target.value)} />
|
<Input className="files-search" placeholder={t("files.search")} value={search} onChange={(e) => setSearch(e.target.value)} />
|
||||||
<button className="small" title={t("files.newFile")} onClick={() => newEntry(false)}>
|
<Button size="small" title={t("files.newFile")} onClick={() => newEntry(false)}>
|
||||||
<Icon name="plus" className="tiny" /> <Icon name="file" />
|
<Icon name="plus" className="tiny" /> <Icon name="file" />
|
||||||
</button>
|
</Button>
|
||||||
<button className="small" title={t("files.newFolder")} onClick={() => newEntry(true)}>
|
<Button size="small" title={t("files.newFolder")} onClick={() => newEntry(true)}>
|
||||||
<Icon name="plus" className="tiny" /> <Icon name="folder" />
|
<Icon name="plus" className="tiny" /> <Icon name="folder" />
|
||||||
</button>
|
</Button>
|
||||||
<button className="small" title={t("files.upload")} onClick={() => uploadRef.current?.click()}>
|
<Button size="small" title={t("files.upload")} onClick={() => uploadRef.current?.click()}>
|
||||||
<Icon name="upload" />
|
<Icon name="upload" />
|
||||||
</button>
|
</Button>
|
||||||
<input ref={uploadRef} type="file" multiple hidden onChange={(e) => e.target.files && upload(e.target.files)} />
|
<input ref={uploadRef} type="file" multiple hidden onChange={(e) => e.target.files && upload(e.target.files)} />
|
||||||
<button className={`small ${hidden ? "active" : ""}`} title={t("files.showHidden")} onClick={() => setHidden(!hidden)}>
|
<Button size="small" className={hidden ? "active" : ""} title={t("files.showHidden")} onClick={() => setHidden(!hidden)}>
|
||||||
.*
|
.*
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<div className="crumbs">
|
<div className="crumbs">
|
||||||
<button
|
<Button type="text" size="small"
|
||||||
className="small ghost crumbs-up"
|
className="crumbs-up"
|
||||||
disabled={!listing?.parent}
|
disabled={!listing?.parent}
|
||||||
onClick={() => listing?.parent && void confirmDiscard().then((ok): unknown => ok && load(listing.parent!))}
|
onClick={() => listing?.parent && void confirmDiscard().then((ok): unknown => ok && load(listing.parent!))}
|
||||||
title={t("files.up")}
|
title={t("files.up")}
|
||||||
aria-label={t("files.up")}
|
aria-label={t("files.up")}
|
||||||
>
|
>
|
||||||
<Icon name="folder-up" />
|
<Icon name="folder-up" />
|
||||||
</button>
|
</Button>
|
||||||
{crumbs.map((c, i) => {
|
{crumbs.map((c, i) => {
|
||||||
const path = i === 0 ? c : `${crumbs[0]}/${crumbs.slice(1, i + 1).join("/")}`;
|
const path = i === 0 ? c : `${crumbs[0]}/${crumbs.slice(1, i + 1).join("/")}`;
|
||||||
return (
|
return (
|
||||||
@@ -341,18 +343,18 @@ export function Files({ onMenu, embed }: { onMenu?: () => void; embed?: FilesEmb
|
|||||||
<summary aria-label={t("files.actions")}><Icon name="more" /></summary>
|
<summary aria-label={t("files.actions")}><Icon name="more" /></summary>
|
||||||
<div className="menu">
|
<div className="menu">
|
||||||
{e.is_dir && (
|
{e.is_dir && (
|
||||||
<button onClick={() => void chatHere(e)}>{t("files.chatHere")}</button>
|
<Button onClick={() => void chatHere(e)}>{t("files.chatHere")}</Button>
|
||||||
)}
|
)}
|
||||||
<button onClick={() => rename(e)}>{t("files.rename")}</button>
|
<Button onClick={() => rename(e)}>{t("files.rename")}</Button>
|
||||||
<button onClick={() => duplicate(e)}>{t("files.duplicate")}</button>
|
<Button onClick={() => duplicate(e)}>{t("files.duplicate")}</Button>
|
||||||
{!e.is_dir && (
|
{!e.is_dir && (
|
||||||
<a className="button" href={rawUrl(e.path, true)}>
|
<a className="button" href={rawUrl(e.path, true)}>
|
||||||
{t("files.download")}
|
{t("files.download")}
|
||||||
</a>
|
</a>
|
||||||
)}
|
)}
|
||||||
<button className="danger" onClick={() => remove(e)}>
|
<Button danger onClick={() => remove(e)}>
|
||||||
{t("common.delete")}
|
{t("common.delete")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</details>
|
</details>
|
||||||
</div>
|
</div>
|
||||||
@@ -371,9 +373,9 @@ export function Files({ onMenu, embed }: { onMenu?: () => void; embed?: FilesEmb
|
|||||||
return (
|
return (
|
||||||
<div className="editor-pane">
|
<div className="editor-pane">
|
||||||
<div className="editor-bar">
|
<div className="editor-bar">
|
||||||
<button className="ghost small mobile-only" onClick={() => setMobileEditor(false)}>
|
<Button type="text" size="small" className="mobile-only" onClick={() => setMobileEditor(false)}>
|
||||||
<Icon name="arrow-left" />
|
<Icon name="arrow-left" />
|
||||||
</button>
|
</Button>
|
||||||
<b className="grow">{pane.title}</b>
|
<b className="grow">{pane.title}</b>
|
||||||
</div>
|
</div>
|
||||||
<div className="pane-scroll">{pane.diff ? <Diff diff={pane.diff} /> : <div className="empty">{t("git.noDiff")}</div>}</div>
|
<div className="pane-scroll">{pane.diff ? <Diff diff={pane.diff} /> : <div className="empty">{t("git.noDiff")}</div>}</div>
|
||||||
@@ -387,25 +389,25 @@ export function Files({ onMenu, embed }: { onMenu?: () => void; embed?: FilesEmb
|
|||||||
return (
|
return (
|
||||||
<div className="editor-pane">
|
<div className="editor-pane">
|
||||||
<div className="editor-bar">
|
<div className="editor-bar">
|
||||||
<button className="ghost small mobile-only" onClick={() => void confirmDiscard().then((ok): unknown => ok && setMobileEditor(false))}>
|
<Button type="text" size="small" className="mobile-only" onClick={() => void confirmDiscard().then((ok): unknown => ok && setMobileEditor(false))}>
|
||||||
<Icon name="arrow-left" />
|
<Icon name="arrow-left" />
|
||||||
</button>
|
</Button>
|
||||||
<b className="grow" title={f.path}>
|
<b className="grow" title={f.path}>
|
||||||
{baseName(f.path)}
|
{baseName(f.path)}
|
||||||
{dirty && <span className="dirty"> <Icon name="dot" className="tiny" /></span>}
|
{dirty && <span className="dirty"> <Icon name="dot" className="tiny" /></span>}
|
||||||
</b>
|
</b>
|
||||||
{(isMd || isImage) && !f.preview && (
|
{(isMd || isImage) && !f.preview && (
|
||||||
<button className="small" onClick={() => setPreview(!preview)}>
|
<Button size="small" onClick={() => setPreview(!preview)}>
|
||||||
{preview ? t("files.edit") : t("files.preview")}
|
{preview ? t("files.edit") : t("files.preview")}
|
||||||
</button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
<a className="button small" href={rawUrl(f.path, true)}>
|
<a className="button small" href={rawUrl(f.path, true)}>
|
||||||
<Icon name="download" />
|
<Icon name="download" />
|
||||||
</a>
|
</a>
|
||||||
{!f.binary && (
|
{!f.binary && (
|
||||||
<button className="small primary" disabled={!dirty} onClick={() => save()}>
|
<Button type="primary" size="small" disabled={!dirty} onClick={() => save()}>
|
||||||
{t("common.save")}
|
{t("common.save")}
|
||||||
</button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
{f.preview ? (
|
{f.preview ? (
|
||||||
@@ -439,23 +441,23 @@ export function Files({ onMenu, embed }: { onMenu?: () => void; embed?: FilesEmb
|
|||||||
<>
|
<>
|
||||||
<div className={embed ? "files-embed-bar" : "topbar"}>
|
<div className={embed ? "files-embed-bar" : "topbar"}>
|
||||||
{!embed && (
|
{!embed && (
|
||||||
<button className="ghost menu-btn" onClick={onMenu} aria-label={t("nav.menu")}>
|
<Button type="text" className="menu-btn" onClick={onMenu} aria-label={t("nav.menu")}>
|
||||||
<Icon name="menu" />
|
<Icon name="menu" />
|
||||||
</button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
<div className="grow">
|
<div className="grow">
|
||||||
{!embed && <h1>{t("nav.files")}</h1>}
|
{!embed && <h1>{t("nav.files")}</h1>}
|
||||||
<div className="path">{listing?.path}</div>
|
<div className="path">{listing?.path}</div>
|
||||||
</div>
|
</div>
|
||||||
{listing?.repo && (
|
{listing?.repo && (
|
||||||
<div className="mode-tabs" role="tablist">
|
<Segmented
|
||||||
<button className={tab === "files" ? "active" : ""} onClick={() => setTab("files")}>
|
value={tab}
|
||||||
{t("files.tabFiles")}
|
onChange={(v) => setTab(v)}
|
||||||
</button>
|
options={[
|
||||||
<button className={tab === "git" ? "active" : ""} onClick={() => setTab("git")}>
|
{ value: "files" as const, label: t("files.tabFiles") },
|
||||||
Git{git && git.files.length > 0 ? ` (${git.files.length})` : ""}
|
{ value: "git" as const, label: `Git${git && git.files.length > 0 ? ` (${git.files.length})` : ""}` },
|
||||||
</button>
|
]}
|
||||||
</div>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className={`files-layout ${mobileEditor ? "show-editor" : ""}`}>
|
<div className={`files-layout ${mobileEditor ? "show-editor" : ""}`}>
|
||||||
@@ -473,11 +475,10 @@ export function Files({ onMenu, embed }: { onMenu?: () => void; embed?: FilesEmb
|
|||||||
)}
|
)}
|
||||||
{!listing?.repo && listing && (
|
{!listing?.repo && listing && (
|
||||||
<div className="git-init">
|
<div className="git-init">
|
||||||
<button className="small" onClick={() => act(() => post("/git", { path: listing.path, action: "init" }))}>
|
<Button size="small" onClick={() => act(() => post("/git", { path: listing.path, action: "init" }))}>
|
||||||
{t("git.init")}
|
{t("git.init")}
|
||||||
</button>
|
</Button>
|
||||||
<button
|
<Button size="small"
|
||||||
className="small"
|
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
const url = await promptDialog({ message: t("git.cloneUrl"), placeholder: "https://…/repo.git" });
|
const url = await promptDialog({ message: t("git.cloneUrl"), placeholder: "https://…/repo.git" });
|
||||||
if (!url) return;
|
if (!url) return;
|
||||||
@@ -486,7 +487,7 @@ export function Files({ onMenu, embed }: { onMenu?: () => void; embed?: FilesEmb
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{t("git.clone")}
|
{t("git.clone")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { Button, Checkbox, Input, Segmented } from "antd";
|
||||||
|
import { Select } from "../ui/Select";
|
||||||
import { Icon } from "./Icon";
|
import { Icon } from "./Icon";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { post } from "../api";
|
import { post } from "../api";
|
||||||
@@ -101,26 +103,26 @@ export function GitPanel({
|
|||||||
return (
|
return (
|
||||||
<div key={`${isStaged}-${f.path}`} className="git-file">
|
<div key={`${isStaged}-${f.path}`} className="git-file">
|
||||||
<span className={`git-mark m-${LABEL[code] ?? code}`}>{LABEL[code] ?? code}</span>
|
<span className={`git-mark m-${LABEL[code] ?? code}`}>{LABEL[code] ?? code}</span>
|
||||||
<button className="ghost git-name" onClick={() => diff(f, isStaged)} title={f.path}>
|
<Button type="text" className="git-name" onClick={() => diff(f, isStaged)} title={f.path}>
|
||||||
{f.path}
|
{f.path}
|
||||||
</button>
|
</Button>
|
||||||
<button className="small ghost" title={t("git.openFile")} onClick={() => openFile(abs(f))}>
|
<Button type="text" size="small" title={t("git.openFile")} onClick={() => openFile(abs(f))}>
|
||||||
<Icon name="external" />
|
<Icon name="external" />
|
||||||
</button>
|
</Button>
|
||||||
{isStaged ? (
|
{isStaged ? (
|
||||||
<button className="small" title={t("git.unstage")} onClick={() => run("unstage", () => call("unstage", { files: [abs(f)] }))}>
|
<Button size="small" title={t("git.unstage")} onClick={() => run("unstage", () => call("unstage", { files: [abs(f)] }))}>
|
||||||
<Icon name="minus" />
|
<Icon name="minus" />
|
||||||
</button>
|
</Button>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
{f.index !== "?" && (
|
{f.index !== "?" && (
|
||||||
<button className="small ghost danger" title={t("git.discard")} onClick={() => void confirmDialog({ message: t("git.discardConfirm", { file: f.path }), danger: true, confirmLabel: t("git.discard") }).then((ok): unknown => ok && run("discard", () => call("discard", { files: [abs(f)] })))}>
|
<Button type="text" danger size="small" title={t("git.discard")} onClick={() => void confirmDialog({ message: t("git.discardConfirm", { file: f.path }), danger: true, confirmLabel: t("git.discard") }).then((ok): unknown => ok && run("discard", () => call("discard", { files: [abs(f)] })))}>
|
||||||
<Icon name="refresh" />
|
<Icon name="refresh" />
|
||||||
</button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
<button className="small" title={t("git.stage")} onClick={() => run("stage", () => call("stage", { files: [abs(f)] }))}>
|
<Button size="small" title={t("git.stage")} onClick={() => run("stage", () => call("stage", { files: [abs(f)] }))}>
|
||||||
+
|
+
|
||||||
</button>
|
</Button>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
@@ -130,7 +132,7 @@ export function GitPanel({
|
|||||||
return (
|
return (
|
||||||
<div className="git-panel">
|
<div className="git-panel">
|
||||||
<div className="git-branch">
|
<div className="git-branch">
|
||||||
<select
|
<Select
|
||||||
value={branches.find((b) => b.current)?.name ?? status.branch ?? ""}
|
value={branches.find((b) => b.current)?.name ?? status.branch ?? ""}
|
||||||
onChange={(e) => run("checkout", () => call("checkout", { branch: e.target.value.replace(/^origin\//, "") }), true)}
|
onChange={(e) => run("checkout", () => call("checkout", { branch: e.target.value.replace(/^origin\//, "") }), true)}
|
||||||
aria-label={t("git.branch")}
|
aria-label={t("git.branch")}
|
||||||
@@ -141,9 +143,8 @@ export function GitPanel({
|
|||||||
{b.name}
|
{b.name}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</Select>
|
||||||
<button
|
<Button size="small"
|
||||||
className="small"
|
|
||||||
title={t("git.newBranch")}
|
title={t("git.newBranch")}
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
const name = await promptDialog({ message: t("git.newBranchName"), placeholder: "feature/…" });
|
const name = await promptDialog({ message: t("git.newBranchName"), placeholder: "feature/…" });
|
||||||
@@ -151,7 +152,7 @@ export function GitPanel({
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
+
|
+
|
||||||
</button>
|
</Button>
|
||||||
{status.upstream && (
|
{status.upstream && (
|
||||||
<span className="chip" title={status.upstream}>
|
<span className="chip" title={status.upstream}>
|
||||||
<Icon name="arrow-up" className="tiny" />{status.ahead} <Icon name="arrow-down" className="tiny" />{status.behind}
|
<Icon name="arrow-up" className="tiny" />{status.ahead} <Icon name="arrow-down" className="tiny" />{status.behind}
|
||||||
@@ -159,21 +160,22 @@ export function GitPanel({
|
|||||||
)}
|
)}
|
||||||
<span className="spacer" />
|
<span className="spacer" />
|
||||||
{(["fetch", "pull", "push"] as const).map((a) => (
|
{(["fetch", "pull", "push"] as const).map((a) => (
|
||||||
<button key={a} className="small" disabled={!!busy} onClick={() => run(a, () => call(a), true)}>
|
<Button size="small" key={a} disabled={!!busy} onClick={() => run(a, () => call(a), true)}>
|
||||||
{busy === a ? <Spinner small /> : t(`git.${a}`)}
|
{busy === a ? <Spinner small /> : t(`git.${a}`)}
|
||||||
</button>
|
</Button>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
{output && <pre className={`git-output ${output.ok ? "" : "err"}`}>{output.text}</pre>}
|
{output && <pre className={`git-output ${output.ok ? "" : "err"}`}>{output.text}</pre>}
|
||||||
|
|
||||||
<div className="mode-tabs" style={{ margin: "8px 0" }}>
|
<Segmented
|
||||||
<button className={view === "changes" ? "active" : ""} onClick={() => setView("changes")}>
|
style={{ margin: "8px 0", alignSelf: "flex-start" }}
|
||||||
{t("git.changes")} ({status.files.length})
|
value={view}
|
||||||
</button>
|
onChange={(v) => setView(v)}
|
||||||
<button className={view === "history" ? "active" : ""} onClick={() => setView("history")}>
|
options={[
|
||||||
{t("git.history")}
|
{ value: "changes" as const, label: `${t("git.changes")} (${status.files.length})` },
|
||||||
</button>
|
{ value: "history" as const, label: t("git.history") },
|
||||||
</div>
|
]}
|
||||||
|
/>
|
||||||
|
|
||||||
{view === "changes" ? (
|
{view === "changes" ? (
|
||||||
<>
|
<>
|
||||||
@@ -181,9 +183,9 @@ export function GitPanel({
|
|||||||
<div className="git-head">
|
<div className="git-head">
|
||||||
{t("git.staged")} ({staged.length})
|
{t("git.staged")} ({staged.length})
|
||||||
{staged.length > 0 && (
|
{staged.length > 0 && (
|
||||||
<button className="small ghost" onClick={() => run("unstage", () => call("unstage", { files: staged.map(abs) }))}>
|
<Button type="text" size="small" onClick={() => run("unstage", () => call("unstage", { files: staged.map(abs) }))}>
|
||||||
{t("git.unstageAll")}
|
{t("git.unstageAll")}
|
||||||
</button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
{staged.map((f) => fileRow(f, true))}
|
{staged.map((f) => fileRow(f, true))}
|
||||||
@@ -192,30 +194,28 @@ export function GitPanel({
|
|||||||
<div className="git-head">
|
<div className="git-head">
|
||||||
{t("git.unstaged")} ({unstaged.length})
|
{t("git.unstaged")} ({unstaged.length})
|
||||||
{unstaged.length > 0 && (
|
{unstaged.length > 0 && (
|
||||||
<button className="small ghost" onClick={() => run("stage", () => call("stage", { files: unstaged.map(abs) }))}>
|
<Button type="text" size="small" onClick={() => run("stage", () => call("stage", { files: unstaged.map(abs) }))}>
|
||||||
{t("git.stageAll")}
|
{t("git.stageAll")}
|
||||||
</button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
{unstaged.map((f) => fileRow(f, false))}
|
{unstaged.map((f) => fileRow(f, false))}
|
||||||
{status.files.length === 0 && <div className="empty" style={{ padding: 12 }}>{t("git.clean")}</div>}
|
{status.files.length === 0 && <div className="empty" style={{ padding: 12 }}>{t("git.clean")}</div>}
|
||||||
</div>
|
</div>
|
||||||
<div className="git-commit">
|
<div className="git-commit">
|
||||||
<textarea rows={3} placeholder={t("git.message")} value={message} onChange={(e) => setMessage(e.target.value)} />
|
<Input.TextArea rows={3} placeholder={t("git.message")} value={message} onChange={(e) => setMessage(e.target.value)} />
|
||||||
<div className="row">
|
<div className="row">
|
||||||
<label style={{ fontSize: 12.5 }}>
|
<Checkbox style={{ fontSize: 12.5 }} checked={amend} onChange={(e) => setAmend(e.target.checked)}> {t("git.amend")}
|
||||||
<input type="checkbox" checked={amend} onChange={(e) => setAmend(e.target.checked)} /> {t("git.amend")}
|
</Checkbox>
|
||||||
</label>
|
|
||||||
<span className="spacer" />
|
<span className="spacer" />
|
||||||
<button
|
<Button
|
||||||
disabled={!!busy || staged.length === 0}
|
disabled={!!busy || staged.length === 0}
|
||||||
title={t("git.suggestHint")}
|
title={t("git.suggestHint")}
|
||||||
onClick={() => run("suggest", async () => setMessage((await call<{ message: string }>("suggest")).message))}
|
onClick={() => run("suggest", async () => setMessage((await call<{ message: string }>("suggest")).message))}
|
||||||
>
|
>
|
||||||
{busy === "suggest" ? <Spinner small /> : t("git.suggest")}
|
{busy === "suggest" ? <Spinner small /> : t("git.suggest")}
|
||||||
</button>
|
</Button>
|
||||||
<button
|
<Button type="primary"
|
||||||
className="primary"
|
|
||||||
disabled={!!busy || (!amend && (!message.trim() || staged.length === 0))}
|
disabled={!!busy || (!amend && (!message.trim() || staged.length === 0))}
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
run(
|
run(
|
||||||
@@ -231,7 +231,7 @@ export function GitPanel({
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
{busy === "commit" ? <Spinner small /> : t("git.commit")}
|
{busy === "commit" ? <Spinner small /> : t("git.commit")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { Button } from "antd";
|
||||||
import { useEffect, useRef, useState } from "react";
|
import { useEffect, useRef, useState } from "react";
|
||||||
import { useT } from "../i18n";
|
import { useT } from "../i18n";
|
||||||
import { toast } from "../dialogs";
|
import { toast } from "../dialogs";
|
||||||
@@ -135,25 +136,25 @@ export function ImageAnnotator({ src, name, onDone, onCancel }: { src: string; n
|
|||||||
/>
|
/>
|
||||||
<div className="annotator-tools" role="toolbar" aria-label={t("viewer.annotate")}>
|
<div className="annotator-tools" role="toolbar" aria-label={t("viewer.annotate")}>
|
||||||
{(["pen", "arrow", "rect"] as Tool[]).map((k) => (
|
{(["pen", "arrow", "rect"] as Tool[]).map((k) => (
|
||||||
<button key={k} className={`small ${tool === k ? "primary" : "ghost"}`} onClick={() => setTool(k)} aria-pressed={tool === k} title={t(`viewer.tool.${k}` as const)}>
|
<Button key={k} size="small" type={tool === k ? "primary" : "text"} onClick={() => setTool(k)} aria-pressed={tool === k} title={t(`viewer.tool.${k}` as const)}>
|
||||||
<Icon name={k === "pen" ? "edit" : k === "arrow" ? "arrow-right" : "box-off"} />
|
<Icon name={k === "pen" ? "edit" : k === "arrow" ? "arrow-right" : "box-off"} />
|
||||||
</button>
|
</Button>
|
||||||
))}
|
))}
|
||||||
<span className="annotator-colors">
|
<span className="annotator-colors">
|
||||||
{COLORS.map((c) => (
|
{COLORS.map((c) => (
|
||||||
<button key={c} className={`swatch ${c === color ? "on" : ""}`} style={{ background: c }} onClick={() => setColor(c)} aria-label={c} aria-pressed={c === color} />
|
<button key={c} className={`swatch ${c === color ? "on" : ""}`} style={{ background: c }} onClick={() => setColor(c)} aria-label={c} aria-pressed={c === color} />
|
||||||
))}
|
))}
|
||||||
</span>
|
</span>
|
||||||
<button className="small ghost" onClick={() => setShapes((s) => s.slice(0, -1))} disabled={!shapes.length} title={t("viewer.undo")} aria-label={t("viewer.undo")}>
|
<Button type="text" size="small" onClick={() => setShapes((s) => s.slice(0, -1))} disabled={!shapes.length} title={t("viewer.undo")} aria-label={t("viewer.undo")}>
|
||||||
<Icon name="undo" />
|
<Icon name="undo" />
|
||||||
</button>
|
</Button>
|
||||||
<span className="grow" />
|
<span className="grow" />
|
||||||
<button className="small" onClick={onCancel}>
|
<Button size="small" onClick={onCancel}>
|
||||||
{t("common.cancel")}
|
{t("common.cancel")}
|
||||||
</button>
|
</Button>
|
||||||
<button className="small primary" onClick={finish} disabled={!ready}>
|
<Button type="primary" size="small" onClick={finish} disabled={!ready}>
|
||||||
<Icon name="clip" /> {t("viewer.attach")}
|
<Icon name="clip" /> {t("viewer.attach")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { Button } from "antd";
|
||||||
import { useCallback, useEffect, useRef, useState } from "react";
|
import { useCallback, useEffect, useRef, useState } from "react";
|
||||||
import { Icon } from "./Icon";
|
import { Icon } from "./Icon";
|
||||||
import { ImageAnnotator } from "./ImageAnnotator";
|
import { ImageAnnotator } from "./ImageAnnotator";
|
||||||
@@ -139,12 +140,12 @@ export function ImageViewer() {
|
|||||||
<span className="viewer-name">{cur.alt && !/^(image|SVG)$/i.test(cur.alt) ? cur.alt : ""}</span>
|
<span className="viewer-name">{cur.alt && !/^(image|SVG)$/i.test(cur.alt) ? cur.alt : ""}</span>
|
||||||
{sessionId && (
|
{sessionId && (
|
||||||
<>
|
<>
|
||||||
<button className="small ghost" onClick={() => setMarking(true)} title={t("viewer.annotate")} aria-label={t("viewer.annotate")}>
|
<Button type="text" size="small" onClick={() => setMarking(true)} title={t("viewer.annotate")} aria-label={t("viewer.annotate")}>
|
||||||
<Icon name="edit" />
|
<Icon name="edit" />
|
||||||
</button>
|
</Button>
|
||||||
<button className="small ghost" onClick={() => void useInChat()} title={t("viewer.useInChat")} aria-label={t("viewer.useInChat")}>
|
<Button type="text" size="small" onClick={() => void useInChat()} title={t("viewer.useInChat")} aria-label={t("viewer.useInChat")}>
|
||||||
<Icon name="reply" />
|
<Icon name="reply" />
|
||||||
</button>
|
</Button>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<a className="button small ghost" href={cur.src} target="_blank" rel="noreferrer" title={t("viewer.open")} aria-label={t("viewer.open")}>
|
<a className="button small ghost" href={cur.src} target="_blank" rel="noreferrer" title={t("viewer.open")} aria-label={t("viewer.open")}>
|
||||||
@@ -153,9 +154,9 @@ export function ImageViewer() {
|
|||||||
<a className="button small ghost" href={cur.src} download title={t("viewer.download")} aria-label={t("viewer.download")}>
|
<a className="button small ghost" href={cur.src} download title={t("viewer.download")} aria-label={t("viewer.download")}>
|
||||||
<Icon name="download" />
|
<Icon name="download" />
|
||||||
</a>
|
</a>
|
||||||
<button className="small ghost" onClick={close} aria-label={t("common.close")}>
|
<Button type="text" size="small" onClick={close} aria-label={t("common.close")}>
|
||||||
<Icon name="close" />
|
<Icon name="close" />
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
{marking && (
|
{marking && (
|
||||||
<ImageAnnotator
|
<ImageAnnotator
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { Button, Input } from "antd";
|
||||||
|
import { Select } from "../ui/Select";
|
||||||
import { Icon } from "./Icon";
|
import { Icon } from "./Icon";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { del, post } from "../api";
|
import { del, post } from "../api";
|
||||||
@@ -63,9 +65,9 @@ export function Images({ onMenu }: { onMenu: () => void }) {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="topbar">
|
<div className="topbar">
|
||||||
<button className="ghost menu-btn" onClick={onMenu} aria-label={t("nav.menu")}>
|
<Button type="text" className="menu-btn" onClick={onMenu} aria-label={t("nav.menu")}>
|
||||||
<Icon name="menu" />
|
<Icon name="menu" />
|
||||||
</button>
|
</Button>
|
||||||
<div className="grow">
|
<div className="grow">
|
||||||
<h1>{t("nav.images")}</h1>
|
<h1>{t("nav.images")}</h1>
|
||||||
</div>
|
</div>
|
||||||
@@ -74,7 +76,7 @@ export function Images({ onMenu }: { onMenu: () => void }) {
|
|||||||
<div className="page-inner">
|
<div className="page-inner">
|
||||||
{cfg && !cfg.enabled && <div className="notice">{t("images.disabled")}</div>}
|
{cfg && !cfg.enabled && <div className="notice">{t("images.disabled")}</div>}
|
||||||
<div className="panel">
|
<div className="panel">
|
||||||
<textarea
|
<Input.TextArea
|
||||||
style={{ width: "100%", minHeight: 90 }}
|
style={{ width: "100%", minHeight: 90 }}
|
||||||
placeholder={t("images.promptPlaceholder")}
|
placeholder={t("images.promptPlaceholder")}
|
||||||
value={form.prompt}
|
value={form.prompt}
|
||||||
@@ -82,42 +84,42 @@ export function Images({ onMenu }: { onMenu: () => void }) {
|
|||||||
onKeyDown={(e) => e.key === "Enter" && (e.ctrlKey || e.metaKey) && form.prompt.trim() && generate()}
|
onKeyDown={(e) => e.key === "Enter" && (e.ctrlKey || e.metaKey) && form.prompt.trim() && generate()}
|
||||||
/>
|
/>
|
||||||
<div className="row" style={{ marginTop: 8 }}>
|
<div className="row" style={{ marginTop: 8 }}>
|
||||||
<select value={form.model} onChange={(e) => setForm({ ...form, model: e.target.value })} aria-label={t("images.model")}>
|
<Select value={form.model} onChange={(e) => setForm({ ...form, model: e.target.value })} aria-label={t("images.model")}>
|
||||||
{cfg?.models.map((m) => (
|
{cfg?.models.map((m) => (
|
||||||
<option key={m.id} value={m.id}>
|
<option key={m.id} value={m.id}>
|
||||||
{m.name}
|
{m.name}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</Select>
|
||||||
<select value={form.size} onChange={(e) => setForm({ ...form, size: e.target.value })} aria-label={t("images.size")}>
|
<Select value={form.size} onChange={(e) => setForm({ ...form, size: e.target.value })} aria-label={t("images.size")}>
|
||||||
{cfg?.sizes.map((s) => (
|
{cfg?.sizes.map((s) => (
|
||||||
<option key={s} value={s}>
|
<option key={s} value={s}>
|
||||||
{t(`images.size.${s}` as Key)}
|
{t(`images.size.${s}` as Key)}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</Select>
|
||||||
<select value={form.count} onChange={(e) => setForm({ ...form, count: Number(e.target.value) })} aria-label={t("images.count")}>
|
<Select value={form.count} onChange={(e) => setForm({ ...form, count: Number(e.target.value) })} aria-label={t("images.count")}>
|
||||||
{[1, 2, 3, 4].map((n) => (
|
{[1, 2, 3, 4].map((n) => (
|
||||||
<option key={n} value={n}>
|
<option key={n} value={n}>
|
||||||
{t("images.countN", { n })}
|
{t("images.countN", { n })}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</Select>
|
||||||
{roots.length > 1 && (
|
{roots.length > 1 && (
|
||||||
<select value={form.root} onChange={(e) => setForm({ ...form, root: e.target.value })} aria-label={t("images.folder")}>
|
<Select value={form.root} onChange={(e) => setForm({ ...form, root: e.target.value })} aria-label={t("images.folder")}>
|
||||||
{roots.map((r) => (
|
{roots.map((r) => (
|
||||||
<option key={r.path} value={r.path}>
|
<option key={r.path} value={r.path}>
|
||||||
{r.name}
|
{r.name}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</Select>
|
||||||
)}
|
)}
|
||||||
<input value={form.folder} onChange={(e) => setForm({ ...form, folder: e.target.value })} title={t("images.folder")} style={{ width: 140 }} />
|
<Input value={form.folder} onChange={(e) => setForm({ ...form, folder: e.target.value })} title={t("images.folder")} style={{ width: 140 }} />
|
||||||
<span className="spacer" />
|
<span className="spacer" />
|
||||||
{price ? <span className="chip">≈ {fmtCost(price * form.count, cfg!.currency)}</span> : null}
|
{price ? <span className="chip">≈ {fmtCost(price * form.count, cfg!.currency)}</span> : null}
|
||||||
<button className="primary" disabled={busy || !form.prompt.trim() || !cfg?.enabled} onClick={generate}>
|
<Button type="primary" disabled={busy || !form.prompt.trim() || !cfg?.enabled} onClick={generate}>
|
||||||
{busy ? <Spinner small /> : null} {busy ? t("images.generating") : t("images.generate")}
|
{busy ? <Spinner small /> : null} {busy ? t("images.generating") : t("images.generate")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
{error && <div className="notice err" style={{ marginTop: 8 }}>{error}</div>}
|
{error && <div className="notice err" style={{ marginTop: 8 }}>{error}</div>}
|
||||||
</div>
|
</div>
|
||||||
@@ -144,15 +146,15 @@ export function Images({ onMenu }: { onMenu: () => void }) {
|
|||||||
<a className="button small" href={fileUrl(img.id)} download={img.path.split("/").pop()}>
|
<a className="button small" href={fileUrl(img.id)} download={img.path.split("/").pop()}>
|
||||||
<Icon name="download" />
|
<Icon name="download" />
|
||||||
</a>
|
</a>
|
||||||
<button className="small" title={t("images.reuse")} onClick={() => setForm({ ...form, prompt: img.prompt, model: img.model })}>
|
<Button size="small" title={t("images.reuse")} onClick={() => setForm({ ...form, prompt: img.prompt, model: img.model })}>
|
||||||
<Icon name="refresh" />
|
<Icon name="refresh" />
|
||||||
</button>
|
</Button>
|
||||||
<button className="small" title={t("images.copyPath")} onClick={() => navigator.clipboard?.writeText(img.path)}>
|
<Button size="small" title={t("images.copyPath")} onClick={() => navigator.clipboard?.writeText(img.path)}>
|
||||||
<Icon name="copy" />
|
<Icon name="copy" />
|
||||||
</button>
|
</Button>
|
||||||
<button className="small danger" title={t("common.delete")} onClick={() => void confirmDialog({ message: t("images.deleteConfirm"), danger: true, confirmLabel: t("common.delete") }).then((ok): unknown => ok && del(`/images/${img.id}`).then(reload))}>
|
<Button danger size="small" title={t("common.delete")} onClick={() => void confirmDialog({ message: t("images.deleteConfirm"), danger: true, confirmLabel: t("common.delete") }).then((ok): unknown => ok && del(`/images/${img.id}`).then(reload))}>
|
||||||
<Icon name="trash" />
|
<Icon name="trash" />
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</figcaption>
|
</figcaption>
|
||||||
</figure>
|
</figure>
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { Button, Input } from "antd";
|
||||||
|
import { Modal } from "../ui/Modal";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { patch } from "../api";
|
import { patch } from "../api";
|
||||||
import { useT } from "../i18n";
|
import { useT } from "../i18n";
|
||||||
@@ -21,13 +23,12 @@ export function InstructionsDialog({ sessionId, value, onClose }: { sessionId: s
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="modal-backdrop" onClick={onClose}>
|
<Modal onClose={onClose} className="instructions-modal" role="dialog" aria-label={t("instructions.title")}>
|
||||||
<div className="modal instructions-modal" role="dialog" aria-label={t("instructions.title")} onClick={(e) => e.stopPropagation()}>
|
|
||||||
<h3>{t("instructions.title")}</h3>
|
<h3>{t("instructions.title")}</h3>
|
||||||
<div className="hint" style={{ marginBottom: 8 }}>
|
<div className="hint" style={{ marginBottom: 8 }}>
|
||||||
{t("instructions.hint")}
|
{t("instructions.hint")}
|
||||||
</div>
|
</div>
|
||||||
<textarea
|
<Input.TextArea
|
||||||
autoFocus
|
autoFocus
|
||||||
rows={10}
|
rows={10}
|
||||||
style={{ width: "100%" }}
|
style={{ width: "100%" }}
|
||||||
@@ -39,17 +40,16 @@ export function InstructionsDialog({ sessionId, value, onClose }: { sessionId: s
|
|||||||
{error && <div className="notice err">{error}</div>}
|
{error && <div className="notice err">{error}</div>}
|
||||||
<div className="row" style={{ marginTop: 10, justifyContent: "flex-end", gap: 6 }}>
|
<div className="row" style={{ marginTop: 10, justifyContent: "flex-end", gap: 6 }}>
|
||||||
{value && (
|
{value && (
|
||||||
<button className="danger" onClick={() => void save("")} disabled={busy}>
|
<Button danger onClick={() => void save("")} disabled={busy}>
|
||||||
{t("instructions.clear")}
|
{t("instructions.clear")}
|
||||||
</button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
<span className="spacer" />
|
<span className="spacer" />
|
||||||
<button onClick={onClose}>{t("common.cancel")}</button>
|
<Button onClick={onClose}>{t("common.cancel")}</Button>
|
||||||
<button className="primary" onClick={() => void save(text)} disabled={busy || text.trim() === value.trim()}>
|
<Button type="primary" onClick={() => void save(text)} disabled={busy || text.trim() === value.trim()}>
|
||||||
{t("common.save")}
|
{t("common.save")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
</Modal>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { Button, Input } from "antd";
|
||||||
import { Icon } from "./Icon";
|
import { Icon } from "./Icon";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { post } from "../api";
|
import { post } from "../api";
|
||||||
@@ -98,12 +99,12 @@ export function PermissionCard({ req, currentId }: { req: PermissionRequest; cur
|
|||||||
<Icon name="sparkle" className="tiny" /> {explanation}
|
<Icon name="sparkle" className="tiny" /> {explanation}
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<button className="small ghost explain-btn" disabled={explaining} onClick={explain}>
|
<Button type="text" size="small" className="explain-btn" disabled={explaining} onClick={explain}>
|
||||||
<Icon name="sparkle" /> {explaining ? t("permission.explaining") : t("permission.explain")}
|
<Icon name="sparkle" /> {explaining ? t("permission.explaining") : t("permission.explain")}
|
||||||
</button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
{explainError && <div className="hint">{explainError}</div>}
|
{explainError && <div className="hint">{explainError}</div>}
|
||||||
<input
|
<Input
|
||||||
style={{ width: "100%", marginTop: 8 }}
|
style={{ width: "100%", marginTop: 8 }}
|
||||||
placeholder={t("permission.feedback")}
|
placeholder={t("permission.feedback")}
|
||||||
value={feedback}
|
value={feedback}
|
||||||
@@ -111,20 +112,20 @@ export function PermissionCard({ req, currentId }: { req: PermissionRequest; cur
|
|||||||
onKeyDown={(e) => e.key === "Enter" && reply("reject")}
|
onKeyDown={(e) => e.key === "Enter" && reply("reject")}
|
||||||
/>
|
/>
|
||||||
<div className="actions">
|
<div className="actions">
|
||||||
<button className="primary" disabled={busy || (hunkCount > 1 && chosen === 0)} onClick={() => reply("once")} autoFocus>
|
<Button type="primary" disabled={busy || (hunkCount > 1 && chosen === 0)} onClick={() => reply("once")} autoFocus>
|
||||||
{partial ? t("permission.applySelected", { k: chosen, n: hunkCount }) : t("permission.allowOnce")}
|
{partial ? t("permission.applySelected", { k: chosen, n: hunkCount }) : t("permission.allowOnce")}
|
||||||
</button>
|
</Button>
|
||||||
<button disabled={busy || partial} onClick={() => reply("always")}>
|
<Button disabled={busy || partial} onClick={() => reply("always")}>
|
||||||
{alwaysLabel}
|
{alwaysLabel}
|
||||||
</button>
|
</Button>
|
||||||
{!dangerous && (
|
{!dangerous && (
|
||||||
<button disabled={busy || partial} onClick={() => reply("project")} title={t("permission.projectHint")}>
|
<Button disabled={busy || partial} onClick={() => reply("project")} title={t("permission.projectHint")}>
|
||||||
{projectLabel}
|
{projectLabel}
|
||||||
</button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
<button className="danger" disabled={busy} onClick={() => reply("reject")}>
|
<Button danger disabled={busy} onClick={() => reply("reject")}>
|
||||||
{feedback ? t("permission.rejectWithFeedback") : t("permission.reject")}
|
{feedback ? t("permission.rejectWithFeedback") : t("permission.reject")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -194,7 +195,7 @@ export function QuestionCard({ req, currentId }: { req: QuestionRequest; current
|
|||||||
<Icon name={q.multi_select ? (isSel ? "box-on" : "box-off") : isSel ? "radio-on" : "radio-off"} />
|
<Icon name={q.multi_select ? (isSel ? "box-on" : "box-off") : isSel ? "radio-on" : "radio-off"} />
|
||||||
<div style={{ flex: 1 }}>
|
<div style={{ flex: 1 }}>
|
||||||
{o.label === OTHER ? (
|
{o.label === OTHER ? (
|
||||||
<input
|
<Input
|
||||||
style={{ width: "100%" }}
|
style={{ width: "100%" }}
|
||||||
placeholder={t("question.other")}
|
placeholder={t("question.other")}
|
||||||
value={other[qi] ?? ""}
|
value={other[qi] ?? ""}
|
||||||
@@ -214,7 +215,7 @@ export function QuestionCard({ req, currentId }: { req: QuestionRequest; current
|
|||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<textarea
|
<Input.TextArea
|
||||||
style={{ width: "100%", marginTop: 6 }}
|
style={{ width: "100%", marginTop: 6 }}
|
||||||
placeholder={t("question.answer")}
|
placeholder={t("question.answer")}
|
||||||
value={other[qi] ?? ""}
|
value={other[qi] ?? ""}
|
||||||
@@ -224,12 +225,12 @@ export function QuestionCard({ req, currentId }: { req: QuestionRequest; current
|
|||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
<div className="actions">
|
<div className="actions">
|
||||||
<button className="primary" disabled={busy || !complete} onClick={() => submit()}>
|
<Button type="primary" disabled={busy || !complete} onClick={() => submit()}>
|
||||||
{t("question.submit")}
|
{t("question.submit")}
|
||||||
</button>
|
</Button>
|
||||||
<button disabled={busy} onClick={() => submit(true)}>
|
<Button disabled={busy} onClick={() => submit(true)}>
|
||||||
{t("question.dismiss")}
|
{t("question.dismiss")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { Button, Checkbox, Input, Segmented } from "antd";
|
||||||
|
import { Select } from "../ui/Select";
|
||||||
import { lazy, Suspense, useCallback, useEffect, useRef, useState } from "react";
|
import { lazy, Suspense, useCallback, useEffect, useRef, useState } from "react";
|
||||||
import { ApiError, get, patch, post, put } from "../api";
|
import { ApiError, get, patch, post, put } from "../api";
|
||||||
import { confirmDialog, toast } from "../dialogs";
|
import { confirmDialog, toast } from "../dialogs";
|
||||||
@@ -174,35 +176,42 @@ export function JobEditor({ id, onMenu }: { id: string; onMenu: () => void }) {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="topbar">
|
<div className="topbar">
|
||||||
<button className="ghost menu-btn" onClick={onMenu} aria-label={t("nav.menu")}>
|
<Button type="text" className="menu-btn" onClick={onMenu} aria-label={t("nav.menu")}>
|
||||||
<Icon name="menu" />
|
<Icon name="menu" />
|
||||||
</button>
|
</Button>
|
||||||
<button className="small ghost" onClick={back} title={t("jobEditor.back")} aria-label={t("jobEditor.back")}>
|
<Button type="text" size="small" onClick={back} title={t("jobEditor.back")} aria-label={t("jobEditor.back")}>
|
||||||
<Icon name="arrow-left" />
|
<Icon name="arrow-left" />
|
||||||
</button>
|
</Button>
|
||||||
<div className="grow">
|
<div className="grow">
|
||||||
<h1>{settings.name || t("nav.jobs")}</h1>
|
<h1>{settings.name || t("nav.jobs")}</h1>
|
||||||
<div className="path mono">{job.path}</div>
|
<div className="path mono">{job.path}</div>
|
||||||
</div>
|
</div>
|
||||||
<label className="switch" title={t(job.enabled ? "jobs.disable" : "jobs.enable")}>
|
<Checkbox className="switch" title={t(job.enabled ? "jobs.disable" : "jobs.enable")} checked={job.enabled} onChange={(e) => void setEnabled(e.target.checked)}>
|
||||||
<input type="checkbox" checked={job.enabled} onChange={(e) => void setEnabled(e.target.checked)} />
|
|
||||||
<span>{t(job.enabled ? "jobs.on" : "jobs.off")}</span>
|
<span>{t(job.enabled ? "jobs.on" : "jobs.off")}</span>
|
||||||
</label>
|
</Checkbox>
|
||||||
<button className="small ghost" onClick={runNow} title={t("jobs.runNow")}>
|
<Button type="text" size="small" onClick={runNow} title={t("jobs.runNow")}>
|
||||||
<Icon name="play" /> <span className="hide-mobile">{t("jobs.runNow")}</span>
|
<Icon name="play" /> <span className="hide-mobile">{t("jobs.runNow")}</span>
|
||||||
</button>
|
</Button>
|
||||||
<button className="small primary" disabled={!dirty || saving} onClick={() => void save()}>
|
<Button type="primary" size="small" disabled={!dirty || saving} onClick={() => void save()}>
|
||||||
{saving ? <Spinner small /> : <Icon name="check" />} {t("common.save")}
|
{saving ? <Spinner small /> : <Icon name="check" />} {t("common.save")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<div className="job-tabs" role="tablist">
|
<div className="job-tabs">
|
||||||
{(["prompt", "settings", "assistant"] as Tab[]).map((x) => (
|
<Segmented<Tab>
|
||||||
<button key={x} role="tab" aria-selected={tab === x} className={tab === x ? "active" : ""} onClick={() => setTab(x)}>
|
block
|
||||||
|
value={tab}
|
||||||
|
onChange={setTab}
|
||||||
|
options={(["prompt", "settings", "assistant"] as Tab[]).map((x) => ({
|
||||||
|
value: x,
|
||||||
|
label: (
|
||||||
|
<>
|
||||||
{t(`jobEditor.tab.${x}` as const)}
|
{t(`jobEditor.tab.${x}` as const)}
|
||||||
{x === "prompt" && fileDirty && " •"}
|
{x === "prompt" && fileDirty && " •"}
|
||||||
{x === "settings" && settingsDirty && " •"}
|
{x === "settings" && settingsDirty && " •"}
|
||||||
</button>
|
</>
|
||||||
))}
|
),
|
||||||
|
}))}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className={`job-editor tab-${tab}`}>
|
<div className={`job-editor tab-${tab}`}>
|
||||||
<div className="job-editor-main">
|
<div className="job-editor-main">
|
||||||
@@ -210,7 +219,7 @@ export function JobEditor({ id, onMenu }: { id: string; onMenu: () => void }) {
|
|||||||
<div className="job-editor-row">
|
<div className="job-editor-row">
|
||||||
<label className="field" style={{ flex: 2 }}>
|
<label className="field" style={{ flex: 2 }}>
|
||||||
<span>{t("jobs.tplName")}</span>
|
<span>{t("jobs.tplName")}</span>
|
||||||
<input value={settings.name} onChange={(e) => up({ name: e.target.value })} />
|
<Input value={settings.name} onChange={(e) => up({ name: e.target.value })} />
|
||||||
</label>
|
</label>
|
||||||
<div className="job-editor-status">
|
<div className="job-editor-status">
|
||||||
<span>
|
<span>
|
||||||
@@ -233,19 +242,19 @@ export function JobEditor({ id, onMenu }: { id: string; onMenu: () => void }) {
|
|||||||
<div className="job-editor-row">
|
<div className="job-editor-row">
|
||||||
<label className="field">
|
<label className="field">
|
||||||
<span>{t("jobs.tplMode")}</span>
|
<span>{t("jobs.tplMode")}</span>
|
||||||
<select value={settings.agent} onChange={(e) => up({ agent: e.target.value })}>
|
<Select value={settings.agent} onChange={(e) => up({ agent: e.target.value })}>
|
||||||
<option value="build">build</option>
|
<option value="build">build</option>
|
||||||
<option value="plan">plan</option>
|
<option value="plan">plan</option>
|
||||||
</select>
|
</Select>
|
||||||
</label>
|
</label>
|
||||||
<label className="field">
|
<label className="field">
|
||||||
<span>{t("jobs.permissionMode")}</span>
|
<span>{t("jobs.permissionMode")}</span>
|
||||||
<select value={settings.permission_mode} title={t("jobs.permissionModeHint")} onChange={(e) => up({ permission_mode: e.target.value })}>
|
<Select value={settings.permission_mode} title={t("jobs.permissionModeHint")} onChange={(e) => up({ permission_mode: e.target.value })}>
|
||||||
<option value="default">{t("permissionMode.default")}</option>
|
<option value="default">{t("permissionMode.default")}</option>
|
||||||
<option value="auto">{t("permissionMode.auto")}</option>
|
<option value="auto">{t("permissionMode.auto")}</option>
|
||||||
<option value="accept_edits">{t("permissionMode.accept_edits")}</option>
|
<option value="accept_edits">{t("permissionMode.accept_edits")}</option>
|
||||||
<option value="bypass">{t("permissionMode.bypass")}</option>
|
<option value="bypass">{t("permissionMode.bypass")}</option>
|
||||||
</select>
|
</Select>
|
||||||
</label>
|
</label>
|
||||||
<label className="field">
|
<label className="field">
|
||||||
<span>{t("composer.model")}</span>
|
<span>{t("composer.model")}</span>
|
||||||
@@ -253,13 +262,12 @@ export function JobEditor({ id, onMenu }: { id: string; onMenu: () => void }) {
|
|||||||
</label>
|
</label>
|
||||||
<label className="field" style={{ maxWidth: 140 }}>
|
<label className="field" style={{ maxWidth: 140 }}>
|
||||||
<span>{t("jobEditor.timeout")}</span>
|
<span>{t("jobEditor.timeout")}</span>
|
||||||
<input type="number" min={1} max={1440} value={settings.timeout_minutes} onChange={(e) => up({ timeout_minutes: Math.max(1, Number(e.target.value) || 60) })} />
|
<Input type="number" min={1} max={1440} value={settings.timeout_minutes} onChange={(e) => up({ timeout_minutes: Math.max(1, Number(e.target.value) || 60) })} />
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<label className="row" style={{ gap: 6, alignItems: "center", marginTop: 6 }}>
|
<Checkbox className="row" style={{ gap: 6, alignItems: "center", marginTop: 6 }} checked={settings.notify} onChange={(e) => up({ notify: e.target.checked })}>
|
||||||
<input type="checkbox" checked={settings.notify} onChange={(e) => up({ notify: e.target.checked })} />
|
|
||||||
{t("jobEditor.notify")}
|
{t("jobEditor.notify")}
|
||||||
</label>
|
</Checkbox>
|
||||||
{settings.permission_mode !== "bypass" && <div className="hint">{t("jobEditor.bypassHint")}</div>}
|
{settings.permission_mode !== "bypass" && <div className="hint">{t("jobEditor.bypassHint")}</div>}
|
||||||
</section>
|
</section>
|
||||||
<section className="job-editor-prompt">
|
<section className="job-editor-prompt">
|
||||||
@@ -270,9 +278,9 @@ export function JobEditor({ id, onMenu }: { id: string; onMenu: () => void }) {
|
|||||||
{changedOnDisk && (
|
{changedOnDisk && (
|
||||||
<div className="notice">
|
<div className="notice">
|
||||||
{t("jobEditor.changedOnDisk")}{" "}
|
{t("jobEditor.changedOnDisk")}{" "}
|
||||||
<button className="small" onClick={() => void loadFile(job.path)}>
|
<Button size="small" onClick={() => void loadFile(job.path)}>
|
||||||
{t("jobEditor.reload")}
|
{t("jobEditor.reload")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{job.error && !job.error.includes("empty") && <div className="notice err">{job.error}</div>}
|
{job.error && !job.error.includes("empty") && <div className="notice err">{job.error}</div>}
|
||||||
@@ -292,9 +300,9 @@ export function JobEditor({ id, onMenu }: { id: string; onMenu: () => void }) {
|
|||||||
<div className="job-assistant-start">
|
<div className="job-assistant-start">
|
||||||
<Icon name="sparkle" />
|
<Icon name="sparkle" />
|
||||||
<p>{t("jobEditor.assistantIntro")}</p>
|
<p>{t("jobEditor.assistantIntro")}</p>
|
||||||
<button className="primary" onClick={startAssistant}>
|
<Button type="primary" onClick={startAssistant}>
|
||||||
{t("jobEditor.assistantStart")}
|
{t("jobEditor.assistantStart")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</aside>
|
</aside>
|
||||||
|
|||||||
+20
-23
@@ -1,3 +1,4 @@
|
|||||||
|
import { Button, Checkbox, Input } from "antd";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { del, get, patch, post } from "../api";
|
import { del, get, patch, post } from "../api";
|
||||||
import { fmtRelative, useT } from "../i18n";
|
import { fmtRelative, useT } from "../i18n";
|
||||||
@@ -56,9 +57,9 @@ export function Jobs({ onMenu }: { onMenu: () => void }) {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="topbar">
|
<div className="topbar">
|
||||||
<button className="ghost menu-btn" onClick={onMenu} aria-label={t("nav.menu")}>
|
<Button type="text" className="menu-btn" onClick={onMenu} aria-label={t("nav.menu")}>
|
||||||
<Icon name="menu" />
|
<Icon name="menu" />
|
||||||
</button>
|
</Button>
|
||||||
<div className="grow">
|
<div className="grow">
|
||||||
<h1>{t("nav.jobs")}</h1>
|
<h1>{t("nav.jobs")}</h1>
|
||||||
</div>
|
</div>
|
||||||
@@ -67,9 +68,9 @@ export function Jobs({ onMenu }: { onMenu: () => void }) {
|
|||||||
<div className="page-inner" style={{ maxWidth: 980 }}>
|
<div className="page-inner" style={{ maxWidth: 980 }}>
|
||||||
<div className="notice">{t("jobs.intro")}</div>
|
<div className="notice">{t("jobs.intro")}</div>
|
||||||
<div className="row" style={{ margin: "12px 0" }}>
|
<div className="row" style={{ margin: "12px 0" }}>
|
||||||
<button className="primary" onClick={() => setTemplates(true)}>
|
<Button type="primary" onClick={() => setTemplates(true)}>
|
||||||
<Icon name="plus" /> {t("jobs.new")}
|
<Icon name="plus" /> {t("jobs.new")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
{templates && <NewJobDialog onClose={() => setTemplates(false)} />}
|
{templates && <NewJobDialog onClose={() => setTemplates(false)} />}
|
||||||
{!jobs && <div className="empty"><Spinner /></div>}
|
{!jobs && <div className="empty"><Spinner /></div>}
|
||||||
@@ -86,10 +87,9 @@ export function Jobs({ onMenu }: { onMenu: () => void }) {
|
|||||||
</h3>
|
</h3>
|
||||||
<div className="hint mono">{j.path}</div>
|
<div className="hint mono">{j.path}</div>
|
||||||
</div>
|
</div>
|
||||||
<label className="switch" title={t(j.enabled ? "jobs.disable" : "jobs.enable")}>
|
<Checkbox className="switch" title={t(j.enabled ? "jobs.disable" : "jobs.enable")} checked={j.enabled} onChange={(e) => act(j.id, () => patch(`/jobs/${j.id}`, { enabled: e.target.checked }))}>
|
||||||
<input type="checkbox" checked={j.enabled} onChange={(e) => act(j.id, () => patch(`/jobs/${j.id}`, { enabled: e.target.checked }))} />
|
|
||||||
<span>{t(j.enabled ? "jobs.on" : "jobs.off")}</span>
|
<span>{t(j.enabled ? "jobs.on" : "jobs.off")}</span>
|
||||||
</label>
|
</Checkbox>
|
||||||
</div>
|
</div>
|
||||||
{j.error ? (
|
{j.error ? (
|
||||||
<div className="notice err">{j.error}</div>
|
<div className="notice err">{j.error}</div>
|
||||||
@@ -126,8 +126,7 @@ export function Jobs({ onMenu }: { onMenu: () => void }) {
|
|||||||
<span>
|
<span>
|
||||||
<Icon name="external" /> {t("jobs.webhook")}: {j.webhook ? t("jobs.on") : t("jobs.off")}
|
<Icon name="external" /> {t("jobs.webhook")}: {j.webhook ? t("jobs.on") : t("jobs.off")}
|
||||||
</span>
|
</span>
|
||||||
<button
|
<Button type="text" size="small"
|
||||||
className="small ghost"
|
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
act(j.id, async () => {
|
act(j.id, async () => {
|
||||||
const r = await post<{ url?: string; secret?: string }>(`/jobs/${j.id}/webhook`, { enable: !j.webhook });
|
const r = await post<{ url?: string; secret?: string }>(`/jobs/${j.id}/webhook`, { enable: !j.webhook });
|
||||||
@@ -136,10 +135,9 @@ export function Jobs({ onMenu }: { onMenu: () => void }) {
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
{j.webhook ? t("jobs.webhookOff") : t("jobs.webhookOn")}
|
{j.webhook ? t("jobs.webhookOff") : t("jobs.webhookOn")}
|
||||||
</button>
|
</Button>
|
||||||
{j.webhook && (
|
{j.webhook && (
|
||||||
<button
|
<Button type="text" size="small"
|
||||||
className="small ghost"
|
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
act(j.id, async () => {
|
act(j.id, async () => {
|
||||||
const r = await post<{ url: string; secret: string }>(`/jobs/${j.id}/webhook`, { enable: true });
|
const r = await post<{ url: string; secret: string }>(`/jobs/${j.id}/webhook`, { enable: true });
|
||||||
@@ -148,7 +146,7 @@ export function Jobs({ onMenu }: { onMenu: () => void }) {
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
{t("jobs.webhookRenew")}
|
{t("jobs.webhookRenew")}
|
||||||
</button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
{hook?.id === j.id && (
|
{hook?.id === j.id && (
|
||||||
@@ -161,24 +159,23 @@ export function Jobs({ onMenu }: { onMenu: () => void }) {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div className="row" style={{ gap: 8, marginTop: 10 }}>
|
<div className="row" style={{ gap: 8, marginTop: 10 }}>
|
||||||
<button className="small" disabled={busy === j.id || !!j.error} onClick={() => act(j.id, async () => {
|
<Button size="small" disabled={busy === j.id || !!j.error} onClick={() => act(j.id, async () => {
|
||||||
const r = await post<{ session_id: string }>(`/jobs/${j.id}/run`, {});
|
const r = await post<{ session_id: string }>(`/jobs/${j.id}/run`, {});
|
||||||
navigate(`/s/${r.session_id}`);
|
navigate(`/s/${r.session_id}`);
|
||||||
})}>
|
})}>
|
||||||
{busy === j.id ? <Spinner small /> : <Icon name="play" />} {t("jobs.runNow")}
|
{busy === j.id ? <Spinner small /> : <Icon name="play" />} {t("jobs.runNow")}
|
||||||
</button>
|
</Button>
|
||||||
<button className="small" onClick={() => navigate(`/jobs/${j.id}`)}>
|
<Button size="small" onClick={() => navigate(`/jobs/${j.id}`)}>
|
||||||
<Icon name="edit" /> {t("jobs.edit")}
|
<Icon name="edit" /> {t("jobs.edit")}
|
||||||
</button>
|
</Button>
|
||||||
<span className="grow" />
|
<span className="grow" />
|
||||||
<button
|
<Button type="text" danger size="small"
|
||||||
className="small ghost danger"
|
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
if (await confirmDialog({ message: t("jobs.deleteConfirm", { name: j.spec?.name ?? j.path }), danger: true })) void act(j.id, () => del(`/jobs/${j.id}`));
|
if (await confirmDialog({ message: t("jobs.deleteConfirm", { name: j.spec?.name ?? j.path }), danger: true })) void act(j.id, () => del(`/jobs/${j.id}`));
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Icon name="trash" /> {t("jobs.remove")}
|
<Icon name="trash" /> {t("jobs.remove")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
@@ -186,14 +183,14 @@ export function Jobs({ onMenu }: { onMenu: () => void }) {
|
|||||||
<h3>{t("jobs.register")}</h3>
|
<h3>{t("jobs.register")}</h3>
|
||||||
<div className="hint" style={{ marginBottom: 8 }}>{t("jobs.registerHint")}</div>
|
<div className="hint" style={{ marginBottom: 8 }}>{t("jobs.registerHint")}</div>
|
||||||
<div className="row" style={{ gap: 8 }}>
|
<div className="row" style={{ gap: 8 }}>
|
||||||
<input className="mono" style={{ flex: 1, minWidth: 0 }} value={path} placeholder="/workspace/project/.codecraft/jobs/nightly.md" onChange={(e) => setPath(e.target.value)} />
|
<Input className="mono" style={{ flex: 1, minWidth: 0 }} value={path} placeholder="/workspace/project/.codecraft/jobs/nightly.md" onChange={(e) => setPath(e.target.value)} />
|
||||||
<button disabled={!path.trim()} onClick={() => act("new", async () => {
|
<Button disabled={!path.trim()} onClick={() => act("new", async () => {
|
||||||
const j = await post<JobInfo>("/jobs", { path: path.trim() });
|
const j = await post<JobInfo>("/jobs", { path: path.trim() });
|
||||||
setPath("");
|
setPath("");
|
||||||
navigate(`/jobs/${j.id}`);
|
navigate(`/jobs/${j.id}`);
|
||||||
})}>
|
})}>
|
||||||
{t("jobs.registerBtn")}
|
{t("jobs.registerBtn")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { Button, Input } from "antd";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { post } from "../api";
|
import { post } from "../api";
|
||||||
import { useT } from "../i18n";
|
import { useT } from "../i18n";
|
||||||
@@ -35,14 +36,14 @@ export function Login({ info, onSuccess }: { info: Info; onSuccess: () => void }
|
|||||||
<img src="/icon.svg" alt="" />
|
<img src="/icon.svg" alt="" />
|
||||||
<h2 style={{ margin: 0 }}>CodeCraft</h2>
|
<h2 style={{ margin: 0 }}>CodeCraft</h2>
|
||||||
<div style={{ color: "var(--fg3)" }}>{setup ? t("login.setupPrompt") : t("login.prompt")}</div>
|
<div style={{ color: "var(--fg3)" }}>{setup ? t("login.setupPrompt") : t("login.prompt")}</div>
|
||||||
{setup && <input autoFocus placeholder={t("login.setupCode")} value={form.code} onChange={set("code")} autoComplete="one-time-code" />}
|
{setup && <Input autoFocus placeholder={t("login.setupCode")} value={form.code} onChange={set("code")} autoComplete="one-time-code" />}
|
||||||
<input autoFocus={!setup} placeholder={t("login.username")} value={form.username} onChange={set("username")} autoComplete="username" autoCapitalize="none" />
|
<Input autoFocus={!setup} placeholder={t("login.username")} value={form.username} onChange={set("username")} autoComplete="username" autoCapitalize="none" />
|
||||||
<input type="password" placeholder={t("login.password")} value={form.password} onChange={set("password")} autoComplete={setup ? "new-password" : "current-password"} />
|
<Input.Password placeholder={t("login.password")} value={form.password} onChange={set("password")} autoComplete={setup ? "new-password" : "current-password"} />
|
||||||
{setup && <input type="password" placeholder={t("login.passwordRepeat")} value={form.password2} onChange={set("password2")} autoComplete="new-password" />}
|
{setup && <Input.Password placeholder={t("login.passwordRepeat")} value={form.password2} onChange={set("password2")} autoComplete="new-password" />}
|
||||||
{error && <div style={{ color: "var(--red)" }}>{error}</div>}
|
{error && <div style={{ color: "var(--red)" }}>{error}</div>}
|
||||||
<button className="primary" type="submit" disabled={busy || !form.username || !form.password}>
|
<Button type="primary" htmlType="submit" disabled={busy || !form.username || !form.password}>
|
||||||
{setup ? t("login.createAdmin") : t("login.submit")}
|
{setup ? t("login.createAdmin") : t("login.submit")}
|
||||||
</button>
|
</Button>
|
||||||
{!setup && info.oidc && (
|
{!setup && info.oidc && (
|
||||||
<>
|
<>
|
||||||
<div style={{ color: "var(--muted)", fontSize: 12 }}>{t("login.or")}</div>
|
<div style={{ color: "var(--muted)", fontSize: 12 }}>{t("login.or")}</div>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { Button } from "antd";
|
||||||
import { Icon } from "./Icon";
|
import { Icon } from "./Icon";
|
||||||
import { memo, useState, type ReactNode } from "react";
|
import { memo, useState, type ReactNode } from "react";
|
||||||
import ReactMarkdown from "react-markdown";
|
import ReactMarkdown from "react-markdown";
|
||||||
@@ -36,9 +37,9 @@ export function SvgBlock({ code, children }: { code: string; children?: ReactNod
|
|||||||
<FileFigure name="inline.svg" size={new Blob([code]).size} mime="image/svg+xml">
|
<FileFigure name="inline.svg" size={new Blob([code]).size} mime="image/svg+xml">
|
||||||
<img src={url} alt="SVG" />
|
<img src={url} alt="SVG" />
|
||||||
</FileFigure>
|
</FileFigure>
|
||||||
<button className="small ghost" onClick={() => setShowCode(!showCode)}>
|
<Button type="text" size="small" onClick={() => setShowCode(!showCode)}>
|
||||||
<Icon name={showCode ? "chevron-down" : "chevron-right"} /> SVG
|
<Icon name={showCode ? "chevron-down" : "chevron-right"} /> SVG
|
||||||
</button>
|
</Button>
|
||||||
{showCode && children}
|
{showCode && children}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { Button } from "antd";
|
||||||
|
import { Modal } from "../ui/Modal";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { get } from "../api";
|
import { get } from "../api";
|
||||||
import { useT, type Key } from "../i18n";
|
import { useT, type Key } from "../i18n";
|
||||||
@@ -58,22 +60,21 @@ export function MediaGallery({ sessionId, onClose, onJump }: { sessionId: string
|
|||||||
}, [current, shown.length, onClose]);
|
}, [current, shown.length, onClose]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="modal-backdrop" onClick={onClose}>
|
<Modal onClose={onClose} className="media-gallery" role="dialog" aria-label={t("media.title")}>
|
||||||
<div className="modal media-gallery" role="dialog" aria-label={t("media.title")} onClick={(e) => e.stopPropagation()}>
|
|
||||||
<div className="media-head">
|
<div className="media-head">
|
||||||
<h3>
|
<h3>
|
||||||
<Icon name="image" /> {t("media.title")}
|
<Icon name="image" /> {t("media.title")}
|
||||||
</h3>
|
</h3>
|
||||||
<div className="media-filters" role="radiogroup">
|
<div className="media-filters" role="radiogroup">
|
||||||
{(["all", "image", "video", "audio", "model"] as Filter[]).map((k) => (
|
{(["all", "image", "video", "audio", "model"] as Filter[]).map((k) => (
|
||||||
<button key={k} role="radio" aria-checked={filter === k} className={`chip-btn ${filter === k ? "active" : ""}`} onClick={() => (setFilter(k), setOpen(undefined))} disabled={!!items && count(k) === 0 && k !== "all"}>
|
<Button key={k} role="radio" aria-checked={filter === k} size="small" shape="round" type={filter === k ? "primary" : "default"} onClick={() => (setFilter(k), setOpen(undefined))} disabled={!!items && count(k) === 0 && k !== "all"}>
|
||||||
{t(`media.filter.${k}` as Key)} {items && <small>{count(k)}</small>}
|
{t(`media.filter.${k}` as Key)} {items && <small>{count(k)}</small>}
|
||||||
</button>
|
</Button>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
<button className="small ghost" onClick={onClose} aria-label={t("common.close")}>
|
<Button type="text" size="small" onClick={onClose} aria-label={t("common.close")}>
|
||||||
<Icon name="close" />
|
<Icon name="close" />
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
{error && <div className="notice err">{error}</div>}
|
{error && <div className="notice err">{error}</div>}
|
||||||
{!items && !error && (
|
{!items && !error && (
|
||||||
@@ -92,34 +93,34 @@ export function MediaGallery({ sessionId, onClose, onJump }: { sessionId: string
|
|||||||
<div className="media-model">
|
<div className="media-model">
|
||||||
{current.preview ? <img src={current.preview} alt={current.name} /> : <Icon name="cube" />}
|
{current.preview ? <img src={current.preview} alt={current.name} /> : <Icon name="cube" />}
|
||||||
{current.path && (
|
{current.path && (
|
||||||
<button className="primary" onClick={() => open3d(current.path!)}>
|
<Button type="primary" onClick={() => open3d(current.path!)}>
|
||||||
<Icon name="cube" /> {t("tool.open3d")}
|
<Icon name="cube" /> {t("tool.open3d")}
|
||||||
</button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="media-bar">
|
<div className="media-bar">
|
||||||
<button className="small ghost" disabled={open === 0} onClick={() => setOpen((o) => (o ?? 1) - 1)} aria-label={t("media.prev")}>
|
<Button type="text" size="small" disabled={open === 0} onClick={() => setOpen((o) => (o ?? 1) - 1)} aria-label={t("media.prev")}>
|
||||||
<Icon name="arrow-left" />
|
<Icon name="arrow-left" />
|
||||||
</button>
|
</Button>
|
||||||
<span className="grow">
|
<span className="grow">
|
||||||
{current.name} · {t(`media.source.${current.source}` as Key)} · {new Date(current.created_at).toLocaleString(undefined, { dateStyle: "short", timeStyle: "short" })}
|
{current.name} · {t(`media.source.${current.source}` as Key)} · {new Date(current.created_at).toLocaleString(undefined, { dateStyle: "short", timeStyle: "short" })}
|
||||||
</span>
|
</span>
|
||||||
{current.message_id && (
|
{current.message_id && (
|
||||||
<button className="small" onClick={() => onJump(current.message_id!)}>
|
<Button size="small" onClick={() => onJump(current.message_id!)}>
|
||||||
{t("media.showInChat")}
|
{t("media.showInChat")}
|
||||||
</button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
<a className="small button" href={current.url} target="_blank" rel="noreferrer">
|
<a className="small button" href={current.url} target="_blank" rel="noreferrer">
|
||||||
<Icon name="external" /> {t("media.open")}
|
<Icon name="external" /> {t("media.open")}
|
||||||
</a>
|
</a>
|
||||||
<button className="small ghost" disabled={open === shown.length - 1} onClick={() => setOpen((o) => (o ?? 0) + 1)} aria-label={t("media.next")}>
|
<Button type="text" size="small" disabled={open === shown.length - 1} onClick={() => setOpen((o) => (o ?? 0) + 1)} aria-label={t("media.next")}>
|
||||||
<Icon name="arrow-right" />
|
<Icon name="arrow-right" />
|
||||||
</button>
|
</Button>
|
||||||
<button className="small ghost" onClick={() => setOpen(undefined)} aria-label={t("media.back")}>
|
<Button type="text" size="small" onClick={() => setOpen(undefined)} aria-label={t("media.back")}>
|
||||||
<Icon name="close" />
|
<Icon name="close" />
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
@@ -149,7 +150,6 @@ export function MediaGallery({ sessionId, onClose, onJump }: { sessionId: string
|
|||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</Modal>
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { Select } from "../ui/Select";
|
||||||
import { useModels, modelOptions } from "../hooks";
|
import { useModels, modelOptions } from "../hooks";
|
||||||
|
|
||||||
/** Model picker; keeps unknown current values selectable. */
|
/** Model picker; keeps unknown current values selectable. */
|
||||||
@@ -5,7 +6,7 @@ export function ModelSelect({ value, onChange, title, emptyLabel }: { value: str
|
|||||||
const options = modelOptions(useModels());
|
const options = modelOptions(useModels());
|
||||||
const known = options.some((o) => o.value === value);
|
const known = options.some((o) => o.value === value);
|
||||||
return (
|
return (
|
||||||
<select value={value} onChange={(e) => onChange(e.target.value)} title={title}>
|
<Select value={value} onChange={(e) => onChange(e.target.value)} title={title}>
|
||||||
{emptyLabel !== undefined && <option value="">{emptyLabel}</option>}
|
{emptyLabel !== undefined && <option value="">{emptyLabel}</option>}
|
||||||
{!known && value && <option value={value}>{value}</option>}
|
{!known && value && <option value={value}>{value}</option>}
|
||||||
{options.map((o) => (
|
{options.map((o) => (
|
||||||
@@ -13,6 +14,6 @@ export function ModelSelect({ value, onChange, title, emptyLabel }: { value: str
|
|||||||
{o.label}
|
{o.label}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</Select>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { Button, Input } from "antd";
|
||||||
|
import { Modal } from "../ui/Modal";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { post } from "../api";
|
import { post } from "../api";
|
||||||
import { getLang, useT } from "../i18n";
|
import { getLang, useT } from "../i18n";
|
||||||
@@ -82,12 +84,11 @@ export function NewJobDialog({ onClose }: { onClose: () => void }) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="modal-backdrop" onClick={onClose}>
|
<Modal onClose={onClose} className="job-tpl" role="dialog" aria-label={t("jobs.new")}>
|
||||||
<div className="modal job-tpl" role="dialog" aria-label={t("jobs.new")} onClick={(e) => e.stopPropagation()}>
|
|
||||||
<h3>{t("jobs.new")}</h3>
|
<h3>{t("jobs.new")}</h3>
|
||||||
<label className="field">
|
<label className="field">
|
||||||
<span>{t("jobs.tplName")}</span>
|
<span>{t("jobs.tplName")}</span>
|
||||||
<input autoFocus value={name} placeholder={t("jobs.namePlaceholder")} onChange={(e) => setName(e.target.value)} />
|
<Input autoFocus value={name} placeholder={t("jobs.namePlaceholder")} onChange={(e) => setName(e.target.value)} />
|
||||||
</label>
|
</label>
|
||||||
<div className="field">
|
<div className="field">
|
||||||
<span>{t("jobs.tplProject")}</span>
|
<span>{t("jobs.tplProject")}</span>
|
||||||
@@ -117,12 +118,11 @@ export function NewJobDialog({ onClose }: { onClose: () => void }) {
|
|||||||
</div>
|
</div>
|
||||||
{error && <div className="notice err">{error}</div>}
|
{error && <div className="notice err">{error}</div>}
|
||||||
<div className="row" style={{ marginTop: 12, justifyContent: "flex-end" }}>
|
<div className="row" style={{ marginTop: 12, justifyContent: "flex-end" }}>
|
||||||
<button onClick={onClose}>{t("common.cancel")}</button>
|
<Button onClick={onClose}>{t("common.cancel")}</Button>
|
||||||
<button className="primary" disabled={busy || !cwd || !name.trim()} onClick={create}>
|
<Button type="primary" disabled={busy || !cwd || !name.trim()} onClick={create}>
|
||||||
{t("jobs.createAndEdit")}
|
{t("jobs.createAndEdit")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
</Modal>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { Button, Checkbox, Input, Segmented } from "antd";
|
||||||
|
import { Select } from "../ui/Select";
|
||||||
import { Icon } from "./Icon";
|
import { Icon } from "./Icon";
|
||||||
import { useEffect, useMemo, useRef, useState, type ReactNode } from "react";
|
import { useEffect, useMemo, useRef, useState, type ReactNode } from "react";
|
||||||
import { post } from "../api";
|
import { post } from "../api";
|
||||||
@@ -353,9 +355,9 @@ export function NewSession({ onMenu, onCreated }: { onMenu: () => void; onCreate
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="topbar">
|
<div className="topbar">
|
||||||
<button className="ghost menu-btn" onClick={onMenu} aria-label={t("nav.menu")}>
|
<Button type="text" className="menu-btn" onClick={onMenu} aria-label={t("nav.menu")}>
|
||||||
<Icon name="menu" />
|
<Icon name="menu" />
|
||||||
</button>
|
</Button>
|
||||||
<div className="grow">
|
<div className="grow">
|
||||||
<h1>{t("new.title")}</h1>
|
<h1>{t("new.title")}</h1>
|
||||||
</div>
|
</div>
|
||||||
@@ -433,9 +435,9 @@ export function NewSession({ onMenu, onCreated }: { onMenu: () => void; onCreate
|
|||||||
<i style={{ width: `${Math.round(progress[f.name] * 100)}%` }} />
|
<i style={{ width: `${Math.round(progress[f.name] * 100)}%` }} />
|
||||||
</span>
|
</span>
|
||||||
) : (
|
) : (
|
||||||
<button className="small ghost" onClick={() => setOriginals((c) => c.filter((_, j) => j !== i))} aria-label={t("common.remove")}>
|
<Button type="text" size="small" onClick={() => setOriginals((c) => c.filter((_, j) => j !== i))} aria-label={t("common.remove")}>
|
||||||
<Icon name="close" />
|
<Icon name="close" />
|
||||||
</button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
@@ -446,7 +448,7 @@ export function NewSession({ onMenu, onCreated }: { onMenu: () => void; onCreate
|
|||||||
|
|
||||||
<Step n={n++} title={t("wizard.sayWhat")}>
|
<Step n={n++} title={t("wizard.sayWhat")}>
|
||||||
{needsUrl && (
|
{needsUrl && (
|
||||||
<input
|
<Input
|
||||||
className="wiz-url"
|
className="wiz-url"
|
||||||
type="url"
|
type="url"
|
||||||
value={url}
|
value={url}
|
||||||
@@ -462,7 +464,7 @@ export function NewSession({ onMenu, onCreated }: { onMenu: () => void; onCreate
|
|||||||
void addFiles(e.dataTransfer.files);
|
void addFiles(e.dataTransfer.files);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<textarea
|
<Input.TextArea
|
||||||
value={text}
|
value={text}
|
||||||
placeholder={t(task === "craft" ? (`wizard.placeholder.${target}` as Key) : task === "cad" ? "wizard.placeholder.cad" : task === "chat" ? "wizard.placeholder.chat" : "wizard.placeholder.task")}
|
placeholder={t(task === "craft" ? (`wizard.placeholder.${target}` as Key) : task === "cad" ? "wizard.placeholder.cad" : task === "chat" ? "wizard.placeholder.chat" : "wizard.placeholder.task")}
|
||||||
onChange={(e) => setText(e.target.value)}
|
onChange={(e) => setText(e.target.value)}
|
||||||
@@ -484,26 +486,26 @@ export function NewSession({ onMenu, onCreated }: { onMenu: () => void; onCreate
|
|||||||
{images.map((img, i) => (
|
{images.map((img, i) => (
|
||||||
<div className="att" key={`i${i}`}>
|
<div className="att" key={`i${i}`}>
|
||||||
<img src={imageSrc(img)} alt="" />
|
<img src={imageSrc(img)} alt="" />
|
||||||
<button onClick={() => setImages((c) => c.filter((_, j) => j !== i))} aria-label={t("common.remove")}>
|
<Button onClick={() => setImages((c) => c.filter((_, j) => j !== i))} aria-label={t("common.remove")}>
|
||||||
<Icon name="close" />
|
<Icon name="close" />
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
{files.map((f, i) => (
|
{files.map((f, i) => (
|
||||||
<div className="att file" key={`f${i}`}>
|
<div className="att file" key={`f${i}`}>
|
||||||
<span><Icon name="file" /> {f.name}</span>
|
<span><Icon name="file" /> {f.name}</span>
|
||||||
<small>{formatSize(f.size)}</small>
|
<small>{formatSize(f.size)}</small>
|
||||||
<button onClick={() => setFiles((c) => c.filter((_, j) => j !== i))} aria-label={t("common.remove")}>
|
<Button onClick={() => setFiles((c) => c.filter((_, j) => j !== i))} aria-label={t("common.remove")}>
|
||||||
<Icon name="close" />
|
<Icon name="close" />
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div className="wiz-input-foot">
|
<div className="wiz-input-foot">
|
||||||
<button type="button" className="ghost small" onClick={() => fileInput.current?.click()} title={t("wizard.attach")}>
|
<Button type="text" size="small" onClick={() => fileInput.current?.click()} title={t("wizard.attach")}>
|
||||||
{ICONS.clip}
|
{ICONS.clip}
|
||||||
</button>
|
</Button>
|
||||||
<span>{target === "software" && task === "craft" ? t("wizard.softwareHint") : t("wizard.enterHint")}</span>
|
<span>{target === "software" && task === "craft" ? t("wizard.softwareHint") : t("wizard.enterHint")}</span>
|
||||||
<input ref={fileInput} type="file" multiple hidden onChange={(e) => e.target.files && void addFiles(e.target.files)} />
|
<input ref={fileInput} type="file" multiple hidden onChange={(e) => e.target.files && void addFiles(e.target.files)} />
|
||||||
</div>
|
</div>
|
||||||
@@ -512,9 +514,9 @@ export function NewSession({ onMenu, onCreated }: { onMenu: () => void; onCreate
|
|||||||
<div className="wiz-ideas">
|
<div className="wiz-ideas">
|
||||||
<span>{t("wizard.ideas")}</span>
|
<span>{t("wizard.ideas")}</span>
|
||||||
{ideas.map((k) => (
|
{ideas.map((k) => (
|
||||||
<button key={k} type="button" className="chip-btn" onClick={() => setText(t(k))}>
|
<Button key={k} size="small" shape="round" onClick={() => setText(t(k))}>
|
||||||
{t(k)}
|
{t(k)}
|
||||||
</button>
|
</Button>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
@@ -536,7 +538,7 @@ export function NewSession({ onMenu, onCreated }: { onMenu: () => void; onCreate
|
|||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
{folderMode === "git" && (
|
{folderMode === "git" && (
|
||||||
<input className="wiz-url" value={repoUrl} placeholder="https://git.example.com/user/repo.git" onChange={(e) => setRepoUrl(e.target.value)} />
|
<Input className="wiz-url" value={repoUrl} placeholder="https://git.example.com/user/repo.git" onChange={(e) => setRepoUrl(e.target.value)} />
|
||||||
)}
|
)}
|
||||||
{folderMode !== "existing" && (
|
{folderMode !== "existing" && (
|
||||||
<div className="wiz-folder">
|
<div className="wiz-folder">
|
||||||
@@ -544,18 +546,18 @@ export function NewSession({ onMenu, onCreated }: { onMenu: () => void; onCreate
|
|||||||
<span className="wiz-folder-text">
|
<span className="wiz-folder-text">
|
||||||
{t(folderMode === "git" ? "wizard.cloneInto" : "wizard.newFolderIn")}{" "}
|
{t(folderMode === "git" ? "wizard.cloneInto" : "wizard.newFolderIn")}{" "}
|
||||||
{roots.length > 1 ? (
|
{roots.length > 1 ? (
|
||||||
<select value={rootPath} onChange={(e) => setRootPath(e.target.value)}>
|
<Select value={rootPath} onChange={(e) => setRootPath(e.target.value)}>
|
||||||
{roots.map((r) => (
|
{roots.map((r) => (
|
||||||
<option key={r.path} value={r.path}>
|
<option key={r.path} value={r.path}>
|
||||||
{r.name === "/" ? "workspace" : r.name}
|
{r.name === "/" ? "workspace" : r.name}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</Select>
|
||||||
) : (
|
) : (
|
||||||
<code>{!roots[0] || roots[0].name === "/" ? "workspace" : roots[0].name}</code>
|
<code>{!roots[0] || roots[0].name === "/" ? "workspace" : roots[0].name}</code>
|
||||||
)}
|
)}
|
||||||
<span>/</span>
|
<span>/</span>
|
||||||
<input
|
<Input
|
||||||
className="wiz-folder-name"
|
className="wiz-folder-name"
|
||||||
value={folderName}
|
value={folderName}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
@@ -568,22 +570,21 @@ export function NewSession({ onMenu, onCreated }: { onMenu: () => void; onCreate
|
|||||||
)}
|
)}
|
||||||
{folderMode === "existing" && <FolderPicker path={picked} onPick={setPicked} />}
|
{folderMode === "existing" && <FolderPicker path={picked} onPick={setPicked} />}
|
||||||
{folderMode !== "new" && (
|
{folderMode !== "new" && (
|
||||||
<label className="wiz-check-row">
|
<Checkbox className="wiz-check-row" checked={isolated} onChange={(e) => setIsolated(e.target.checked)}>
|
||||||
<input type="checkbox" checked={isolated} onChange={(e) => setIsolated(e.target.checked)} />
|
|
||||||
<span>
|
<span>
|
||||||
<b>{t("worktree.isolate")}</b>
|
<b>{t("worktree.isolate")}</b>
|
||||||
<span className="hint"> – {t("worktree.isolateHint")}</span>
|
<span className="hint"> – {t("worktree.isolateHint")}</span>
|
||||||
</span>
|
</span>
|
||||||
</label>
|
</Checkbox>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{error && <div className="notice err">{error}</div>}
|
{error && <div className="notice err">{error}</div>}
|
||||||
<div className="wiz-start-row">
|
<div className="wiz-start-row">
|
||||||
<button className="primary wiz-start" disabled={!canStart} onClick={create}>
|
<Button type="primary" className="wiz-start" disabled={!canStart} onClick={create}>
|
||||||
{ICONS.start}
|
{ICONS.start}
|
||||||
{creating ?? t("wizard.start")}
|
{creating ?? t("wizard.start")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -624,37 +625,37 @@ export function FolderPicker({ path, onPick }: { path: string; onPick: (p: strin
|
|||||||
return (
|
return (
|
||||||
<div className="wiz-picker">
|
<div className="wiz-picker">
|
||||||
{roots.length > 1 && (
|
{roots.length > 1 && (
|
||||||
<div className="mode-tabs" style={{ marginBottom: 8, flexWrap: "wrap" }}>
|
<Segmented
|
||||||
{roots.map((r) => (
|
className="seg-wrap"
|
||||||
<button key={r.path} className={listing?.root === r.path ? "active" : ""} onClick={() => setBrowse(r.path)}>
|
style={{ marginBottom: 8 }}
|
||||||
{r.name}
|
value={listing?.root ?? ""}
|
||||||
</button>
|
onChange={(path) => setBrowse(path)}
|
||||||
))}
|
options={roots.map((r) => ({ value: r.path, label: r.name }))}
|
||||||
</div>
|
/>
|
||||||
)}
|
)}
|
||||||
<div className="row" style={{ marginBottom: 8 }}>
|
<div className="row" style={{ marginBottom: 8 }}>
|
||||||
<code className="grow" style={{ flex: 1 }}>
|
<code className="grow" style={{ flex: 1 }}>
|
||||||
{rel}
|
{rel}
|
||||||
</code>
|
</code>
|
||||||
{listing?.parent && (
|
{listing?.parent && (
|
||||||
<button className="small" onClick={() => setBrowse(listing.parent!)}>
|
<Button size="small" onClick={() => setBrowse(listing.parent!)}>
|
||||||
<Icon name="arrow-up" /> {t("new.up")}
|
<Icon name="arrow-up" /> {t("new.up")}
|
||||||
</button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
{listing && (
|
{listing && (
|
||||||
<button className="small" onClick={() => void newFolder()}>
|
<Button size="small" onClick={() => void newFolder()}>
|
||||||
<Icon name="plus" /> {t("files.newFolder")}
|
<Icon name="plus" /> {t("files.newFolder")}
|
||||||
</button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="dir-list">
|
<div className="dir-list">
|
||||||
{listing?.dirs.length === 0 && <div className="empty" style={{ padding: 16 }}>{t("new.noSubdirs")}</div>}
|
{listing?.dirs.length === 0 && <div className="empty" style={{ padding: 16 }}>{t("new.noSubdirs")}</div>}
|
||||||
{listing?.dirs.map((d) => (
|
{listing?.dirs.map((d) => (
|
||||||
<button key={d.path} onClick={() => setBrowse(d.path)}>
|
<Button key={d.path} onClick={() => setBrowse(d.path)}>
|
||||||
{ICONS.folder}
|
{ICONS.folder}
|
||||||
<span style={{ flex: 1 }}>{d.name}</span>
|
<span style={{ flex: 1 }}>{d.name}</span>
|
||||||
{d.git && <span className="chip">git</span>}
|
{d.git && <span className="chip">git</span>}
|
||||||
</button>
|
</Button>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { Button } from "antd";
|
||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
import { useT } from "../i18n";
|
import { useT } from "../i18n";
|
||||||
import { flushOutbox, removeFromOutbox, useOutbox } from "../outbox";
|
import { flushOutbox, removeFromOutbox, useOutbox } from "../outbox";
|
||||||
@@ -22,16 +23,16 @@ export function OutboxBar({ sessionId }: { sessionId: string }) {
|
|||||||
<div className="outbox-head">
|
<div className="outbox-head">
|
||||||
<Icon name="clock" className="tiny" /> {t("outbox.waiting", { n: items.length })}
|
<Icon name="clock" className="tiny" /> {t("outbox.waiting", { n: items.length })}
|
||||||
<span className="grow" />
|
<span className="grow" />
|
||||||
<button className="small" onClick={() => void flushOutbox(sessionId)}>
|
<Button size="small" onClick={() => void flushOutbox(sessionId)}>
|
||||||
{t("outbox.sendNow")}
|
{t("outbox.sendNow")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
{items.map((i) => (
|
{items.map((i) => (
|
||||||
<div key={i.id} className="outbox-item">
|
<div key={i.id} className="outbox-item">
|
||||||
<span>{i.text.length > 120 ? `${i.text.slice(0, 120)}…` : i.text}</span>
|
<span>{i.text.length > 120 ? `${i.text.slice(0, 120)}…` : i.text}</span>
|
||||||
<button className="small ghost" onClick={() => removeFromOutbox(i.id)} aria-label={t("outbox.discard")} title={t("outbox.discard")}>
|
<Button type="text" size="small" onClick={() => removeFromOutbox(i.id)} aria-label={t("outbox.discard")} title={t("outbox.discard")}>
|
||||||
<Icon name="close" />
|
<Icon name="close" />
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { Input } from "antd";
|
||||||
|
import { Modal } from "../ui/Modal";
|
||||||
import { useEffect, useMemo, useState } from "react";
|
import { useEffect, useMemo, useState } from "react";
|
||||||
import { fmtRelative, useT, type Key } from "../i18n";
|
import { fmtRelative, useT, type Key } from "../i18n";
|
||||||
import { navigate } from "../router";
|
import { navigate } from "../router";
|
||||||
@@ -103,9 +105,8 @@ export function Palette() {
|
|||||||
const close = () => setOpen(false);
|
const close = () => setOpen(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="modal-backdrop palette-backdrop" onClick={close}>
|
<Modal onClose={close} className="palette" role="dialog" aria-label={t("palette.title")}>
|
||||||
<div className="modal palette" role="dialog" aria-label={t("palette.title")} onClick={(e) => e.stopPropagation()}>
|
<Input
|
||||||
<input
|
|
||||||
autoFocus
|
autoFocus
|
||||||
value={q}
|
value={q}
|
||||||
placeholder={t("palette.placeholder")}
|
placeholder={t("palette.placeholder")}
|
||||||
@@ -142,7 +143,6 @@ export function Palette() {
|
|||||||
<span><kbd>Alt+<Icon name="arrow-up" className="tiny" /></kbd><kbd>Alt+<Icon name="arrow-down" className="tiny" /></kbd> {t("palette.prevNext")}</span>
|
<span><kbd>Alt+<Icon name="arrow-up" className="tiny" /></kbd><kbd>Alt+<Icon name="arrow-down" className="tiny" /></kbd> {t("palette.prevNext")}</span>
|
||||||
<span><kbd>Esc</kbd> {t("palette.close")}</span>
|
<span><kbd>Esc</kbd> {t("palette.close")}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</Modal>
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { Button } from "antd";
|
||||||
import { useMemo } from "react";
|
import { useMemo } from "react";
|
||||||
import { useFetch } from "../hooks";
|
import { useFetch } from "../hooks";
|
||||||
import { fmtCost, fmtDate, fmtRelative, useT, type Key } from "../i18n";
|
import { fmtCost, fmtDate, fmtRelative, useT, type Key } from "../i18n";
|
||||||
@@ -54,18 +55,18 @@ export function ProjectPage({ cwd, onMenu }: { cwd: string; onMenu: () => void }
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="topbar">
|
<div className="topbar">
|
||||||
<button className="ghost menu-btn" onClick={onMenu} aria-label={t("nav.menu")}>
|
<Button type="text" className="menu-btn" onClick={onMenu} aria-label={t("nav.menu")}>
|
||||||
<Icon name="menu" />
|
<Icon name="menu" />
|
||||||
</button>
|
</Button>
|
||||||
<div className="grow">
|
<div className="grow">
|
||||||
<h1>
|
<h1>
|
||||||
<Icon name="folder" /> {basename(cwd) || "/"}
|
<Icon name="folder" /> {basename(cwd) || "/"}
|
||||||
</h1>
|
</h1>
|
||||||
<div className="path mono">{cwd}</div>
|
<div className="path mono">{cwd}</div>
|
||||||
</div>
|
</div>
|
||||||
<button className="small primary" onClick={newChat}>
|
<Button type="primary" size="small" onClick={newChat}>
|
||||||
<Icon name="plus" /> {t("project.newChat")}
|
<Icon name="plus" /> {t("project.newChat")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<div className="chat-scroll">
|
<div className="chat-scroll">
|
||||||
<div className="chat project-page">
|
<div className="chat project-page">
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { Button } from "antd";
|
||||||
|
import { Modal } from "../ui/Modal";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { api, get } from "../api";
|
import { api, get } from "../api";
|
||||||
import { useT } from "../i18n";
|
import { useT } from "../i18n";
|
||||||
@@ -23,8 +25,7 @@ export function ProjectPermissions({ sessionId, cwd, onClose }: { sessionId: str
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<div className="modal-backdrop" onClick={onClose}>
|
<Modal onClose={onClose} role="dialog" aria-label={t("permProject.title")}>
|
||||||
<div className="modal" role="dialog" aria-label={t("permProject.title")} onClick={(e) => e.stopPropagation()}>
|
|
||||||
<h3>
|
<h3>
|
||||||
<Icon name="lock" /> {t("permProject.title")}
|
<Icon name="lock" /> {t("permProject.title")}
|
||||||
</h3>
|
</h3>
|
||||||
@@ -39,17 +40,16 @@ export function ProjectPermissions({ sessionId, cwd, onClose }: { sessionId: str
|
|||||||
{keys.map((k) => (
|
{keys.map((k) => (
|
||||||
<li key={k} className="row" style={{ justifyContent: "space-between" }}>
|
<li key={k} className="row" style={{ justifyContent: "space-between" }}>
|
||||||
<code>{label(k)}</code>
|
<code>{label(k)}</code>
|
||||||
<button className="small danger" onClick={() => void revoke(k)}>
|
<Button danger size="small" onClick={() => void revoke(k)}>
|
||||||
{t("permProject.revoke")}
|
{t("permProject.revoke")}
|
||||||
</button>
|
</Button>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
)}
|
)}
|
||||||
<div className="row" style={{ justifyContent: "flex-end", marginTop: 10 }}>
|
<div className="row" style={{ justifyContent: "flex-end", marginTop: 10 }}>
|
||||||
<button onClick={onClose}>{t("common.close")}</button>
|
<Button onClick={onClose}>{t("common.close")}</Button>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
</Modal>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { Button } from "antd";
|
||||||
import { Icon } from "./Icon";
|
import { Icon } from "./Icon";
|
||||||
import { del, post } from "../api";
|
import { del, post } from "../api";
|
||||||
import { useT } from "../i18n";
|
import { useT } from "../i18n";
|
||||||
@@ -17,11 +18,12 @@ export function QueueList({ sessionId, busy }: { sessionId: string; busy: boolea
|
|||||||
<div className="queue">
|
<div className="queue">
|
||||||
<div className="queue-head">
|
<div className="queue-head">
|
||||||
<span>{busy ? t("queue.pending", { n: items.length }) : t("queue.stopped", { n: items.length })}</span>
|
<span>{busy ? t("queue.pending", { n: items.length }) : t("queue.stopped", { n: items.length })}</span>
|
||||||
{!busy && (
|
<Button type="primary" size="small"
|
||||||
<button className="small primary" onClick={() => post(`/sessions/${sessionId}/queue/flush`).catch((e) => toast(e.message))}>
|
title={busy ? t("queue.forceHint") : undefined}
|
||||||
{t("queue.sendNow")}
|
onClick={() => post(`/sessions/${sessionId}/queue/force`).catch((e) => toast(e.message))}
|
||||||
</button>
|
>
|
||||||
)}
|
{busy ? t("queue.force") : t("queue.sendNow")}
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
{items.map((it) => {
|
{items.map((it) => {
|
||||||
const text = it.parts.map((p) => (p.type === "text" ? p.text : "")).join(" ").trim();
|
const text = it.parts.map((p) => (p.type === "text" ? p.text : "")).join(" ").trim();
|
||||||
@@ -34,14 +36,13 @@ export function QueueList({ sessionId, busy }: { sessionId: string; busy: boolea
|
|||||||
<img key={i} src={imageSrc(p.image)} alt="" />
|
<img key={i} src={imageSrc(p.image)} alt="" />
|
||||||
))}
|
))}
|
||||||
{it.source !== "background" && (
|
{it.source !== "background" && (
|
||||||
<button
|
<Button type="text" size="small"
|
||||||
className="small ghost"
|
|
||||||
aria-label={t("queue.remove")}
|
aria-label={t("queue.remove")}
|
||||||
title={t("queue.remove")}
|
title={t("queue.remove")}
|
||||||
onClick={() => del(`/sessions/${sessionId}/queue/${it.id}`).catch((e) => toast(e.message))}
|
onClick={() => del(`/sessions/${sessionId}/queue/${it.id}`).catch((e) => toast(e.message))}
|
||||||
>
|
>
|
||||||
<Icon name="close" />
|
<Icon name="close" />
|
||||||
</button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { Button } from "antd";
|
||||||
|
import { Select } from "../ui/Select";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { post } from "../api";
|
import { post } from "../api";
|
||||||
import { useT } from "../i18n";
|
import { useT } from "../i18n";
|
||||||
@@ -11,14 +13,14 @@ export const EFFORTS = ["low", "medium", "high", "max"] as const;
|
|||||||
export function EffortSelect({ value, onChange, compact }: { value: string; onChange: (v: string) => void; compact?: boolean }) {
|
export function EffortSelect({ value, onChange, compact }: { value: string; onChange: (v: string) => void; compact?: boolean }) {
|
||||||
const t = useT();
|
const t = useT();
|
||||||
return (
|
return (
|
||||||
<select className={compact ? "effort-select" : ""} value={value} onChange={(e) => onChange(e.target.value)} title={t("effort.title")} aria-label={t("effort.title")}>
|
<Select className={compact ? "effort-select" : ""} value={value} onChange={(e) => onChange(e.target.value)} title={t("effort.title")} aria-label={t("effort.title")}>
|
||||||
<option value="">{compact ? t("effort.autoShort") : t("effort.auto")}</option>
|
<option value="">{compact ? t("effort.autoShort") : t("effort.auto")}</option>
|
||||||
{EFFORTS.map((e) => (
|
{EFFORTS.map((e) => (
|
||||||
<option key={e} value={e}>
|
<option key={e} value={e}>
|
||||||
{t(`effort.${e}` as any)}
|
{t(`effort.${e}` as any)}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</Select>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,18 +44,18 @@ export function RegenerateButton({ sessionId, messageId, model }: { sessionId: s
|
|||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<div className="regen">
|
<div className="regen">
|
||||||
<button className="small ghost" onClick={() => setOpen(!open)} title={t("regen.title")}>
|
<Button type="text" size="small" onClick={() => setOpen(!open)} title={t("regen.title")}>
|
||||||
<Icon name="refresh" /> {t("regen.button")}
|
<Icon name="refresh" /> {t("regen.button")}
|
||||||
</button>
|
</Button>
|
||||||
{open && (
|
{open && (
|
||||||
<div className="regen-panel">
|
<div className="regen-panel">
|
||||||
<div className="hint">{t("regen.hint")}</div>
|
<div className="hint">{t("regen.hint")}</div>
|
||||||
<div className="row" style={{ gap: 6, flexWrap: "wrap" }}>
|
<div className="row" style={{ gap: 6, flexWrap: "wrap" }}>
|
||||||
<ModelSelect value={m} onChange={setM} />
|
<ModelSelect value={m} onChange={setM} />
|
||||||
<EffortSelect value={effort} onChange={setEffort} />
|
<EffortSelect value={effort} onChange={setEffort} />
|
||||||
<button className="small primary" disabled={busy} onClick={go}>
|
<Button type="primary" size="small" disabled={busy} onClick={go}>
|
||||||
<Icon name="refresh" /> {t("regen.go")}
|
<Icon name="refresh" /> {t("regen.go")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { Button, Input } from "antd";
|
||||||
|
import { Modal } from "../ui/Modal";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { patch, post } from "../api";
|
import { patch, post } from "../api";
|
||||||
import { useFetch } from "../hooks";
|
import { useFetch } from "../hooks";
|
||||||
@@ -41,10 +43,9 @@ export function RenameDialog({ sessionId, title, onClose }: { sessionId: string;
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="modal-backdrop" onClick={onClose}>
|
<Modal onClose={onClose} role="dialog" aria-label={t("rename.title")}>
|
||||||
<div className="modal" role="dialog" aria-label={t("rename.title")} onClick={(e) => e.stopPropagation()}>
|
|
||||||
<h3>{t("rename.title")}</h3>
|
<h3>{t("rename.title")}</h3>
|
||||||
<input
|
<Input
|
||||||
autoFocus
|
autoFocus
|
||||||
style={{ width: "100%" }}
|
style={{ width: "100%" }}
|
||||||
value={value}
|
value={value}
|
||||||
@@ -55,18 +56,17 @@ export function RenameDialog({ sessionId, title, onClose }: { sessionId: string;
|
|||||||
<div className="rename-gen">
|
<div className="rename-gen">
|
||||||
<span className="hint">{t("rename.generateWith")}</span>
|
<span className="hint">{t("rename.generateWith")}</span>
|
||||||
<ModelSelect value={chosen} onChange={setModel} />
|
<ModelSelect value={chosen} onChange={setModel} />
|
||||||
<button className="small" onClick={generate} disabled={!!busy}>
|
<Button size="small" onClick={generate} disabled={!!busy}>
|
||||||
{busy === "gen" ? <Spinner small /> : <Icon name="sparkle" />} {t("rename.generate")}
|
{busy === "gen" ? <Spinner small /> : <Icon name="sparkle" />} {t("rename.generate")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
{error && <div className="notice err">{error}</div>}
|
{error && <div className="notice err">{error}</div>}
|
||||||
<div className="row" style={{ marginTop: 12, justifyContent: "flex-end" }}>
|
<div className="row" style={{ marginTop: 12, justifyContent: "flex-end" }}>
|
||||||
<button onClick={onClose}>{t("common.cancel")}</button>
|
<Button onClick={onClose}>{t("common.cancel")}</Button>
|
||||||
<button className="primary" onClick={save} disabled={!!busy}>
|
<Button type="primary" onClick={save} disabled={!!busy}>
|
||||||
{t("common.save")}
|
{t("common.save")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
</Modal>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { Button, Checkbox } from "antd";
|
||||||
|
import { Modal } from "../ui/Modal";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { get, post } from "../api";
|
import { get, post } from "../api";
|
||||||
import { useT } from "../i18n";
|
import { useT } from "../i18n";
|
||||||
@@ -23,8 +25,7 @@ export function RewindDialog({ sessionId, messageId, onDone, onClose }: { sessio
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<div className="modal-backdrop" onClick={onClose}>
|
<Modal onClose={onClose} role="dialog" aria-label={t("chat.rewind")}>
|
||||||
<div className="modal" role="dialog" aria-label={t("chat.rewind")} onClick={(e) => e.stopPropagation()}>
|
|
||||||
<h3>{t("chat.rewind")}</h3>
|
<h3>{t("chat.rewind")}</h3>
|
||||||
<p style={{ fontSize: 13, color: "var(--fg3)" }}>{t("rewind.intro")}</p>
|
<p style={{ fontSize: 13, color: "var(--fg3)" }}>{t("rewind.intro")}</p>
|
||||||
{files === undefined ? (
|
{files === undefined ? (
|
||||||
@@ -33,9 +34,8 @@ export function RewindDialog({ sessionId, messageId, onDone, onClose }: { sessio
|
|||||||
<p style={{ fontSize: 13 }}>{t("rewind.noFiles")}</p>
|
<p style={{ fontSize: 13 }}>{t("rewind.noFiles")}</p>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<label className="row" style={{ marginBottom: 6 }}>
|
<Checkbox className="row" style={{ marginBottom: 6 }} checked={restore} onChange={(e) => setRestore(e.target.checked)}> {t("rewind.restore", { n: files.length })}
|
||||||
<input type="checkbox" checked={restore} onChange={(e) => setRestore(e.target.checked)} /> {t("rewind.restore", { n: files.length })}
|
</Checkbox>
|
||||||
</label>
|
|
||||||
<ul className="rewind-files">
|
<ul className="rewind-files">
|
||||||
{files.map((f) => (
|
{files.map((f) => (
|
||||||
<li key={f.path}>
|
<li key={f.path}>
|
||||||
@@ -47,12 +47,11 @@ export function RewindDialog({ sessionId, messageId, onDone, onClose }: { sessio
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<div className="row" style={{ justifyContent: "flex-end", marginTop: 10 }}>
|
<div className="row" style={{ justifyContent: "flex-end", marginTop: 10 }}>
|
||||||
<button onClick={onClose}>{t("common.cancel")}</button>
|
<Button onClick={onClose}>{t("common.cancel")}</Button>
|
||||||
<button className="primary" disabled={busy || files === undefined} onClick={go}>
|
<Button type="primary" disabled={busy || files === undefined} onClick={go}>
|
||||||
{t("rewind.confirm")}
|
{t("rewind.confirm")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
</Modal>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
+144
-157
@@ -1,3 +1,5 @@
|
|||||||
|
import { Button, Checkbox, Input, Segmented, Tabs } from "antd";
|
||||||
|
import { Select } from "../ui/Select";
|
||||||
import { Icon } from "./Icon";
|
import { Icon } from "./Icon";
|
||||||
import { useEffect, useState, useSyncExternalStore } from "react";
|
import { useEffect, useState, useSyncExternalStore } from "react";
|
||||||
import { get, patch as apiPatch, post, put } from "../api";
|
import { get, patch as apiPatch, post, put } from "../api";
|
||||||
@@ -65,16 +67,16 @@ function InterfaceSettings() {
|
|||||||
<h3>{t("settings.interface")}</h3>
|
<h3>{t("settings.interface")}</h3>
|
||||||
<div className="form">
|
<div className="form">
|
||||||
<label>{t("settings.language")}</label>
|
<label>{t("settings.language")}</label>
|
||||||
<select value={getLang()} onChange={(e) => setLang(e.target.value)}>
|
<Select value={getLang()} onChange={(e) => setLang(e.target.value)}>
|
||||||
{Object.entries(languages).map(([k, v]) => (
|
{Object.entries(languages).map(([k, v]) => (
|
||||||
<option key={k} value={k}>
|
<option key={k} value={k}>
|
||||||
{v.name}
|
{v.name}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</Select>
|
||||||
<label>{t("settings.theme")}</label>
|
<label>{t("settings.theme")}</label>
|
||||||
<div className="stack">
|
<div className="stack">
|
||||||
<select
|
<Select
|
||||||
value={theme}
|
value={theme}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
const v = e.target.value as Theme;
|
const v = e.target.value as Theme;
|
||||||
@@ -86,30 +88,23 @@ function InterfaceSettings() {
|
|||||||
{th.name}
|
{th.name}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</Select>
|
||||||
<div className="hint">{t("settings.themeSource", { source: themeInfo.source, license: themeInfo.license })}</div>
|
<div className="hint">{t("settings.themeSource", { source: themeInfo.source, license: themeInfo.license })}</div>
|
||||||
</div>
|
</div>
|
||||||
<label>{t("settings.themeMode")}</label>
|
<label>{t("settings.themeMode")}</label>
|
||||||
<div className="segmented">
|
<Segmented
|
||||||
{THEME_MODES.map((m) => (
|
className="theme-mode"
|
||||||
<button
|
value={mode}
|
||||||
key={m}
|
onChange={(m) => applyTheme(theme, m)}
|
||||||
className={`small ${m === mode ? "active" : "ghost"}`}
|
options={THEME_MODES.map((m) => ({ value: m, label: t(m === "auto" ? "settings.themeAuto" : m === "light" ? "settings.themeLight" : "settings.themeDark") }))}
|
||||||
onClick={() => {
|
/>
|
||||||
applyTheme(theme, m);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{t(m === "auto" ? "settings.themeAuto" : m === "light" ? "settings.themeLight" : "settings.themeDark")}
|
|
||||||
</button>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
<label>{t("settings.reasoningDisplay")}</label>
|
<label>{t("settings.reasoningDisplay")}</label>
|
||||||
<select value={reasoning} onChange={(e) => setReasoningMode(e.target.value as ReasoningMode)}>
|
<Select value={reasoning} onChange={(e) => setReasoningMode(e.target.value as ReasoningMode)}>
|
||||||
<option value="collapsed">{t("settings.reasoningCollapsed")}</option>
|
<option value="collapsed">{t("settings.reasoningCollapsed")}</option>
|
||||||
<option value="hidden">{t("settings.reasoningHidden")}</option>
|
<option value="hidden">{t("settings.reasoningHidden")}</option>
|
||||||
<option value="live">{t("settings.reasoningLive")}</option>
|
<option value="live">{t("settings.reasoningLive")}</option>
|
||||||
<option value="expanded">{t("settings.reasoningExpanded")}</option>
|
<option value="expanded">{t("settings.reasoningExpanded")}</option>
|
||||||
</select>
|
</Select>
|
||||||
<div className="hint">{t("settings.reasoningHint")}</div>
|
<div className="hint">{t("settings.reasoningHint")}</div>
|
||||||
<label>{t("settings.notifications")}</label>
|
<label>{t("settings.notifications")}</label>
|
||||||
<PushControl />
|
<PushControl />
|
||||||
@@ -130,9 +125,9 @@ function InstallControl() {
|
|||||||
if (prompt)
|
if (prompt)
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<button className="small primary" onClick={() => void promptInstall()}>
|
<Button type="primary" size="small" onClick={() => void promptInstall()}>
|
||||||
<Icon name="download" /> {t("install.button")}
|
<Icon name="download" /> {t("install.button")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
return <div className="hint">{t(`install.hint.${platformHint()}` as Key)}</div>;
|
return <div className="hint">{t(`install.hint.${platformHint()}` as Key)}</div>;
|
||||||
@@ -156,33 +151,22 @@ function DigestToggle() {
|
|||||||
if (on === undefined) return null;
|
if (on === undefined) return null;
|
||||||
return (
|
return (
|
||||||
<div className="row" style={{ gap: 8, flexBasis: "100%", alignItems: "center", flexWrap: "wrap" }}>
|
<div className="row" style={{ gap: 8, flexBasis: "100%", alignItems: "center", flexWrap: "wrap" }}>
|
||||||
<label className="row" style={{ gap: 6, alignItems: "center" }}>
|
<Checkbox className="row" style={{ gap: 6, alignItems: "center" }} checked={on} onChange={(e) => {
|
||||||
<input
|
|
||||||
type="checkbox"
|
|
||||||
checked={on}
|
|
||||||
onChange={(e) => {
|
|
||||||
const v = e.target.checked;
|
const v = e.target.checked;
|
||||||
setOn(v);
|
setOn(v);
|
||||||
put("/push/digest", { enabled: v }).catch((err) => (setOn(!v), toast(err.message)));
|
put("/push/digest", { enabled: v }).catch((err) => (setOn(!v), toast(err.message)));
|
||||||
}}
|
}}>
|
||||||
/>
|
|
||||||
{t("settings.digest")}
|
{t("settings.digest")}
|
||||||
</label>
|
</Checkbox>
|
||||||
<label className="row" style={{ gap: 6, alignItems: "center" }}>
|
<Checkbox className="row" style={{ gap: 6, alignItems: "center" }} checked={weekly} onChange={(e) => {
|
||||||
<input
|
|
||||||
type="checkbox"
|
|
||||||
checked={weekly}
|
|
||||||
onChange={(e) => {
|
|
||||||
const v = e.target.checked;
|
const v = e.target.checked;
|
||||||
setWeekly(v);
|
setWeekly(v);
|
||||||
put("/push/digest", { weekly: v }).catch((err) => (setWeekly(!v), toast(err.message)));
|
put("/push/digest", { weekly: v }).catch((err) => (setWeekly(!v), toast(err.message)));
|
||||||
}}
|
}}>
|
||||||
/>
|
|
||||||
{t("settings.weeklyDigest")}
|
{t("settings.weeklyDigest")}
|
||||||
</label>
|
</Checkbox>
|
||||||
{weekly && (
|
{weekly && (
|
||||||
<button
|
<Button type="text" size="small"
|
||||||
className="small ghost"
|
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
post<{ sent: number; errors: string[] }>("/push/digest?weekly=true")
|
post<{ sent: number; errors: string[] }>("/push/digest?weekly=true")
|
||||||
.then((r) => toast(r.sent ? t("settings.pushTestSent") : r.errors.join("; ") || t("settings.pushTestNone"), r.sent ? "success" : "error"))
|
.then((r) => toast(r.sent ? t("settings.pushTestSent") : r.errors.join("; ") || t("settings.pushTestNone"), r.sent ? "success" : "error"))
|
||||||
@@ -190,11 +174,10 @@ function DigestToggle() {
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
{t("settings.digestNow")}
|
{t("settings.digestNow")}
|
||||||
</button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
{on && (
|
{on && (
|
||||||
<button
|
<Button type="text" size="small"
|
||||||
className="small ghost"
|
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
post<{ sent: number; errors: string[] }>("/push/digest")
|
post<{ sent: number; errors: string[] }>("/push/digest")
|
||||||
.then((r) => toast(r.sent ? t("settings.pushTestSent") : r.errors.join("; ") || t("settings.pushTestNone"), r.sent ? "success" : "error"))
|
.then((r) => toast(r.sent ? t("settings.pushTestSent") : r.errors.join("; ") || t("settings.pushTestNone"), r.sent ? "success" : "error"))
|
||||||
@@ -202,7 +185,7 @@ function DigestToggle() {
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
{t("settings.digestNow")}
|
{t("settings.digestNow")}
|
||||||
</button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -242,8 +225,7 @@ function PushControl() {
|
|||||||
{state === "on" ? (
|
{state === "on" ? (
|
||||||
<>
|
<>
|
||||||
<span className="chip">{t("settings.notificationsOn")}</span>
|
<span className="chip">{t("settings.notificationsOn")}</span>
|
||||||
<button
|
<Button size="small"
|
||||||
className="small"
|
|
||||||
disabled={busy}
|
disabled={busy}
|
||||||
onClick={run(async () => {
|
onClick={run(async () => {
|
||||||
const r = await testPush();
|
const r = await testPush();
|
||||||
@@ -252,16 +234,16 @@ function PushControl() {
|
|||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
{t("settings.pushTest")}
|
{t("settings.pushTest")}
|
||||||
</button>
|
</Button>
|
||||||
<button className="small ghost" disabled={busy} onClick={run(async () => (await disablePush(), setState("off")))}>
|
<Button type="text" size="small" disabled={busy} onClick={run(async () => (await disablePush(), setState("off")))}>
|
||||||
{t("settings.pushDisable")}
|
{t("settings.pushDisable")}
|
||||||
</button>
|
</Button>
|
||||||
<DigestToggle />
|
<DigestToggle />
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<button className="small" disabled={busy} onClick={run(async () => (await enablePush(), setState("on")))}>
|
<Button size="small" disabled={busy} onClick={run(async () => (await enablePush(), setState("on")))}>
|
||||||
{t("settings.notificationsEnable")}
|
{t("settings.notificationsEnable")}
|
||||||
</button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -338,35 +320,35 @@ function General({ cfg, reload }: { cfg: ConfigResponse; reload: () => void }) {
|
|||||||
<ModelSelect value={form.plan_model} emptyLabel={t("settings.sameAsChat")} onChange={(v) => setForm({ ...form, plan_model: v })} />
|
<ModelSelect value={form.plan_model} emptyLabel={t("settings.sameAsChat")} onChange={(v) => setForm({ ...form, plan_model: v })} />
|
||||||
<div className="hint">{t("settings.planModelHint")}</div>
|
<div className="hint">{t("settings.planModelHint")}</div>
|
||||||
<label>{t("settings.transcribeModel")}</label>
|
<label>{t("settings.transcribeModel")}</label>
|
||||||
<input value={form.transcribe_model} placeholder="openai/whisper-1" onChange={(e) => setForm({ ...form, transcribe_model: e.target.value })} />
|
<Input value={form.transcribe_model} placeholder="openai/whisper-1" onChange={(e) => setForm({ ...form, transcribe_model: e.target.value })} />
|
||||||
<div className="hint">{t("settings.transcribeHint")}</div>
|
<div className="hint">{t("settings.transcribeHint")}</div>
|
||||||
<label>{t("settings.currency")}</label>
|
<label>{t("settings.currency")}</label>
|
||||||
<input value={form.currency} onChange={(e) => setForm({ ...form, currency: e.target.value.toUpperCase() })} maxLength={3} />
|
<Input value={form.currency} onChange={(e) => setForm({ ...form, currency: e.target.value.toUpperCase() })} maxLength={3} />
|
||||||
<label>{t("settings.autoCompact")}</label>
|
<label>{t("settings.autoCompact")}</label>
|
||||||
<input type="number" min={0} max={1} step={0.05} value={form.auto_compact_threshold} onChange={(e) => setForm({ ...form, auto_compact_threshold: e.target.value })} />
|
<Input type="number" min={0} max={1} step={0.05} value={form.auto_compact_threshold} onChange={(e) => setForm({ ...form, auto_compact_threshold: e.target.value })} />
|
||||||
<div className="hint">{t("settings.autoCompactHint")}</div>
|
<div className="hint">{t("settings.autoCompactHint")}</div>
|
||||||
<label>{t("settings.commitTrailer")}</label>
|
<label>{t("settings.commitTrailer")}</label>
|
||||||
<input className="mono" value={form.commit_trailer} placeholder={t("settings.commitTrailerOff")} onChange={(e) => setForm({ ...form, commit_trailer: e.target.value })} />
|
<Input className="mono" value={form.commit_trailer} placeholder={t("settings.commitTrailerOff")} onChange={(e) => setForm({ ...form, commit_trailer: e.target.value })} />
|
||||||
<div className="hint">{t("settings.commitTrailerHint")}</div>
|
<div className="hint">{t("settings.commitTrailerHint")}</div>
|
||||||
<label>{t("settings.monthlyBudgetTotal")}</label>
|
<label>{t("settings.monthlyBudgetTotal")}</label>
|
||||||
<input type="number" min={0} value={form.monthly_budget} onChange={(e) => setForm({ ...form, monthly_budget: e.target.value })} />
|
<Input type="number" min={0} value={form.monthly_budget} onChange={(e) => setForm({ ...form, monthly_budget: e.target.value })} />
|
||||||
<div className="hint">{t("settings.monthlyBudgetHint")}</div>
|
<div className="hint">{t("settings.monthlyBudgetHint")}</div>
|
||||||
<label>{t("settings.budgetWarning")}</label>
|
<label>{t("settings.budgetWarning")}</label>
|
||||||
<input type="number" min={0} max={1} step={0.05} value={form.budget_warning} onChange={(e) => setForm({ ...form, budget_warning: e.target.value })} />
|
<Input type="number" min={0} max={1} step={0.05} value={form.budget_warning} onChange={(e) => setForm({ ...form, budget_warning: e.target.value })} />
|
||||||
<label>{t("settings.budgetAction")}</label>
|
<label>{t("settings.budgetAction")}</label>
|
||||||
<select value={form.budget_action} onChange={(e) => setForm({ ...form, budget_action: e.target.value })}>
|
<Select value={form.budget_action} onChange={(e) => setForm({ ...form, budget_action: e.target.value })}>
|
||||||
<option value="warn">{t("settings.budgetWarn")}</option>
|
<option value="warn">{t("settings.budgetWarn")}</option>
|
||||||
<option value="block">{t("settings.budgetBlock")}</option>
|
<option value="block">{t("settings.budgetBlock")}</option>
|
||||||
</select>
|
</Select>
|
||||||
<label>{t("settings.sandbox")}</label>
|
<label>{t("settings.sandbox")}</label>
|
||||||
<select value={form.sandbox_mode} onChange={(e) => setForm({ ...form, sandbox_mode: e.target.value })}>
|
<Select value={form.sandbox_mode} onChange={(e) => setForm({ ...form, sandbox_mode: e.target.value })}>
|
||||||
<option value="auto">{t("settings.sandboxAuto")}</option>
|
<option value="auto">{t("settings.sandboxAuto")}</option>
|
||||||
<option value="always">{t("settings.sandboxAlways")}</option>
|
<option value="always">{t("settings.sandboxAlways")}</option>
|
||||||
<option value="off">{t("settings.sandboxOff")}</option>
|
<option value="off">{t("settings.sandboxOff")}</option>
|
||||||
</select>
|
</Select>
|
||||||
<div className="hint">{t("settings.sandboxHint")}</div>
|
<div className="hint">{t("settings.sandboxHint")}</div>
|
||||||
<label>{t("settings.maxParallelSubagents")}</label>
|
<label>{t("settings.maxParallelSubagents")}</label>
|
||||||
<input type="number" min={0} value={form.max_parallel_subagents} onChange={(e) => setForm({ ...form, max_parallel_subagents: e.target.value })} />
|
<Input type="number" min={0} value={form.max_parallel_subagents} onChange={(e) => setForm({ ...form, max_parallel_subagents: e.target.value })} />
|
||||||
<div className="hint">{t("settings.maxParallelSubagentsHint")}</div>
|
<div className="hint">{t("settings.maxParallelSubagentsHint")}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -374,40 +356,40 @@ function General({ cfg, reload }: { cfg: ConfigResponse; reload: () => void }) {
|
|||||||
<h3>{t("settings.craft")}</h3>
|
<h3>{t("settings.craft")}</h3>
|
||||||
<div className="form">
|
<div className="form">
|
||||||
<label>{t("settings.cleanRoom")}</label>
|
<label>{t("settings.cleanRoom")}</label>
|
||||||
<input type="checkbox" checked={form.clean_room} onChange={(e) => setForm({ ...form, clean_room: e.target.checked })} style={{ justifySelf: "start" }} />
|
<Checkbox checked={form.clean_room} onChange={(e) => setForm({ ...form, clean_room: e.target.checked })} style={{ justifySelf: "start" }} />
|
||||||
<div className="hint">{t("settings.cleanRoomHint")}</div>
|
<div className="hint">{t("settings.cleanRoomHint")}</div>
|
||||||
<label>{t("settings.chromium")}</label>
|
<label>{t("settings.chromium")}</label>
|
||||||
<input value={form.chromium} onChange={(e) => setForm({ ...form, chromium: e.target.value })} />
|
<Input value={form.chromium} onChange={(e) => setForm({ ...form, chromium: e.target.value })} />
|
||||||
<label>{t("settings.widths")}</label>
|
<label>{t("settings.widths")}</label>
|
||||||
<input value={form.widths} onChange={(e) => setForm({ ...form, widths: e.target.value })} />
|
<Input value={form.widths} onChange={(e) => setForm({ ...form, widths: e.target.value })} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="panel">
|
<div className="panel">
|
||||||
<h3>{t("settings.images")}</h3>
|
<h3>{t("settings.images")}</h3>
|
||||||
<div className="form">
|
<div className="form">
|
||||||
<label>{t("settings.imagesEnabled")}</label>
|
<label>{t("settings.imagesEnabled")}</label>
|
||||||
<input type="checkbox" checked={form.images_enabled} onChange={(e) => setForm({ ...form, images_enabled: e.target.checked })} style={{ justifySelf: "start" }} />
|
<Checkbox checked={form.images_enabled} onChange={(e) => setForm({ ...form, images_enabled: e.target.checked })} style={{ justifySelf: "start" }} />
|
||||||
<label>{t("settings.imagesKey")}</label>
|
<label>{t("settings.imagesKey")}</label>
|
||||||
<input type="password" value={form.images_key} placeholder={cfg.config.images?.api_key === MASK ? t("settings.apiKeyStored") : "fal.ai API key"} onChange={(e) => setForm({ ...form, images_key: e.target.value })} />
|
<Input.Password value={form.images_key} placeholder={cfg.config.images?.api_key === MASK ? t("settings.apiKeyStored") : "fal.ai API key"} onChange={(e) => setForm({ ...form, images_key: e.target.value })} />
|
||||||
<label>{t("settings.imagesDefault")}</label>
|
<label>{t("settings.imagesDefault")}</label>
|
||||||
<select value={form.images_model} onChange={(e) => setForm({ ...form, images_model: e.target.value })}>
|
<Select value={form.images_model} onChange={(e) => setForm({ ...form, images_model: e.target.value })}>
|
||||||
{(cfg.config.images?.models ?? []).map((m: any) => (
|
{(cfg.config.images?.models ?? []).map((m: any) => (
|
||||||
<option key={m.id} value={m.id}>
|
<option key={m.id} value={m.id}>
|
||||||
{m.name ?? m.id}
|
{m.name ?? m.id}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</Select>
|
||||||
<label>{t("settings.monthlyBudget")}</label>
|
<label>{t("settings.monthlyBudget")}</label>
|
||||||
<input type="number" min={0} value={form.images_budget} placeholder="–" onChange={(e) => setForm({ ...form, images_budget: e.target.value })} />
|
<Input type="number" min={0} value={form.images_budget} placeholder="–" onChange={(e) => setForm({ ...form, images_budget: e.target.value })} />
|
||||||
<label>{t("settings.imagesDir")}</label>
|
<label>{t("settings.imagesDir")}</label>
|
||||||
<input value={form.images_dir} onChange={(e) => setForm({ ...form, images_dir: e.target.value })} />
|
<Input value={form.images_dir} onChange={(e) => setForm({ ...form, images_dir: e.target.value })} />
|
||||||
<div className="hint">{t("settings.imagesHint")}</div>
|
<div className="hint">{t("settings.imagesHint")}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{view}
|
{view}
|
||||||
<button className="primary" onClick={save}>
|
<Button type="primary" onClick={save}>
|
||||||
{t("common.save")}
|
{t("common.save")}
|
||||||
</button>
|
</Button>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -575,7 +557,7 @@ function ProviderEditor({ name, p, reload, status }: { name: string; p: Json; re
|
|||||||
return (
|
return (
|
||||||
<div className="panel">
|
<div className="panel">
|
||||||
<h3>
|
<h3>
|
||||||
<input type="checkbox" checked={!!form.enabled} onChange={(e) => setForm({ ...form, enabled: e.target.checked })} title={t("settings.enabled")} />
|
<Checkbox checked={!!form.enabled} onChange={(e) => setForm({ ...form, enabled: e.target.checked })} title={t("settings.enabled")} />
|
||||||
{name}
|
{name}
|
||||||
<span className="chip">{form.kind}</span>
|
<span className="chip">{form.kind}</span>
|
||||||
<span className="chip">{t("settings.modelCount", { n: models.length || discovered.length })}</span>
|
<span className="chip">{t("settings.modelCount", { n: models.length || discovered.length })}</span>
|
||||||
@@ -589,66 +571,65 @@ function ProviderEditor({ name, p, reload, status }: { name: string; p: Json; re
|
|||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
<span className="spacer" />
|
<span className="spacer" />
|
||||||
<button className="small" onClick={() => setOpen(!open)}>
|
<Button size="small" onClick={() => setOpen(!open)}>
|
||||||
{open ? t("common.collapse") : t("common.edit")}
|
{open ? t("common.collapse") : t("common.edit")}
|
||||||
</button>
|
</Button>
|
||||||
</h3>
|
</h3>
|
||||||
{open && (
|
{open && (
|
||||||
<>
|
<>
|
||||||
<div className="form">
|
<div className="form">
|
||||||
<label>{t("settings.kind")}</label>
|
<label>{t("settings.kind")}</label>
|
||||||
<select value={form.kind} onChange={(e) => setForm({ ...form, kind: e.target.value })}>
|
<Select value={form.kind} onChange={(e) => setForm({ ...form, kind: e.target.value })}>
|
||||||
<option value="anthropic">Anthropic Messages API</option>
|
<option value="anthropic">Anthropic Messages API</option>
|
||||||
<option value="openai">OpenAI-compatible</option>
|
<option value="openai">OpenAI-compatible</option>
|
||||||
</select>
|
</Select>
|
||||||
<label>{t("settings.baseUrl")}</label>
|
<label>{t("settings.baseUrl")}</label>
|
||||||
<input value={form.base_url} onChange={(e) => setForm({ ...form, base_url: e.target.value })} />
|
<Input value={form.base_url} onChange={(e) => setForm({ ...form, base_url: e.target.value })} />
|
||||||
<label>{t("settings.apiKey")}</label>
|
<label>{t("settings.apiKey")}</label>
|
||||||
<input
|
<Input.Password
|
||||||
type="password"
|
|
||||||
value={form.api_key}
|
value={form.api_key}
|
||||||
placeholder={p.api_key === MASK ? t("settings.apiKeyStored") : ""}
|
placeholder={p.api_key === MASK ? t("settings.apiKeyStored") : ""}
|
||||||
onChange={(e) => setForm({ ...form, api_key: e.target.value })}
|
onChange={(e) => setForm({ ...form, api_key: e.target.value })}
|
||||||
/>
|
/>
|
||||||
<div className="hint">{t("settings.apiKeyHint")}</div>
|
<div className="hint">{t("settings.apiKeyHint")}</div>
|
||||||
<label>{t("settings.authPrefix")}</label>
|
<label>{t("settings.authPrefix")}</label>
|
||||||
<input value={form.auth_prefix ?? ""} placeholder={form.kind === "openai" ? "Bearer " : ""} onChange={(e) => setForm({ ...form, auth_prefix: e.target.value })} />
|
<Input value={form.auth_prefix ?? ""} placeholder={form.kind === "openai" ? "Bearer " : ""} onChange={(e) => setForm({ ...form, auth_prefix: e.target.value })} />
|
||||||
<label>{t("settings.monthlyBudget")}</label>
|
<label>{t("settings.monthlyBudget")}</label>
|
||||||
<input type="number" min={0} step="1" value={form.monthly_budget ?? ""} placeholder="–" onChange={(e) => setForm({ ...form, monthly_budget: e.target.value })} />
|
<Input type="number" min={0} step="1" value={form.monthly_budget ?? ""} placeholder="–" onChange={(e) => setForm({ ...form, monthly_budget: e.target.value })} />
|
||||||
{/opencode\.ai\/(inference|zen)\/go/.test(form.base_url ?? "") && (
|
{/opencode\.ai\/(inference|zen)\/go/.test(form.base_url ?? "") && (
|
||||||
<>
|
<>
|
||||||
<label>{t("settings.planLimit")}</label>
|
<label>{t("settings.planLimit")}</label>
|
||||||
<input type="number" min={0} step="1" value={form.plan_limit ?? ""} placeholder="–" onChange={(e) => setForm({ ...form, plan_limit: e.target.value })} />
|
<Input type="number" min={0} step="1" value={form.plan_limit ?? ""} placeholder="–" onChange={(e) => setForm({ ...form, plan_limit: e.target.value })} />
|
||||||
<div className="hint">{t("settings.planLimitHint")}</div>
|
<div className="hint">{t("settings.planLimitHint")}</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{form.kind === "anthropic" && (
|
{form.kind === "anthropic" && (
|
||||||
<>
|
<>
|
||||||
<label>{t("settings.adminKey")}</label>
|
<label>{t("settings.adminKey")}</label>
|
||||||
<input type="password" value={form.admin_key} placeholder={p.admin_key === MASK ? t("settings.apiKeyStored") : "sk-ant-admin01-…"} onChange={(e) => setForm({ ...form, admin_key: e.target.value })} />
|
<Input.Password value={form.admin_key} placeholder={p.admin_key === MASK ? t("settings.apiKeyStored") : "sk-ant-admin01-…"} onChange={(e) => setForm({ ...form, admin_key: e.target.value })} />
|
||||||
<div className="hint">{t("settings.adminKeyHint")}</div>
|
<div className="hint">{t("settings.adminKeyHint")}</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<label>{t("settings.maxConcurrency")}</label>
|
<label>{t("settings.maxConcurrency")}</label>
|
||||||
<input type="number" min={1} value={form.max_concurrency ?? ""} placeholder="∞" onChange={(e) => setForm({ ...form, max_concurrency: e.target.value })} />
|
<Input type="number" min={1} value={form.max_concurrency ?? ""} placeholder="∞" onChange={(e) => setForm({ ...form, max_concurrency: e.target.value })} />
|
||||||
<div className="hint">{t("settings.maxConcurrencyHint")}</div>
|
<div className="hint">{t("settings.maxConcurrencyHint")}</div>
|
||||||
</div>
|
</div>
|
||||||
<h3 style={{ marginTop: 16 }}>
|
<h3 style={{ marginTop: 16 }}>
|
||||||
{t("settings.models")}
|
{t("settings.models")}
|
||||||
<span className="spacer" />
|
<span className="spacer" />
|
||||||
{(form.base_url?.includes("openrouter.ai") || form.base_url?.includes("opencode.ai")) && (
|
{(form.base_url?.includes("openrouter.ai") || form.base_url?.includes("opencode.ai")) && (
|
||||||
<button className="small" onClick={fetchPrices}>
|
<Button size="small" onClick={fetchPrices}>
|
||||||
{t("settings.fetchPrices")}
|
{t("settings.fetchPrices")}
|
||||||
</button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
{discovered.length > 0 && (
|
{discovered.length > 0 && (
|
||||||
<button className="small" onClick={addDiscovered}>
|
<Button size="small" onClick={addDiscovered}>
|
||||||
{t("settings.addDiscovered", { n: discovered.length })}
|
{t("settings.addDiscovered", { n: discovered.length })}
|
||||||
</button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
<button className="small" onClick={() => setModels([...models, { id: "" }])}>
|
<Button size="small" onClick={() => setModels([...models, { id: "" }])}>
|
||||||
+ {t("settings.addModel")}
|
+ {t("settings.addModel")}
|
||||||
</button>
|
</Button>
|
||||||
</h3>
|
</h3>
|
||||||
<div className="hint" style={{ marginBottom: 6, fontSize: 12, color: "var(--muted)" }}>
|
<div className="hint" style={{ marginBottom: 6, fontSize: 12, color: "var(--muted)" }}>
|
||||||
{t("settings.pricesHint")}
|
{t("settings.pricesHint")}
|
||||||
@@ -678,34 +659,34 @@ function ProviderEditor({ name, p, reload, status }: { name: string; p: Json; re
|
|||||||
{models.map((m, i) => (
|
{models.map((m, i) => (
|
||||||
<tr key={i}>
|
<tr key={i}>
|
||||||
<td>
|
<td>
|
||||||
<input value={m.id} onChange={(e) => setModel(i, { id: e.target.value })} style={{ minWidth: 160 }} />
|
<Input value={m.id} onChange={(e) => setModel(i, { id: e.target.value })} style={{ minWidth: 160 }} />
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input type="number" value={m.context ?? ""} onChange={(e) => setModel(i, { context: num(e.target.value) })} />
|
<Input type="number" value={m.context ?? ""} onChange={(e) => setModel(i, { context: num(e.target.value) })} />
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input type="number" value={m.max_output ?? ""} onChange={(e) => setModel(i, { max_output: num(e.target.value) })} />
|
<Input type="number" value={m.max_output ?? ""} onChange={(e) => setModel(i, { max_output: num(e.target.value) })} />
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input type="number" value={m.max_input ?? ""} placeholder="–" onChange={(e) => setModel(i, { max_input: num(e.target.value) })} />
|
<Input type="number" value={m.max_input ?? ""} placeholder="–" onChange={(e) => setModel(i, { max_input: num(e.target.value) })} />
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input type="checkbox" checked={!!m.reasoning} onChange={(e) => setModel(i, { reasoning: e.target.checked })} />
|
<Checkbox checked={!!m.reasoning} onChange={(e) => setModel(i, { reasoning: e.target.checked })} />
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input type="checkbox" checked={!!m.vision} onChange={(e) => setModel(i, { vision: e.target.checked })} />
|
<Checkbox checked={!!m.vision} onChange={(e) => setModel(i, { vision: e.target.checked })} />
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<select value={m.effort ?? ""} onChange={(e) => setModel(i, { effort: e.target.value || undefined })}>
|
<Select value={m.effort ?? ""} onChange={(e) => setModel(i, { effort: e.target.value || undefined })}>
|
||||||
<option value="">–</option>
|
<option value="">–</option>
|
||||||
{["low", "medium", "high", "xhigh", "max"].map((x) => (
|
{["low", "medium", "high", "xhigh", "max"].map((x) => (
|
||||||
<option key={x}>{x}</option>
|
<option key={x}>{x}</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</Select>
|
||||||
</td>
|
</td>
|
||||||
{(["input_price", "output_price", "cache_read_price", "cache_write_price"] as const).map((k) => (
|
{(["input_price", "output_price", "cache_read_price", "cache_write_price"] as const).map((k) => (
|
||||||
<td key={k}>
|
<td key={k}>
|
||||||
<input type="number" step="0.01" value={m[k] ?? ""} onChange={(e) => setModel(i, { [k]: num(e.target.value) })} />
|
<Input type="number" step="0.01" value={m[k] ?? ""} onChange={(e) => setModel(i, { [k]: num(e.target.value) })} />
|
||||||
{k === "cache_write_price" && priceExtras(m) && (
|
{k === "cache_write_price" && priceExtras(m) && (
|
||||||
<span className="chip price-extra" title={priceExtras(m)}>
|
<span className="chip price-extra" title={priceExtras(m)}>
|
||||||
+{(m.price_tiers?.length ?? 0) + (m.price_multipliers?.length ?? 0)}
|
+{(m.price_tiers?.length ?? 0) + (m.price_multipliers?.length ?? 0)}
|
||||||
@@ -714,15 +695,15 @@ function ProviderEditor({ name, p, reload, status }: { name: string; p: Json; re
|
|||||||
</td>
|
</td>
|
||||||
))}
|
))}
|
||||||
<td>
|
<td>
|
||||||
<input type="number" min={1} value={m.max_concurrency ?? ""} placeholder="∞" onChange={(e) => setModel(i, { max_concurrency: num(e.target.value) })} />
|
<Input type="number" min={1} value={m.max_concurrency ?? ""} placeholder="∞" onChange={(e) => setModel(i, { max_concurrency: num(e.target.value) })} />
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<ModelSelect value={m.fallback ?? ""} onChange={(v) => setModel(i, { fallback: v || undefined })} emptyLabel="–" />
|
<ModelSelect value={m.fallback ?? ""} onChange={(v) => setModel(i, { fallback: v || undefined })} emptyLabel="–" />
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<button className="small ghost danger" onClick={() => setModels(models.filter((_, j) => j !== i))} aria-label={t("common.remove")}>
|
<Button type="text" danger size="small" onClick={() => setModels(models.filter((_, j) => j !== i))} aria-label={t("common.remove")}>
|
||||||
<Icon name="close" />
|
<Icon name="close" />
|
||||||
</button>
|
</Button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
))}
|
))}
|
||||||
@@ -737,16 +718,16 @@ function ProviderEditor({ name, p, reload, status }: { name: string; p: Json; re
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div className="row" style={{ marginTop: 12 }}>
|
<div className="row" style={{ marginTop: 12 }}>
|
||||||
<button onClick={test} disabled={testing || !form.base_url}>
|
<Button onClick={test} disabled={testing || !form.base_url}>
|
||||||
<Icon name="plug" /> {testing ? t("settings.testing") : t("settings.testConnection")}
|
<Icon name="plug" /> {testing ? t("settings.testing") : t("settings.testConnection")}
|
||||||
</button>
|
</Button>
|
||||||
<button className="primary" onClick={save}>
|
<Button type="primary" onClick={save}>
|
||||||
{t("common.save")}
|
{t("common.save")}
|
||||||
</button>
|
</Button>
|
||||||
<span className="spacer" />
|
<span className="spacer" />
|
||||||
<button className="danger" onClick={remove}>
|
<Button danger onClick={remove}>
|
||||||
{t("common.delete")}
|
{t("common.delete")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
@@ -787,10 +768,10 @@ function Providers({ cfg, reload }: { cfg: ConfigResponse; reload: () => void })
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="row" style={{ marginBottom: 12 }}>
|
<div className="row" style={{ marginBottom: 12 }}>
|
||||||
<button onClick={() => post("/providers/reload").then(reload)}>{t("settings.reloadProviders")}</button>
|
<Button onClick={() => post("/providers/reload").then(reload)}>{t("settings.reloadProviders")}</Button>
|
||||||
<button onClick={recheck} disabled={checking}>
|
<Button onClick={recheck} disabled={checking}>
|
||||||
{checking ? t("settings.providerChecking") : t("settings.providerCheck")}
|
{checking ? t("settings.providerChecking") : t("settings.providerCheck")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
{Object.entries(providers).map(([n, p]) => (
|
{Object.entries(providers).map(([n, p]) => (
|
||||||
<ProviderEditor key={n + JSON.stringify(p)} name={n} p={p} reload={reload} status={status[n]} />
|
<ProviderEditor key={n + JSON.stringify(p)} name={n} p={p} reload={reload} status={status[n]} />
|
||||||
@@ -798,15 +779,15 @@ function Providers({ cfg, reload }: { cfg: ConfigResponse; reload: () => void })
|
|||||||
<div className="panel">
|
<div className="panel">
|
||||||
<h3>{t("settings.addProvider")}</h3>
|
<h3>{t("settings.addProvider")}</h3>
|
||||||
<div className="row">
|
<div className="row">
|
||||||
<select value={preset} onChange={(e) => setPreset(e.target.value)}>
|
<Select value={preset} onChange={(e) => setPreset(e.target.value)}>
|
||||||
{Object.keys(PRESETS).map((k) => (
|
{Object.keys(PRESETS).map((k) => (
|
||||||
<option key={k}>{k}</option>
|
<option key={k}>{k}</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</Select>
|
||||||
<input placeholder={t("settings.providerName")} value={name} onChange={(e) => setName(e.target.value)} />
|
<Input placeholder={t("settings.providerName")} value={name} onChange={(e) => setName(e.target.value)} />
|
||||||
<button className="primary" onClick={add}>
|
<Button type="primary" onClick={add}>
|
||||||
+ {t("common.add")}
|
+ {t("common.add")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
{view}
|
{view}
|
||||||
</div>
|
</div>
|
||||||
@@ -883,9 +864,9 @@ function McpEditor({ name, m, reload, isNew }: { name: string; m: Json; reload:
|
|||||||
{st?.state === "connected" && <span className="chip">{t("mcp.tools", { n: st.tools ?? 0 })}</span>}
|
{st?.state === "connected" && <span className="chip">{t("mcp.tools", { n: st.tools ?? 0 })}</span>}
|
||||||
<span className="spacer" />
|
<span className="spacer" />
|
||||||
{!isNew && (
|
{!isNew && (
|
||||||
<button className="small" onClick={() => setOpen(!open)}>
|
<Button size="small" onClick={() => setOpen(!open)}>
|
||||||
{open ? t("common.collapse") : t("common.edit")}
|
{open ? t("common.collapse") : t("common.edit")}
|
||||||
</button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</h3>
|
</h3>
|
||||||
{st?.state === "failed" && <div className="notice err">{st.error}</div>}
|
{st?.state === "failed" && <div className="notice err">{st.error}</div>}
|
||||||
@@ -893,40 +874,40 @@ function McpEditor({ name, m, reload, isNew }: { name: string; m: Json; reload:
|
|||||||
<>
|
<>
|
||||||
<div className="form">
|
<div className="form">
|
||||||
<label>{t("settings.name")}</label>
|
<label>{t("settings.name")}</label>
|
||||||
<input value={form.name} onChange={(e) => setForm({ ...form, name: e.target.value })} />
|
<Input value={form.name} onChange={(e) => setForm({ ...form, name: e.target.value })} />
|
||||||
<label>{t("settings.kind")}</label>
|
<label>{t("settings.kind")}</label>
|
||||||
<select value={form.type} onChange={(e) => setForm({ ...form, type: e.target.value })}>
|
<Select value={form.type} onChange={(e) => setForm({ ...form, type: e.target.value })}>
|
||||||
<option value="stdio">stdio</option>
|
<option value="stdio">stdio</option>
|
||||||
<option value="http">Streamable HTTP</option>
|
<option value="http">Streamable HTTP</option>
|
||||||
</select>
|
</Select>
|
||||||
{form.type === "stdio" ? (
|
{form.type === "stdio" ? (
|
||||||
<>
|
<>
|
||||||
<label>{t("mcp.command")}</label>
|
<label>{t("mcp.command")}</label>
|
||||||
<input value={form.command} onChange={(e) => setForm({ ...form, command: e.target.value })} placeholder="npx" />
|
<Input value={form.command} onChange={(e) => setForm({ ...form, command: e.target.value })} placeholder="npx" />
|
||||||
<label>{t("mcp.args")}</label>
|
<label>{t("mcp.args")}</label>
|
||||||
<textarea rows={3} value={form.args} onChange={(e) => setForm({ ...form, args: e.target.value })} className="mono" />
|
<Input.TextArea rows={3} value={form.args} onChange={(e) => setForm({ ...form, args: e.target.value })} className="mono" />
|
||||||
<label>{t("mcp.env")}</label>
|
<label>{t("mcp.env")}</label>
|
||||||
<textarea rows={2} value={form.env} onChange={(e) => setForm({ ...form, env: e.target.value })} className="mono" placeholder="KEY=${SECRET}" />
|
<Input.TextArea rows={2} value={form.env} onChange={(e) => setForm({ ...form, env: e.target.value })} className="mono" placeholder="KEY=${SECRET}" />
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<label>URL</label>
|
<label>URL</label>
|
||||||
<input value={form.url} onChange={(e) => setForm({ ...form, url: e.target.value })} placeholder="https://…/mcp" />
|
<Input value={form.url} onChange={(e) => setForm({ ...form, url: e.target.value })} placeholder="https://…/mcp" />
|
||||||
<label>{t("mcp.headers")}</label>
|
<label>{t("mcp.headers")}</label>
|
||||||
<textarea rows={2} value={form.headers} onChange={(e) => setForm({ ...form, headers: e.target.value })} className="mono" placeholder="Authorization: Bearer ${TOKEN}" />
|
<Input.TextArea rows={2} value={form.headers} onChange={(e) => setForm({ ...form, headers: e.target.value })} className="mono" placeholder="Authorization: Bearer ${TOKEN}" />
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<label>{t("settings.enabled")}</label>
|
<label>{t("settings.enabled")}</label>
|
||||||
<input type="checkbox" checked={form.enabled} onChange={(e) => setForm({ ...form, enabled: e.target.checked })} style={{ justifySelf: "start" }} />
|
<Checkbox checked={form.enabled} onChange={(e) => setForm({ ...form, enabled: e.target.checked })} style={{ justifySelf: "start" }} />
|
||||||
<label>{t("mcp.load")}</label>
|
<label>{t("mcp.load")}</label>
|
||||||
<select value={form.load} onChange={(e) => setForm({ ...form, load: e.target.value })}>
|
<Select value={form.load} onChange={(e) => setForm({ ...form, load: e.target.value })}>
|
||||||
<option value="auto">{t("mcp.loadAuto")}</option>
|
<option value="auto">{t("mcp.loadAuto")}</option>
|
||||||
<option value="always">{t("mcp.loadAlways")}</option>
|
<option value="always">{t("mcp.loadAlways")}</option>
|
||||||
<option value="on_demand">{t("mcp.loadOnDemand")}</option>
|
<option value="on_demand">{t("mcp.loadOnDemand")}</option>
|
||||||
</select>
|
</Select>
|
||||||
<div className="hint">{t("mcp.loadHint")}</div>
|
<div className="hint">{t("mcp.loadHint")}</div>
|
||||||
<label>{t("mcp.users")}</label>
|
<label>{t("mcp.users")}</label>
|
||||||
<input value={form.users} onChange={(e) => setForm({ ...form, users: e.target.value })} placeholder={t("mcp.usersPlaceholder")} />
|
<Input value={form.users} onChange={(e) => setForm({ ...form, users: e.target.value })} placeholder={t("mcp.usersPlaceholder")} />
|
||||||
<div className="hint">{t("mcp.usersHint")}</div>
|
<div className="hint">{t("mcp.usersHint")}</div>
|
||||||
</div>
|
</div>
|
||||||
{status?.tools?.length ? (
|
{status?.tools?.length ? (
|
||||||
@@ -943,14 +924,14 @@ function McpEditor({ name, m, reload, isNew }: { name: string; m: Json; reload:
|
|||||||
) : null}
|
) : null}
|
||||||
{view}
|
{view}
|
||||||
<div className="row" style={{ marginTop: 12 }}>
|
<div className="row" style={{ marginTop: 12 }}>
|
||||||
<button className="primary" onClick={save}>
|
<Button type="primary" onClick={save}>
|
||||||
{t("common.save")}
|
{t("common.save")}
|
||||||
</button>
|
</Button>
|
||||||
<span className="spacer" />
|
<span className="spacer" />
|
||||||
{!isNew && (
|
{!isNew && (
|
||||||
<button className="danger" onClick={() => void confirmDialog({ message: t("settings.deleteMcpConfirm", { name }), danger: true, confirmLabel: t("common.delete") }).then((ok): unknown => ok && run(() => savePatches([{ path: ["mcp", name], value: null }])))}>
|
<Button danger onClick={() => void confirmDialog({ message: t("settings.deleteMcpConfirm", { name }), danger: true, confirmLabel: t("common.delete") }).then((ok): unknown => ok && run(() => savePatches([{ path: ["mcp", name], value: null }])))}>
|
||||||
{t("common.delete")}
|
{t("common.delete")}
|
||||||
</button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
@@ -965,7 +946,7 @@ function Mcp({ cfg, reload }: { cfg: ConfigResponse; reload: () => void }) {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="row" style={{ marginBottom: 12 }}>
|
<div className="row" style={{ marginBottom: 12 }}>
|
||||||
<button onClick={() => post("/mcp/reload")}>{t("mcp.reconnect")}</button>
|
<Button onClick={() => post("/mcp/reload")}>{t("mcp.reconnect")}</Button>
|
||||||
</div>
|
</div>
|
||||||
{Object.keys(servers).length === 0 && <div className="notice">{t("mcp.none")}</div>}
|
{Object.keys(servers).length === 0 && <div className="notice">{t("mcp.none")}</div>}
|
||||||
{Object.entries(servers).map(([n, m]) => (
|
{Object.entries(servers).map(([n, m]) => (
|
||||||
@@ -993,29 +974,29 @@ function RuleTable({ rules, setRules, choices, keyLabel }: { rules: [string, str
|
|||||||
{rules.map(([k, v], i) => (
|
{rules.map(([k, v], i) => (
|
||||||
<tr key={i}>
|
<tr key={i}>
|
||||||
<td>
|
<td>
|
||||||
<input className="mono" value={k} onChange={(e) => setRules(rules.map((r, j) => (j === i ? [e.target.value, r[1]] : r)))} />
|
<Input className="mono" value={k} onChange={(e) => setRules(rules.map((r, j) => (j === i ? [e.target.value, r[1]] : r)))} />
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<select value={v} onChange={(e) => setRules(rules.map((r, j) => (j === i ? [r[0], e.target.value] : r)))}>
|
<Select value={v} onChange={(e) => setRules(rules.map((r, j) => (j === i ? [r[0], e.target.value] : r)))}>
|
||||||
{choices.map((c) => (
|
{choices.map((c) => (
|
||||||
<option key={c} value={c}>
|
<option key={c} value={c}>
|
||||||
{t(`permissions.${c}` as Key)}
|
{t(`permissions.${c}` as Key)}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</Select>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<button className="small ghost danger" onClick={() => setRules(rules.filter((_, j) => j !== i))} aria-label={t("common.remove")}>
|
<Button type="text" danger size="small" onClick={() => setRules(rules.filter((_, j) => j !== i))} aria-label={t("common.remove")}>
|
||||||
<Icon name="close" />
|
<Icon name="close" />
|
||||||
</button>
|
</Button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
))}
|
))}
|
||||||
<tr>
|
<tr>
|
||||||
<td colSpan={3}>
|
<td colSpan={3}>
|
||||||
<button className="small" onClick={() => setRules([...rules, ["", choices[0]]])}>
|
<Button size="small" onClick={() => setRules([...rules, ["", choices[0]]])}>
|
||||||
+ {t("common.add")}
|
+ {t("common.add")}
|
||||||
</button>
|
</Button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
@@ -1055,9 +1036,9 @@ function Permissions({ cfg, reload }: { cfg: ConfigResponse; reload: () => void
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{view}
|
{view}
|
||||||
<button className="primary" onClick={save}>
|
<Button type="primary" onClick={save}>
|
||||||
{t("common.save")}
|
{t("common.save")}
|
||||||
</button>
|
</Button>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1075,13 +1056,13 @@ function Raw({ reload }: { reload: () => void }) {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="notice">{t("settings.rawHint")}</div>
|
<div className="notice">{t("settings.rawHint")}</div>
|
||||||
<textarea className="raw-editor" spellCheck={false} value={text} onChange={(e) => setText(e.target.value)} />
|
<Input.TextArea className="raw-editor" spellCheck={false} value={text} onChange={(e) => setText(e.target.value)} />
|
||||||
{view}
|
{view}
|
||||||
<div className="row" style={{ marginTop: 8 }}>
|
<div className="row" style={{ marginTop: 8 }}>
|
||||||
<button className="primary" onClick={() => run(() => put("/config/raw", { text }))}>
|
<Button type="primary" onClick={() => run(() => put("/config/raw", { text }))}>
|
||||||
{t("common.save")}
|
{t("common.save")}
|
||||||
</button>
|
</Button>
|
||||||
<button onClick={() => get<{ text: string }>("/config/raw").then((r) => setText(r.text))}>{t("settings.revert")}</button>
|
<Button onClick={() => get<{ text: string }>("/config/raw").then((r) => setText(r.text))}>{t("settings.revert")}</Button>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
@@ -1118,23 +1099,29 @@ export function Settings({ tab, onMenu }: { tab?: string; onMenu: () => void })
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="topbar">
|
<div className="topbar">
|
||||||
<button className="ghost menu-btn" onClick={onMenu} aria-label={t("nav.menu")}>
|
<Button type="text" className="menu-btn" onClick={onMenu} aria-label={t("nav.menu")}>
|
||||||
<Icon name="menu" />
|
<Icon name="menu" />
|
||||||
</button>
|
</Button>
|
||||||
<div className="grow">
|
<div className="grow">
|
||||||
<h1>{t("nav.settings")}</h1>
|
<h1>{t("nav.settings")}</h1>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="page">
|
<div className="page">
|
||||||
<div className="page-inner">
|
<div className="page-inner">
|
||||||
<div className="tabs" role="tablist">
|
<Tabs
|
||||||
{TABS.map((x) => (
|
className="settings-tabs"
|
||||||
<button key={x} role="tab" aria-selected={active === x} className={active === x ? "active" : ""} onClick={() => navigate(`/settings/${x}`)}>
|
activeKey={active}
|
||||||
|
onChange={(x) => navigate(`/settings/${x}`)}
|
||||||
|
items={TABS.map((x) => ({
|
||||||
|
key: x,
|
||||||
|
label: (
|
||||||
|
<span className="tab-label">
|
||||||
<Icon name={TAB_ICONS[x]} className="nav-icon" />
|
<Icon name={TAB_ICONS[x]} className="nav-icon" />
|
||||||
{t(`settings.tab.${x}` as Key)}
|
{t(`settings.tab.${x}` as Key)}
|
||||||
</button>
|
</span>
|
||||||
))}
|
),
|
||||||
</div>
|
}))}
|
||||||
|
/>
|
||||||
{error && <div className="notice err">{error}</div>}
|
{error && <div className="notice err">{error}</div>}
|
||||||
{isAdmin && !cfg && !error && <div className="empty">{t("common.loading")}</div>}
|
{isAdmin && !cfg && !error && <div className="empty">{t("common.loading")}</div>}
|
||||||
{!isAdmin && active === "general" && <InterfaceSettings />}
|
{!isAdmin && active === "general" && <InterfaceSettings />}
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
import { Button, Checkbox, Input } from "antd";
|
||||||
|
import { Select } from "../ui/Select";
|
||||||
|
import { Modal } from "../ui/Modal";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { del, get, post, put } from "../api";
|
import { del, get, post, put } from "../api";
|
||||||
import { useT } from "../i18n";
|
import { useT } from "../i18n";
|
||||||
@@ -39,21 +42,21 @@ function Links({ sessionId }: { sessionId: string }) {
|
|||||||
<div className="hint">{t("link.hint")}</div>
|
<div className="hint">{t("link.hint")}</div>
|
||||||
{links.map((l) => (
|
{links.map((l) => (
|
||||||
<div key={l.token} className="row share-link">
|
<div key={l.token} className="row share-link">
|
||||||
<input readOnly value={l.url} onFocus={(e) => e.currentTarget.select()} aria-label={t("link.title")} />
|
<Input readOnly value={l.url} onFocus={(e) => e.currentTarget.select()} aria-label={t("link.title")} />
|
||||||
<span className="hint">{t("link.until", { date: fmtDate(l.expires_at, false) })}</span>
|
<span className="hint">{t("link.until", { date: fmtDate(l.expires_at, false) })}</span>
|
||||||
<button onClick={() => navigator.clipboard?.writeText(l.url).then(() => toast(t("link.copied"), "success"))}>{t("link.copy")}</button>
|
<Button onClick={() => navigator.clipboard?.writeText(l.url).then(() => toast(t("link.copied"), "success"))}>{t("link.copy")}</Button>
|
||||||
<button onClick={() => del(`/sessions/${sessionId}/links/${l.token}`).then(load).catch((e) => toast(e.message))}>{t("link.revoke")}</button>
|
<Button onClick={() => del(`/sessions/${sessionId}/links/${l.token}`).then(load).catch((e) => toast(e.message))}>{t("link.revoke")}</Button>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
<div className="row" style={{ marginTop: 6 }}>
|
<div className="row" style={{ marginTop: 6 }}>
|
||||||
<select value={days} onChange={(e) => setDays(Number(e.target.value))} aria-label={t("link.validity")}>
|
<Select value={days} onChange={(e) => setDays(Number(e.target.value))} aria-label={t("link.validity")}>
|
||||||
{[1, 7, 30, 90].map((d) => (
|
{[1, 7, 30, 90].map((d) => (
|
||||||
<option key={d} value={d}>
|
<option key={d} value={d}>
|
||||||
{t("link.days", { n: d })}
|
{t("link.days", { n: d })}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</Select>
|
||||||
<button onClick={create}>{t("link.create")}</button>
|
<Button onClick={create}>{t("link.create")}</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -87,37 +90,30 @@ export function ShareDialog({ sessionId, onClose }: { sessionId: string; onClose
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="modal-backdrop" onClick={onClose}>
|
<Modal onClose={onClose} role="dialog" aria-label={t("share.title")}>
|
||||||
<div className="modal" role="dialog" aria-label={t("share.title")} onClick={(e) => e.stopPropagation()}>
|
|
||||||
<h3>{t("share.title")}</h3>
|
<h3>{t("share.title")}</h3>
|
||||||
<div style={{ fontSize: 13, color: "var(--muted)", marginBottom: 8 }}>{t("share.hint")}</div>
|
<div style={{ fontSize: 13, color: "var(--muted)", marginBottom: 8 }}>{t("share.hint")}</div>
|
||||||
<div className="check-list">
|
<div className="check-list">
|
||||||
{users.length === 0 && <div className="empty">{t("share.noUsers")}</div>}
|
{users.length === 0 && <div className="empty">{t("share.noUsers")}</div>}
|
||||||
{users.map((u) => (
|
{users.map((u) => (
|
||||||
<label key={u.id}>
|
<Checkbox key={u.id} checked={selected.has(u.id)} onChange={(e) => {
|
||||||
<input
|
|
||||||
type="checkbox"
|
|
||||||
checked={selected.has(u.id)}
|
|
||||||
onChange={(e) => {
|
|
||||||
const next = new Set(selected);
|
const next = new Set(selected);
|
||||||
if (e.target.checked) next.add(u.id);
|
if (e.target.checked) next.add(u.id);
|
||||||
else next.delete(u.id);
|
else next.delete(u.id);
|
||||||
setSelected(next);
|
setSelected(next);
|
||||||
}}
|
}}>
|
||||||
/>
|
|
||||||
{u.display_name || u.username} <span style={{ color: "var(--muted)" }}>@{u.username}</span>
|
{u.display_name || u.username} <span style={{ color: "var(--muted)" }}>@{u.username}</span>
|
||||||
</label>
|
</Checkbox>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
<Links sessionId={sessionId} />
|
<Links sessionId={sessionId} />
|
||||||
{error && <div className="notice err">{error}</div>}
|
{error && <div className="notice err">{error}</div>}
|
||||||
<div className="row" style={{ marginTop: 12, justifyContent: "flex-end" }}>
|
<div className="row" style={{ marginTop: 12, justifyContent: "flex-end" }}>
|
||||||
<button onClick={onClose}>{t("common.cancel")}</button>
|
<Button onClick={onClose}>{t("common.cancel")}</Button>
|
||||||
<button className="primary" onClick={save}>
|
<Button type="primary" onClick={save}>
|
||||||
{t("common.save")}
|
{t("common.save")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
</Modal>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { Button, Input } from "antd";
|
||||||
|
import { Modal } from "../ui/Modal";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { fmtRelative, useT } from "../i18n";
|
import { fmtRelative, useT } from "../i18n";
|
||||||
import { navigate } from "../router";
|
import { navigate } from "../router";
|
||||||
@@ -28,32 +30,30 @@ export function ShareTarget({ shared, onClose }: { shared: string; onClose: () =
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="modal-backdrop" onClick={cancel}>
|
<Modal onClose={cancel} className="share-target" role="dialog" aria-label={t("shareIn.title")}>
|
||||||
<div className="modal share-target" role="dialog" aria-label={t("shareIn.title")} onClick={(e) => e.stopPropagation()}>
|
|
||||||
<h3>{t("shareIn.title")}</h3>
|
<h3>{t("shareIn.title")}</h3>
|
||||||
<textarea value={text} onChange={(e) => setText(e.target.value)} rows={4} />
|
<Input.TextArea value={text} onChange={(e) => setText(e.target.value)} rows={4} />
|
||||||
<button className="primary share-new" onClick={() => done("new")} disabled={!text.trim()}>
|
<Button type="primary" className="share-new" onClick={() => done("new")} disabled={!text.trim()}>
|
||||||
<Icon name="plus" /> {t("shareIn.newChat")}
|
<Icon name="plus" /> {t("shareIn.newChat")}
|
||||||
</button>
|
</Button>
|
||||||
{sessions.length > 0 && (
|
{sessions.length > 0 && (
|
||||||
<>
|
<>
|
||||||
<div className="share-sep">{t("shareIn.appendTo")}</div>
|
<div className="share-sep">{t("shareIn.appendTo")}</div>
|
||||||
<div className="share-list">
|
<div className="share-list">
|
||||||
{sessions.map((s) => (
|
{sessions.map((s) => (
|
||||||
<button key={s.id} onClick={() => done(s.id)} disabled={!text.trim()}>
|
<Button key={s.id} onClick={() => done(s.id)} disabled={!text.trim()}>
|
||||||
<span className="share-title">{s.title || t("session.untitled")}</span>
|
<span className="share-title">{s.title || t("session.untitled")}</span>
|
||||||
<span className="share-meta">
|
<span className="share-meta">
|
||||||
{basename(s.cwd)} · {fmtRelative(s.updated_at)}
|
{basename(s.cwd)} · {fmtRelative(s.updated_at)}
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</Button>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<div className="row" style={{ marginTop: 12, justifyContent: "flex-end" }}>
|
<div className="row" style={{ marginTop: 12, justifyContent: "flex-end" }}>
|
||||||
<button onClick={cancel}>{t("common.cancel")}</button>
|
<Button onClick={cancel}>{t("common.cancel")}</Button>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
</Modal>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { Button, Segmented } from "antd";
|
||||||
|
import { Modal } from "../ui/Modal";
|
||||||
import { Icon } from "./Icon";
|
import { Icon } from "./Icon";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { get, post } from "../api";
|
import { get, post } from "../api";
|
||||||
@@ -44,37 +46,41 @@ export function ShellsChip({ sessionId, busy }: { sessionId: string; busy: boole
|
|||||||
{running ? <Spinner small /> : <Icon name="terminal" />} {t("shells.chip", { n: running, total: shells.length })}
|
{running ? <Spinner small /> : <Icon name="terminal" />} {t("shells.chip", { n: running, total: shells.length })}
|
||||||
</button>
|
</button>
|
||||||
{open && (
|
{open && (
|
||||||
<div className="modal-backdrop" onClick={() => setOpen(false)}>
|
<Modal onClose={() => setOpen(false)} className="wide" role="dialog" aria-label={t("shells.title")}>
|
||||||
<div className="modal wide" role="dialog" aria-label={t("shells.title")} onClick={(e) => e.stopPropagation()}>
|
|
||||||
<div className="row" style={{ marginBottom: 8 }}>
|
<div className="row" style={{ marginBottom: 8 }}>
|
||||||
<h3 style={{ margin: 0 }}>{t("shells.title")}</h3>
|
<h3 style={{ margin: 0 }}>{t("shells.title")}</h3>
|
||||||
<span className="spacer" />
|
<span className="spacer" />
|
||||||
<button className="small ghost" onClick={() => setOpen(false)} aria-label={t("common.close")}>
|
<Button type="text" size="small" onClick={() => setOpen(false)} aria-label={t("common.close")}>
|
||||||
<Icon name="close" />
|
<Icon name="close" />
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
|
||||||
<div className="mode-tabs" style={{ flexWrap: "wrap", marginBottom: 8 }}>
|
|
||||||
{shells.map((s) => (
|
|
||||||
<button key={s.id} className={s.id === current.id ? "active" : ""} onClick={() => setSelected(s.id)}>
|
|
||||||
<Icon name={s.running ? "dot" : "radio-off"} className={`tiny ${s.running ? "ok" : ""}`} />{" "}
|
|
||||||
{s.command.slice(0, 40)}
|
|
||||||
</button>
|
|
||||||
))}
|
|
||||||
</div>
|
</div>
|
||||||
|
<Segmented
|
||||||
|
className="seg-wrap"
|
||||||
|
style={{ marginBottom: 8 }}
|
||||||
|
value={current.id}
|
||||||
|
onChange={setSelected}
|
||||||
|
options={shells.map((s) => ({
|
||||||
|
value: s.id,
|
||||||
|
label: (
|
||||||
|
<>
|
||||||
|
<Icon name={s.running ? "dot" : "radio-off"} className={`tiny ${s.running ? "ok" : ""}`} /> {s.command.slice(0, 40)}
|
||||||
|
</>
|
||||||
|
),
|
||||||
|
}))}
|
||||||
|
/>
|
||||||
<div className="row" style={{ fontSize: 12.5, color: "var(--muted)", marginBottom: 6 }}>
|
<div className="row" style={{ fontSize: 12.5, color: "var(--muted)", marginBottom: 6 }}>
|
||||||
<code>{current.command}</code>
|
<code>{current.command}</code>
|
||||||
<span>· {fmtRelative(current.started_at)}</span>
|
<span>· {fmtRelative(current.started_at)}</span>
|
||||||
<span>· {current.running ? t("shells.running") : t("shells.exited", { code: current.exit_code ?? "?" })}</span>
|
<span>· {current.running ? t("shells.running") : t("shells.exited", { code: current.exit_code ?? "?" })}</span>
|
||||||
<span className="spacer" />
|
<span className="spacer" />
|
||||||
{current.running && (
|
{current.running && (
|
||||||
<button className="small danger" onClick={() => post(`/sessions/${sessionId}/shells/${current.id}/kill`).catch(toast)}>
|
<Button danger size="small" onClick={() => post(`/sessions/${sessionId}/shells/${current.id}/kill`).catch(toast)}>
|
||||||
<Icon name="stop" /> {t("shells.stop")}
|
<Icon name="stop" /> {t("shells.stop")}
|
||||||
</button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<pre className="shell-output">{current.output || t("shells.noOutput")}</pre>
|
<pre className="shell-output">{current.output || t("shells.noOutput")}</pre>
|
||||||
</div>
|
</Modal>
|
||||||
</div>
|
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { Button, Input } from "antd";
|
||||||
import { deleteChat } from "../chatActions";
|
import { deleteChat } from "../chatActions";
|
||||||
import { Icon } from "./Icon";
|
import { Icon } from "./Icon";
|
||||||
import { StatusLeds } from "./StatusLeds";
|
import { StatusLeds } from "./StatusLeds";
|
||||||
@@ -83,35 +84,34 @@ function SessionRow({ s, active, attention, busy, folders }: { s: Session; activ
|
|||||||
{menu && (
|
{menu && (
|
||||||
<div className="session-menu" role="menu" onClick={(e) => e.stopPropagation()}>
|
<div className="session-menu" role="menu" onClick={(e) => e.stopPropagation()}>
|
||||||
{!s.archived && (
|
{!s.archived && (
|
||||||
<button role="menuitem" onClick={() => (setMenu(false), organise(s.id, { pinned: !s.pinned }))}>
|
<Button role="menuitem" onClick={() => (setMenu(false), organise(s.id, { pinned: !s.pinned }))}>
|
||||||
<Icon name="pin" /> {t(s.pinned ? "sidebar.unpin" : "sidebar.pin")}
|
<Icon name="pin" /> {t(s.pinned ? "sidebar.unpin" : "sidebar.pin")}
|
||||||
</button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
<button role="menuitem" className="hide-mobile" onClick={() => (setMenu(false), openBeside(s.id))}>
|
<Button role="menuitem" className="hide-mobile" onClick={() => (setMenu(false), openBeside(s.id))}>
|
||||||
<Icon name="external" /> {t("sidebar.openBeside")}
|
<Icon name="external" /> {t("sidebar.openBeside")}
|
||||||
</button>
|
</Button>
|
||||||
<button role="menuitem" onClick={() => (setMenu(false), void moveTo())}>
|
<Button role="menuitem" onClick={() => (setMenu(false), void moveTo())}>
|
||||||
<Icon name="folder" /> {t("sidebar.moveTo")}
|
<Icon name="folder" /> {t("sidebar.moveTo")}
|
||||||
</button>
|
</Button>
|
||||||
{s.folder && (
|
{s.folder && (
|
||||||
<button role="menuitem" onClick={() => (setMenu(false), organise(s.id, { folder: "" }))}>
|
<Button role="menuitem" onClick={() => (setMenu(false), organise(s.id, { folder: "" }))}>
|
||||||
<Icon name="folder-up" /> {t("sidebar.removeFromFolder")}
|
<Icon name="folder-up" /> {t("sidebar.removeFromFolder")}
|
||||||
</button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
<button role="menuitem" onClick={() => (setMenu(false), organise(s.id, { archived: !s.archived }))}>
|
<Button role="menuitem" onClick={() => (setMenu(false), organise(s.id, { archived: !s.archived }))}>
|
||||||
<Icon name="archive" /> {t(s.archived ? "sidebar.unarchive" : "sidebar.archiveOne")}
|
<Icon name="archive" /> {t(s.archived ? "sidebar.unarchive" : "sidebar.archiveOne")}
|
||||||
</button>
|
</Button>
|
||||||
{!s.shared && (
|
{!s.shared && (
|
||||||
<button
|
<Button danger
|
||||||
role="menuitem"
|
role="menuitem"
|
||||||
className="danger"
|
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
setMenu(false);
|
setMenu(false);
|
||||||
if ((await deleteChat(s)) && active) navigate("/new");
|
if ((await deleteChat(s)) && active) navigate("/new");
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Icon name="trash" /> {t("chat.delete")}
|
<Icon name="trash" /> {t("chat.delete")}
|
||||||
</button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
@@ -212,19 +212,19 @@ function GroupHeader({
|
|||||||
{menu && (
|
{menu && (
|
||||||
<div className="session-menu" role="menu" onClick={(e) => e.stopPropagation()}>
|
<div className="session-menu" role="menu" onClick={(e) => e.stopPropagation()}>
|
||||||
{g.id.startsWith("project:") && (
|
{g.id.startsWith("project:") && (
|
||||||
<button role="menuitem" onClick={() => (setMenu(false), navigate(`/p/${encodeURIComponent(g.id.slice("project:".length))}`))}>
|
<Button role="menuitem" onClick={() => (setMenu(false), navigate(`/p/${encodeURIComponent(g.id.slice("project:".length))}`))}>
|
||||||
<Icon name="clock" /> {t("project.open")}
|
<Icon name="clock" /> {t("project.open")}
|
||||||
</button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
<button role="menuitem" onClick={() => (setMenu(false), onPin?.())}>
|
<Button role="menuitem" onClick={() => (setMenu(false), onPin?.())}>
|
||||||
<Icon name="pin" /> {t(pinned ? "sidebar.groupUnpin" : "sidebar.groupPin")}
|
<Icon name="pin" /> {t(pinned ? "sidebar.groupUnpin" : "sidebar.groupPin")}
|
||||||
</button>
|
</Button>
|
||||||
<button role="menuitem" onClick={() => (setMenu(false), onMove?.(-1))}>
|
<Button role="menuitem" onClick={() => (setMenu(false), onMove?.(-1))}>
|
||||||
<Icon name="arrow-up" /> {t("sidebar.groupUp")}
|
<Icon name="arrow-up" /> {t("sidebar.groupUp")}
|
||||||
</button>
|
</Button>
|
||||||
<button role="menuitem" onClick={() => (setMenu(false), onMove?.(1))}>
|
<Button role="menuitem" onClick={() => (setMenu(false), onMove?.(1))}>
|
||||||
<Icon name="arrow-down" /> {t("sidebar.groupDown")}
|
<Icon name="arrow-down" /> {t("sidebar.groupDown")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
@@ -398,12 +398,12 @@ export function Sidebar({ open, activeIds, section }: { open: boolean; activeIds
|
|||||||
<StatusLeds />
|
<StatusLeds />
|
||||||
</div>
|
</div>
|
||||||
<div style={{ padding: "0 12px 8px" }}>
|
<div style={{ padding: "0 12px 8px" }}>
|
||||||
<button className="primary" style={{ width: "100%" }} onClick={() => navigate("/new")}>
|
<Button type="primary" style={{ width: "100%" }} onClick={() => navigate("/new")}>
|
||||||
+ {t("sidebar.newSession")}
|
+ {t("sidebar.newSession")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<div className="session-search">
|
<div className="session-search">
|
||||||
<input
|
<Input
|
||||||
type="search"
|
type="search"
|
||||||
value={query}
|
value={query}
|
||||||
placeholder={t("sidebar.search")}
|
placeholder={t("sidebar.search")}
|
||||||
@@ -433,10 +433,10 @@ export function Sidebar({ open, activeIds, section }: { open: boolean; activeIds
|
|||||||
{!hits && sessions.length === 0 && <div className="empty">{t("sidebar.noSessions")}</div>}
|
{!hits && sessions.length === 0 && <div className="empty">{t("sidebar.noSessions")}</div>}
|
||||||
{!hits && sessions.length > 0 && (
|
{!hits && sessions.length > 0 && (
|
||||||
<div className="session-view">
|
<div className="session-view">
|
||||||
<button className="ghost small" onClick={switchGroupBy} title={t("sidebar.groupByHint")}>
|
<Button type="text" size="small" onClick={switchGroupBy} title={t("sidebar.groupByHint")}>
|
||||||
<Icon name={groupBy === "time" ? "clock" : "folders"} className="tiny" />
|
<Icon name={groupBy === "time" ? "clock" : "folders"} className="tiny" />
|
||||||
{t(groupBy === "time" ? "sidebar.byTime" : "sidebar.byProject")}
|
{t(groupBy === "time" ? "sidebar.byTime" : "sidebar.byProject")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{!hits &&
|
{!hits &&
|
||||||
@@ -469,40 +469,40 @@ export function Sidebar({ open, activeIds, section }: { open: boolean; activeIds
|
|||||||
{me?.role === "admin" && <span className="chip" style={{ marginLeft: 6 }}>admin</span>}
|
{me?.role === "admin" && <span className="chip" style={{ marginLeft: 6 }}>admin</span>}
|
||||||
</span>
|
</span>
|
||||||
<ThemeModeButton />
|
<ThemeModeButton />
|
||||||
<button className="small ghost" onClick={() => post("/auth/logout").then(() => location.reload())}>
|
<Button type="text" size="small" onClick={() => post("/auth/logout").then(() => location.reload())}>
|
||||||
<Icon name="logout" className="nav-icon" />
|
<Icon name="logout" className="nav-icon" />
|
||||||
{t("nav.logout")}
|
{t("nav.logout")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<div className="sidebar-foot">
|
<div className="sidebar-foot">
|
||||||
<button className={`ghost ${section === "files" ? "active" : ""}`} onClick={() => navigate("/files")}>
|
<Button type="text" className={section === "files" ? "active" : ""} onClick={() => navigate("/files")}>
|
||||||
<Icon name="folder" className="nav-icon" />
|
<Icon name="folder" className="nav-icon" />
|
||||||
{t("nav.files")}
|
{t("nav.files")}
|
||||||
</button>
|
</Button>
|
||||||
<button className={`ghost ${section === "images" ? "active" : ""}`} onClick={() => navigate("/images")}>
|
<Button type="text" className={section === "images" ? "active" : ""} onClick={() => navigate("/images")}>
|
||||||
<Icon name="image" className="nav-icon" />
|
<Icon name="image" className="nav-icon" />
|
||||||
{t("nav.images")}
|
{t("nav.images")}
|
||||||
</button>
|
</Button>
|
||||||
<button className={`ghost ${section === "terminal" ? "active" : ""}`} onClick={() => navigate("/terminal")}>
|
<Button type="text" className={section === "terminal" ? "active" : ""} onClick={() => navigate("/terminal")}>
|
||||||
<Icon name="terminal" className="nav-icon" />
|
<Icon name="terminal" className="nav-icon" />
|
||||||
{t("nav.terminal")}
|
{t("nav.terminal")}
|
||||||
</button>
|
</Button>
|
||||||
<button className={`ghost ${section === "jobs" ? "active" : ""}`} onClick={() => navigate("/jobs")}>
|
<Button type="text" className={section === "jobs" ? "active" : ""} onClick={() => navigate("/jobs")}>
|
||||||
<Icon name="clock" className="nav-icon" />
|
<Icon name="clock" className="nav-icon" />
|
||||||
{t("nav.jobs")}
|
{t("nav.jobs")}
|
||||||
</button>
|
</Button>
|
||||||
<button className={`ghost ${section === "factory" ? "active" : ""}`} onClick={() => navigate("/factory")}>
|
<Button type="text" className={section === "factory" ? "active" : ""} onClick={() => navigate("/factory")}>
|
||||||
<Icon name="factory" className="nav-icon" />
|
<Icon name="factory" className="nav-icon" />
|
||||||
{t("nav.factory")}
|
{t("nav.factory")}
|
||||||
</button>
|
</Button>
|
||||||
<button className={`ghost ${section === "stats" ? "active" : ""}`} onClick={() => navigate("/stats")}>
|
<Button type="text" className={section === "stats" ? "active" : ""} onClick={() => navigate("/stats")}>
|
||||||
<Icon name="chart" className="nav-icon" />
|
<Icon name="chart" className="nav-icon" />
|
||||||
{t("nav.stats")}
|
{t("nav.stats")}
|
||||||
</button>
|
</Button>
|
||||||
<button className={`ghost ${section === "settings" ? "active" : ""}`} onClick={() => navigate("/settings")}>
|
<Button type="text" className={section === "settings" ? "active" : ""} onClick={() => navigate("/settings")}>
|
||||||
<Icon name="wrench" className="nav-icon" />
|
<Icon name="wrench" className="nav-icon" />
|
||||||
{t("nav.settings")}
|
{t("nav.settings")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</aside>
|
</aside>
|
||||||
);
|
);
|
||||||
@@ -515,8 +515,8 @@ function ThemeModeButton() {
|
|||||||
const icon = <Icon name={mode === "auto" ? "theme-auto" : mode === "light" ? "sun" : "moon"} />;
|
const icon = <Icon name={mode === "auto" ? "theme-auto" : mode === "light" ? "sun" : "moon"} />;
|
||||||
const label = t(mode === "auto" ? "settings.themeAuto" : mode === "light" ? "settings.themeLight" : "settings.themeDark");
|
const label = t(mode === "auto" ? "settings.themeAuto" : mode === "light" ? "settings.themeLight" : "settings.themeDark");
|
||||||
return (
|
return (
|
||||||
<button className="small ghost theme-toggle" onClick={cycleThemeMode} title={`${t("settings.themeToggle")} – ${label}`} aria-label={t("settings.themeToggle")}>
|
<Button type="text" size="small" className="theme-toggle" onClick={cycleThemeMode} title={`${t("settings.themeToggle")} – ${label}`} aria-label={t("settings.themeToggle")}>
|
||||||
{icon}
|
{icon}
|
||||||
</button>
|
</Button>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { Button, Segmented } from "antd";
|
||||||
|
import { Select } from "../ui/Select";
|
||||||
import { Icon } from "./Icon";
|
import { Icon } from "./Icon";
|
||||||
import { Fragment, useEffect, useMemo, useState } from "react";
|
import { Fragment, useEffect, useMemo, useState } from "react";
|
||||||
import { useFetch } from "../hooks";
|
import { useFetch } from "../hooks";
|
||||||
@@ -305,10 +307,10 @@ export function Stats({ onMenu }: { onMenu: () => void }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="topbar">
|
<div className="topbar stats-bar">
|
||||||
<button className="ghost menu-btn" onClick={onMenu} aria-label={t("nav.menu")}>
|
<Button type="text" className="menu-btn" onClick={onMenu} aria-label={t("nav.menu")}>
|
||||||
<Icon name="menu" />
|
<Icon name="menu" />
|
||||||
</button>
|
</Button>
|
||||||
<div className="grow">
|
<div className="grow">
|
||||||
<h1>{t("nav.stats")}</h1>
|
<h1>{t("nav.stats")}</h1>
|
||||||
{data && (
|
{data && (
|
||||||
@@ -317,34 +319,32 @@ export function Stats({ onMenu }: { onMenu: () => void }) {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="mode-tabs" role="tablist">
|
<Segmented
|
||||||
{RANGES.map((r) => (
|
value={range}
|
||||||
<button key={r.key} className={range === r.key ? "active" : ""} onClick={() => setRange(r.key)}>
|
onChange={(v) => setRange(v)}
|
||||||
{t(r.label)}
|
options={RANGES.map((r) => ({ value: r.key, label: t(r.label) }))}
|
||||||
</button>
|
/>
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
{years.length > 1 && (
|
{years.length > 1 && (
|
||||||
<select value={year ? range : ""} onChange={(e) => e.target.value && setRange(e.target.value)} aria-label={t("stats.year")} className={year ? "active" : ""}>
|
<Select value={year ? range : ""} onChange={(e) => e.target.value && setRange(e.target.value)} aria-label={t("stats.year")} className={year ? "active" : ""}>
|
||||||
<option value="">{t("stats.year")}</option>
|
<option value="">{t("stats.year")}</option>
|
||||||
{years.map((y) => (
|
{years.map((y) => (
|
||||||
<option key={y} value={`y${y}`}>
|
<option key={y} value={`y${y}`}>
|
||||||
{y}
|
{y}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</Select>
|
||||||
)}
|
)}
|
||||||
{isAdmin && (
|
{isAdmin && (
|
||||||
<select value={userFilter} onChange={(e) => setUserFilter(e.target.value)} aria-label={t("stats.user")}>
|
<Select value={userFilter} onChange={(e) => setUserFilter(e.target.value)} aria-label={t("stats.user")}>
|
||||||
<option value="">{t("stats.allUsers")}</option>
|
<option value="">{t("stats.allUsers")}</option>
|
||||||
{users.map((u) => (
|
{users.map((u) => (
|
||||||
<option key={u.id} value={u.id}>
|
<option key={u.id} value={u.id}>
|
||||||
{u.username}
|
{u.username}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</Select>
|
||||||
)}
|
)}
|
||||||
<select value="" onChange={(e) => exportAs(e.target.value)} aria-label={t("stats.export")} title={t("stats.exportHint")}>
|
<Select value="" onChange={(e) => exportAs(e.target.value)} aria-label={t("stats.export")} title={t("stats.exportHint")}>
|
||||||
<option value="">{t("stats.export")}</option>
|
<option value="">{t("stats.export")}</option>
|
||||||
<option value="xlsx">{t("stats.exportXlsx")}</option>
|
<option value="xlsx">{t("stats.exportXlsx")}</option>
|
||||||
{(["day", "month", "model", "provider", "agent", "user", "session"] as const).map((k) => (
|
{(["day", "month", "model", "provider", "agent", "user", "session"] as const).map((k) => (
|
||||||
@@ -352,10 +352,10 @@ export function Stats({ onMenu }: { onMenu: () => void }) {
|
|||||||
{t("stats.exportCsv", { table: t(`stats.table.${k}` as Key) })}
|
{t("stats.exportCsv", { table: t(`stats.table.${k}` as Key) })}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</Select>
|
||||||
<button className="small" onClick={() => setTableView(!tableView)}>
|
<Button size="small" onClick={() => setTableView(!tableView)}>
|
||||||
{tableView ? t("stats.chartView") : t("stats.tableView")}
|
{tableView ? t("stats.chartView") : t("stats.tableView")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<div className="page">
|
<div className="page">
|
||||||
<div className="page-inner">
|
<div className="page-inner">
|
||||||
@@ -393,11 +393,11 @@ export function Stats({ onMenu }: { onMenu: () => void }) {
|
|||||||
</Fold>
|
</Fold>
|
||||||
<Fold id="heatmap" title={t("stats.heatmap")}>
|
<Fold id="heatmap" title={t("stats.heatmap")}>
|
||||||
<div className="row" style={{ justifyContent: "flex-end", marginBottom: 6 }}>
|
<div className="row" style={{ justifyContent: "flex-end", marginBottom: 6 }}>
|
||||||
<select value={heat} onChange={(e) => setHeat(e.target.value as HeatMetric)} aria-label={t("stats.heatmap")}>
|
<Select value={heat} onChange={(e) => setHeat(e.target.value as HeatMetric)} aria-label={t("stats.heatmap")}>
|
||||||
<option value="requests">{t("stats.requests")}</option>
|
<option value="requests">{t("stats.requests")}</option>
|
||||||
<option value="tokens">{t("stats.tokens")}</option>
|
<option value="tokens">{t("stats.tokens")}</option>
|
||||||
<option value="cost">{t("stats.cost")}</option>
|
<option value="cost">{t("stats.cost")}</option>
|
||||||
</select>
|
</Select>
|
||||||
</div>
|
</div>
|
||||||
<Heatmap cells={view.cells} rows={view.heatRows} format={heatFormat} />
|
<Heatmap cells={view.cells} rows={view.heatRows} format={heatFormat} />
|
||||||
</Fold>
|
</Fold>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { Button } from "antd";
|
||||||
import { useCallback, useEffect, useRef, useState } from "react";
|
import { useCallback, useEffect, useRef, useState } from "react";
|
||||||
import { get, post } from "../api";
|
import { get, post } from "../api";
|
||||||
import { fmtCost, fmtPercent, useT, type Key } from "../i18n";
|
import { fmtCost, fmtPercent, useT, type Key } from "../i18n";
|
||||||
@@ -178,9 +179,9 @@ export function StatusLeds() {
|
|||||||
<Led level={models} /> {t("status.models")}
|
<Led level={models} /> {t("status.models")}
|
||||||
<span className="spacer" />
|
<span className="spacer" />
|
||||||
{admin && (
|
{admin && (
|
||||||
<button className="small ghost" onClick={recheck} disabled={checking} title={t("status.recheck")}>
|
<Button type="text" size="small" onClick={recheck} disabled={checking} title={t("status.recheck")}>
|
||||||
<Icon name="refresh" size={13} />
|
<Icon name="refresh" size={13} />
|
||||||
</button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
{providers.length === 0 && <div className="status-row hint">{t("status.noProviders")}</div>}
|
{providers.length === 0 && <div className="status-row hint">{t("status.noProviders")}</div>}
|
||||||
@@ -228,12 +229,12 @@ export function StatusLeds() {
|
|||||||
|
|
||||||
{admin && (
|
{admin && (
|
||||||
<div className="status-foot">
|
<div className="status-foot">
|
||||||
<button className="small ghost" onClick={() => go("providers")}>
|
<Button type="text" size="small" onClick={() => go("providers")}>
|
||||||
<Icon name="brain" size={13} /> {t("status.providerSettings")}
|
<Icon name="brain" size={13} /> {t("status.providerSettings")}
|
||||||
</button>
|
</Button>
|
||||||
<button className="small ghost" onClick={() => go("mcp")}>
|
<Button type="text" size="small" onClick={() => go("mcp")}>
|
||||||
<Icon name="plug" size={13} /> {t("status.mcpSettings")}
|
<Icon name="plug" size={13} /> {t("status.mcpSettings")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { Button, Input } from "antd";
|
||||||
|
import { Modal } from "../ui/Modal";
|
||||||
import { useEffect, useMemo, useRef, useState } from "react";
|
import { useEffect, useMemo, useRef, useState } from "react";
|
||||||
import { toast } from "../dialogs";
|
import { toast } from "../dialogs";
|
||||||
import { useT } from "../i18n";
|
import { useT } from "../i18n";
|
||||||
@@ -43,14 +45,13 @@ export function TemplatePicker({ onPick, onClose }: { onPick: (text: string) =>
|
|||||||
const ph = chosen ? placeholders(chosen.text) : [];
|
const ph = chosen ? placeholders(chosen.text) : [];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="modal-backdrop" onClick={onClose}>
|
<Modal onClose={onClose} className="tpl-picker" role="dialog" aria-label={t("templates.title")}>
|
||||||
<div className="modal tpl-picker" role="dialog" aria-label={t("templates.title")} onClick={(e) => e.stopPropagation()}>
|
|
||||||
{!chosen ? (
|
{!chosen ? (
|
||||||
<>
|
<>
|
||||||
<h3>
|
<h3>
|
||||||
<Icon name="template" /> {t("templates.title")}
|
<Icon name="template" /> {t("templates.title")}
|
||||||
</h3>
|
</h3>
|
||||||
<input
|
<Input
|
||||||
autoFocus
|
autoFocus
|
||||||
style={{ width: "100%" }}
|
style={{ width: "100%" }}
|
||||||
value={q}
|
value={q}
|
||||||
@@ -79,11 +80,11 @@ export function TemplatePicker({ onPick, onClose }: { onPick: (text: string) =>
|
|||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
<div className="row" style={{ marginTop: 12 }}>
|
<div className="row" style={{ marginTop: 12 }}>
|
||||||
<button className="ghost small" onClick={() => (onClose(), navigate("/settings/templates"))}>
|
<Button type="text" size="small" onClick={() => (onClose(), navigate("/settings/templates"))}>
|
||||||
<Icon name="edit" /> {t("templates.manage")}
|
<Icon name="edit" /> {t("templates.manage")}
|
||||||
</button>
|
</Button>
|
||||||
<span className="grow" />
|
<span className="grow" />
|
||||||
<button onClick={onClose}>{t("common.cancel")}</button>
|
<Button onClick={onClose}>{t("common.cancel")}</Button>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
@@ -108,16 +109,15 @@ export function TemplatePicker({ onPick, onClose }: { onPick: (text: string) =>
|
|||||||
</label>
|
</label>
|
||||||
))}
|
))}
|
||||||
<div className="row" style={{ marginTop: 12, justifyContent: "flex-end" }}>
|
<div className="row" style={{ marginTop: 12, justifyContent: "flex-end" }}>
|
||||||
<button type="button" onClick={() => setChosen(undefined)}>
|
<Button onClick={() => setChosen(undefined)}>
|
||||||
{t("common.back")}
|
{t("common.back")}
|
||||||
</button>
|
</Button>
|
||||||
<button type="submit" className="primary">
|
<Button type="primary" htmlType="submit">
|
||||||
{t("templates.insert")}
|
{t("templates.insert")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
)}
|
)}
|
||||||
</div>
|
</Modal>
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { Button } from "antd";
|
||||||
import { useEffect, useRef, useState } from "react";
|
import { useEffect, useRef, useState } from "react";
|
||||||
import { Terminal as XTerm, type ITheme } from "@xterm/xterm";
|
import { Terminal as XTerm, type ITheme } from "@xterm/xterm";
|
||||||
import { FitAddon } from "@xterm/addon-fit";
|
import { FitAddon } from "@xterm/addon-fit";
|
||||||
@@ -98,23 +99,23 @@ export function TerminalPage({ id, onMenu }: { id?: string; onMenu: () => void }
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="topbar">
|
<div className="topbar">
|
||||||
<button className="ghost menu-btn" onClick={onMenu} aria-label={t("nav.menu")}>
|
<Button type="text" className="menu-btn" onClick={onMenu} aria-label={t("nav.menu")}>
|
||||||
<Icon name="menu" />
|
<Icon name="menu" />
|
||||||
</button>
|
</Button>
|
||||||
<div className="grow term-tabs">
|
<div className="grow term-tabs">
|
||||||
{list.map((x) => (
|
{list.map((x) => (
|
||||||
<span key={x.id} className={`term-tab ${x.id === id ? "active" : ""} ${x.alive ? "" : "dead"}`}>
|
<span key={x.id} className={`term-tab ${x.id === id ? "active" : ""} ${x.alive ? "" : "dead"}`}>
|
||||||
<button className="ghost small" onClick={() => navigate(`/terminal/${x.id}`)} title={x.cwd}>
|
<Button type="text" size="small" onClick={() => navigate(`/terminal/${x.id}`)} title={x.cwd}>
|
||||||
<Icon name="terminal" /> {basename(x.cwd)}
|
<Icon name="terminal" /> {basename(x.cwd)}
|
||||||
</button>
|
</Button>
|
||||||
<button className="ghost small" onClick={() => close(x.id)} aria-label={t("terminal.close")} title={t("terminal.close")}>
|
<Button type="text" size="small" onClick={() => close(x.id)} aria-label={t("terminal.close")} title={t("terminal.close")}>
|
||||||
<Icon name="close" />
|
<Icon name="close" />
|
||||||
</button>
|
</Button>
|
||||||
</span>
|
</span>
|
||||||
))}
|
))}
|
||||||
<button className="ghost small" onClick={open} title={t("terminal.new")} aria-label={t("terminal.new")}>
|
<Button type="text" size="small" onClick={open} title={t("terminal.new")} aria-label={t("terminal.new")}>
|
||||||
<Icon name="plus" />
|
<Icon name="plus" />
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{error && <div className="notice err">{error}</div>}
|
{error && <div className="notice err">{error}</div>}
|
||||||
@@ -123,9 +124,9 @@ export function TerminalPage({ id, onMenu }: { id?: string; onMenu: () => void }
|
|||||||
) : (
|
) : (
|
||||||
<div className="empty">
|
<div className="empty">
|
||||||
{list.length === 0 && id !== "new" && (
|
{list.length === 0 && id !== "new" && (
|
||||||
<button className="primary" onClick={open}>
|
<Button type="primary" onClick={open}>
|
||||||
<Icon name="terminal" /> {t("terminal.new")}
|
<Icon name="terminal" /> {t("terminal.new")}
|
||||||
</button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
@@ -237,8 +238,8 @@ export function TermView({ info }: { info: TermInfo }) {
|
|||||||
<div className="term-host" ref={host} />
|
<div className="term-host" ref={host} />
|
||||||
{state !== "open" && <div className="term-state">{t(state === "connecting" ? "terminal.connecting" : "terminal.reconnecting")}</div>}
|
{state !== "open" && <div className="term-state">{t(state === "connecting" ? "terminal.connecting" : "terminal.reconnecting")}</div>}
|
||||||
<div className="term-keys" aria-label={t("terminal.keys")}>
|
<div className="term-keys" aria-label={t("terminal.keys")}>
|
||||||
<button onClick={() => key("\x1b")}>Esc</button>
|
<Button onClick={() => key("\x1b")}>Esc</Button>
|
||||||
<button onClick={() => key("\t")}>Tab</button>
|
<Button onClick={() => key("\t")}>Tab</Button>
|
||||||
<button
|
<button
|
||||||
className={ctrl ? "active" : ""}
|
className={ctrl ? "active" : ""}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
@@ -249,19 +250,19 @@ export function TermView({ info }: { info: TermInfo }) {
|
|||||||
>
|
>
|
||||||
Ctrl
|
Ctrl
|
||||||
</button>
|
</button>
|
||||||
<button onClick={() => key("\x03")}>^C</button>
|
<Button onClick={() => key("\x03")}>^C</Button>
|
||||||
<button onClick={() => key("\x1b[A")} aria-label="Up">
|
<Button onClick={() => key("\x1b[A")} aria-label="Up">
|
||||||
<Icon name="arrow-up" />
|
<Icon name="arrow-up" />
|
||||||
</button>
|
</Button>
|
||||||
<button onClick={() => key("\x1b[B")} aria-label="Down">
|
<Button onClick={() => key("\x1b[B")} aria-label="Down">
|
||||||
<Icon name="arrow-down" />
|
<Icon name="arrow-down" />
|
||||||
</button>
|
</Button>
|
||||||
<button onClick={() => key("\x1b[D")} aria-label="Left">
|
<Button onClick={() => key("\x1b[D")} aria-label="Left">
|
||||||
<Icon name="arrow-left" />
|
<Icon name="arrow-left" />
|
||||||
</button>
|
</Button>
|
||||||
<button onClick={() => key("\x1b[C")} aria-label="Right">
|
<Button onClick={() => key("\x1b[C")} aria-label="Right">
|
||||||
<Icon name="arrow-right" />
|
<Icon name="arrow-right" />
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { Button } from "antd";
|
||||||
import { Icon } from "./Icon";
|
import { Icon } from "./Icon";
|
||||||
import { FileFigure, imageSize, imageSrc } from "./FileFigure";
|
import { FileFigure, imageSize, imageSrc } from "./FileFigure";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
@@ -142,9 +143,9 @@ export function ToolCard({ call, result, running, baseDir }: { call: ToolCall; r
|
|||||||
{call.name === "bash" && <pre className="mono">$ {call.input?.command}</pre>}
|
{call.name === "bash" && <pre className="mono">$ {call.input?.command}</pre>}
|
||||||
{(call.name === "edit" || call.name === "write") && meta?.diff && <Diff diff={meta.diff} />}
|
{(call.name === "edit" || call.name === "write") && meta?.diff && <Diff diff={meta.diff} />}
|
||||||
{call.name === "task" && meta?.session_id && (
|
{call.name === "task" && meta?.session_id && (
|
||||||
<button className="small" onClick={() => navigate(`/s/${meta.session_id}`)}>
|
<Button size="small" onClick={() => navigate(`/s/${meta.session_id}`)}>
|
||||||
{t("tool.openSubagent")}
|
{t("tool.openSubagent")}
|
||||||
</button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
{!["bash", "edit", "write", "task"].includes(call.name) && (
|
{!["bash", "edit", "write", "task"].includes(call.name) && (
|
||||||
<>
|
<>
|
||||||
@@ -165,8 +166,7 @@ export function ToolCard({ call, result, running, baseDir }: { call: ToolCall; r
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{typeof meta?.model_file === "string" && (
|
{typeof meta?.model_file === "string" && (
|
||||||
<button
|
<Button size="small"
|
||||||
className="small"
|
|
||||||
style={{ marginBottom: 8 }}
|
style={{ marginBottom: 8 }}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
sessionStorage.setItem("codecraft.openFile", meta.model_file);
|
sessionStorage.setItem("codecraft.openFile", meta.model_file);
|
||||||
@@ -174,7 +174,7 @@ export function ToolCard({ call, result, running, baseDir }: { call: ToolCall; r
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Icon name="cube" /> {t("tool.open3d")}
|
<Icon name="cube" /> {t("tool.open3d")}
|
||||||
</button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
{Array.isArray(meta?.image_ids) ? (
|
{Array.isArray(meta?.image_ids) ? (
|
||||||
<div className="gallery small">
|
<div className="gallery small">
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { Button } from "antd";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { get } from "../api";
|
import { get } from "../api";
|
||||||
import { useT } from "../i18n";
|
import { useT } from "../i18n";
|
||||||
@@ -51,9 +52,9 @@ export function TurnChanges({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="turn-changes">
|
<div className="turn-changes">
|
||||||
<button className="small ghost" onClick={toggle} aria-expanded={open}>
|
<Button type="text" size="small" onClick={toggle} aria-expanded={open}>
|
||||||
<Icon name={open ? "chevron-down" : "chevron-right"} className="tiny" /> {t("turn.changes", { n: fileCount })}
|
<Icon name={open ? "chevron-down" : "chevron-right"} className="tiny" /> {t("turn.changes", { n: fileCount })}
|
||||||
</button>
|
</Button>
|
||||||
{open && (
|
{open && (
|
||||||
<div className="turn-changes-body">
|
<div className="turn-changes-body">
|
||||||
{error && <div className="notice err">{error}</div>}
|
{error && <div className="notice err">{error}</div>}
|
||||||
@@ -74,9 +75,9 @@ export function TurnChanges({
|
|||||||
</details>
|
</details>
|
||||||
))}
|
))}
|
||||||
{userMessage && onRewind && changes && changes.length > 0 && (
|
{userMessage && onRewind && changes && changes.length > 0 && (
|
||||||
<button className="small" onClick={() => onRewind(userMessage)}>
|
<Button size="small" onClick={() => onRewind(userMessage)}>
|
||||||
<Icon name="undo" /> {t("turn.rollback")}
|
<Icon name="undo" /> {t("turn.rollback")}
|
||||||
</button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { Button } from "antd";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { post } from "../api";
|
import { post } from "../api";
|
||||||
import { toast } from "../dialogs";
|
import { toast } from "../dialogs";
|
||||||
@@ -32,9 +33,9 @@ export function TurnCheck({ sessionId, messageId, canSend }: { sessionId: string
|
|||||||
<div className="turn-check-body">
|
<div className="turn-check-body">
|
||||||
<pre className="mono">{check.output || t("check.noOutput")}</pre>
|
<pre className="mono">{check.output || t("check.noOutput")}</pre>
|
||||||
{check.status !== "passed" && canSend && (
|
{check.status !== "passed" && canSend && (
|
||||||
<button className="small primary" onClick={fix}>
|
<Button type="primary" size="small" onClick={fix}>
|
||||||
<Icon name="sparkle" /> {t("check.fix")}
|
<Icon name="sparkle" /> {t("check.fix")}
|
||||||
</button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { Button } from "antd";
|
||||||
import { useT } from "../i18n";
|
import { useT } from "../i18n";
|
||||||
import { closeUploadBatch, useUploads } from "../uploads";
|
import { closeUploadBatch, useUploads } from "../uploads";
|
||||||
import { Icon } from "./Icon";
|
import { Icon } from "./Icon";
|
||||||
@@ -23,9 +24,9 @@ export function UploadPanel() {
|
|||||||
<span className="hint">
|
<span className="hint">
|
||||||
{formatSize(sent)} / {formatSize(total)}
|
{formatSize(sent)} / {formatSize(total)}
|
||||||
</span>
|
</span>
|
||||||
<button className="small ghost" onClick={() => closeUploadBatch(b.id)} aria-label={t("common.close")}>
|
<Button type="text" size="small" onClick={() => closeUploadBatch(b.id)} aria-label={t("common.close")}>
|
||||||
<Icon name="close" />
|
<Icon name="close" />
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<div className="upload-bar total" title={`${pct(sent, total)} %`}>
|
<div className="upload-bar total" title={`${pct(sent, total)} %`}>
|
||||||
<i style={{ width: `${pct(sent, total)}%` }} />
|
<i style={{ width: `${pct(sent, total)}%` }} />
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { Button } from "antd";
|
||||||
|
import { Modal } from "../ui/Modal";
|
||||||
import { Icon } from "./Icon";
|
import { Icon } from "./Icon";
|
||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
import { useFetch, useModels } from "../hooks";
|
import { useFetch, useModels } from "../hooks";
|
||||||
@@ -59,14 +61,13 @@ export function UsageOverlay({ session, onClose }: { session: Session; onClose:
|
|||||||
const ctxTokens = u ? u.input_tokens + u.cache_read_tokens + u.cache_write_tokens + u.output_tokens : 0;
|
const ctxTokens = u ? u.input_tokens + u.cache_read_tokens + u.cache_write_tokens + u.output_tokens : 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="modal-backdrop" onClick={onClose}>
|
<Modal onClose={onClose} className="wide" role="dialog" aria-label={t("usage.title")}>
|
||||||
<div className="modal wide" role="dialog" aria-label={t("usage.title")} onClick={(e) => e.stopPropagation()}>
|
|
||||||
<div className="row" style={{ marginBottom: 8 }}>
|
<div className="row" style={{ marginBottom: 8 }}>
|
||||||
<h3 style={{ margin: 0 }}>{t("usage.title")}</h3>
|
<h3 style={{ margin: 0 }}>{t("usage.title")}</h3>
|
||||||
<span className="spacer" />
|
<span className="spacer" />
|
||||||
<button className="small ghost" onClick={onClose} aria-label={t("common.close")}>
|
<Button type="text" size="small" onClick={onClose} aria-label={t("common.close")}>
|
||||||
<Icon name="close" />
|
<Icon name="close" />
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
{!data ? (
|
{!data ? (
|
||||||
<div className="empty">{t("common.loading")}</div>
|
<div className="empty">{t("common.loading")}</div>
|
||||||
@@ -194,7 +195,6 @@ export function UsageOverlay({ session, onClose }: { session: Session; onClose:
|
|||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</Modal>
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { Button } from "antd";
|
||||||
import { useEffect, useRef, useState } from "react";
|
import { useEffect, useRef, useState } from "react";
|
||||||
import { getLang, useT } from "../i18n";
|
import { getLang, useT } from "../i18n";
|
||||||
import { toast } from "../dialogs";
|
import { toast } from "../dialogs";
|
||||||
@@ -75,9 +76,9 @@ function RecorderButton({ onText, onInterim }: { onText: (text: string) => void;
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<button
|
<Button
|
||||||
type="button"
|
|
||||||
className={`ghost small voice-btn ${state === "recording" ? "on" : ""}`}
|
type="text" size="small" className={`voice-btn ${state === "recording" ? "on" : ""}`}
|
||||||
disabled={state === "sending"}
|
disabled={state === "sending"}
|
||||||
onClick={() => void toggle()}
|
onClick={() => void toggle()}
|
||||||
title={t(state === "recording" ? "voice.stop" : "voice.start")}
|
title={t(state === "recording" ? "voice.stop" : "voice.start")}
|
||||||
@@ -85,7 +86,7 @@ function RecorderButton({ onText, onInterim }: { onText: (text: string) => void;
|
|||||||
aria-pressed={state === "recording"}
|
aria-pressed={state === "recording"}
|
||||||
>
|
>
|
||||||
<Icon name="mic" />
|
<Icon name="mic" />
|
||||||
</button>
|
</Button>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,8 +139,8 @@ function BrowserVoiceButton({ onText, onInterim }: { onText: (text: string) => v
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<button type="button" className={`ghost small voice-btn ${listening ? "on" : ""}`} onClick={toggle} title={t(listening ? "voice.stop" : "voice.start")} aria-label={t(listening ? "voice.stop" : "voice.start")} aria-pressed={listening}>
|
<Button type="text" size="small" className={`voice-btn ${listening ? "on" : ""}`} onClick={toggle} title={t(listening ? "voice.stop" : "voice.start")} aria-label={t(listening ? "voice.stop" : "voice.start")} aria-pressed={listening}>
|
||||||
<Icon name="mic" />
|
<Icon name="mic" />
|
||||||
</button>
|
</Button>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { Button } from "antd";
|
||||||
|
import { Modal } from "../ui/Modal";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { getLang, useT } from "../i18n";
|
import { getLang, useT } from "../i18n";
|
||||||
import { WHATS_NEW } from "../whatsnew";
|
import { WHATS_NEW } from "../whatsnew";
|
||||||
@@ -25,8 +27,7 @@ export function WhatsNew({ version }: { version: string }) {
|
|||||||
setOpen(false);
|
setOpen(false);
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<div className="modal-backdrop" onClick={close}>
|
<Modal onClose={close} role="dialog" aria-label={t("whatsnew.title")}>
|
||||||
<div className="modal" role="dialog" aria-label={t("whatsnew.title")} onClick={(e) => e.stopPropagation()}>
|
|
||||||
<h3>
|
<h3>
|
||||||
<Icon name="sparkle" /> {t("whatsnew.title", { version })}
|
<Icon name="sparkle" /> {t("whatsnew.title", { version })}
|
||||||
</h3>
|
</h3>
|
||||||
@@ -36,11 +37,10 @@ export function WhatsNew({ version }: { version: string }) {
|
|||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
<div className="row" style={{ justifyContent: "flex-end" }}>
|
<div className="row" style={{ justifyContent: "flex-end" }}>
|
||||||
<button className="primary" onClick={close}>
|
<Button type="primary" onClick={close}>
|
||||||
{t("common.ok")}
|
{t("common.ok")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
</Modal>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { Button } from "antd";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { get, post } from "../api";
|
import { get, post } from "../api";
|
||||||
import { useT } from "../i18n";
|
import { useT } from "../i18n";
|
||||||
@@ -69,12 +70,12 @@ export function WorktreeChip({ session, busy }: { session: Session; busy: boolea
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<div className="row" style={{ gap: 6, marginTop: 8 }}>
|
<div className="row" style={{ gap: 6, marginTop: 8 }}>
|
||||||
<button className="small primary" disabled={busy || !!working} onClick={() => act("merge")}>
|
<Button type="primary" size="small" disabled={busy || !!working} onClick={() => act("merge")}>
|
||||||
{working === "merge" ? <Spinner small /> : <Icon name="check" />} {t("worktree.merge", { base: wt.base })}
|
{working === "merge" ? <Spinner small /> : <Icon name="check" />} {t("worktree.merge", { base: wt.base })}
|
||||||
</button>
|
</Button>
|
||||||
<button className="small danger" disabled={busy || !!working} onClick={() => act("remove")}>
|
<Button danger size="small" disabled={busy || !!working} onClick={() => act("remove")}>
|
||||||
<Icon name="trash" /> {t("worktree.remove")}
|
<Icon name="trash" /> {t("worktree.remove")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
{busy && <div className="hint">{t("worktree.busy")}</div>}
|
{busy && <div className="hint">{t("worktree.busy")}</div>}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { Button, Input } from "antd";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { post } from "../../api";
|
import { post } from "../../api";
|
||||||
import { useT } from "../../i18n";
|
import { useT } from "../../i18n";
|
||||||
@@ -38,18 +39,18 @@ export function Account() {
|
|||||||
{me?.has_password && (
|
{me?.has_password && (
|
||||||
<>
|
<>
|
||||||
<label>{t("account.current")}</label>
|
<label>{t("account.current")}</label>
|
||||||
<input type="password" value={form.current} onChange={(e) => setForm({ ...form, current: e.target.value })} autoComplete="current-password" />
|
<Input.Password value={form.current} onChange={(e) => setForm({ ...form, current: e.target.value })} autoComplete="current-password" />
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<label>{t("account.new")}</label>
|
<label>{t("account.new")}</label>
|
||||||
<input type="password" value={form.next} onChange={(e) => setForm({ ...form, next: e.target.value })} autoComplete="new-password" />
|
<Input.Password value={form.next} onChange={(e) => setForm({ ...form, next: e.target.value })} autoComplete="new-password" />
|
||||||
<label>{t("login.passwordRepeat")}</label>
|
<label>{t("login.passwordRepeat")}</label>
|
||||||
<input type="password" value={form.repeat} onChange={(e) => setForm({ ...form, repeat: e.target.value })} autoComplete="new-password" />
|
<Input.Password value={form.repeat} onChange={(e) => setForm({ ...form, repeat: e.target.value })} autoComplete="new-password" />
|
||||||
</div>
|
</div>
|
||||||
{notice && <div className={`notice ${notice.ok ? "ok" : "err"}`} style={{ marginTop: 10 }}>{notice.text}</div>}
|
{notice && <div className={`notice ${notice.ok ? "ok" : "err"}`} style={{ marginTop: 10 }}>{notice.text}</div>}
|
||||||
<button className="primary" style={{ marginTop: 12 }} disabled={!form.next} onClick={save}>
|
<Button type="primary" style={{ marginTop: 12 }} disabled={!form.next} onClick={save}>
|
||||||
{t("account.change")}
|
{t("account.change")}
|
||||||
</button>
|
</Button>
|
||||||
<div style={{ fontSize: 12, color: "var(--muted)", marginTop: 8 }}>{t("account.hint")}</div>
|
<div style={{ fontSize: 12, color: "var(--muted)", marginTop: 8 }}>{t("account.hint")}</div>
|
||||||
</div>
|
</div>
|
||||||
<Memory />
|
<Memory />
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { Button, Checkbox, Input } from "antd";
|
||||||
|
import { Select } from "../../ui/Select";
|
||||||
import { Icon } from "../Icon";
|
import { Icon } from "../Icon";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { del, patch } from "../../api";
|
import { del, patch } from "../../api";
|
||||||
@@ -26,16 +28,14 @@ export function ToolPicker({ tools, value, onChange, readOnly }: { tools: ToolIn
|
|||||||
<div className="hint">{value.length ? t("agents.toolsSome", { n: value.length }) : t("agents.toolsAll")}</div>
|
<div className="hint">{value.length ? t("agents.toolsSome", { n: value.length }) : t("agents.toolsAll")}</div>
|
||||||
<div className="tool-grid">
|
<div className="tool-grid">
|
||||||
{tools.map((x) => (
|
{tools.map((x) => (
|
||||||
<label key={x.name} className={`tool-item ${readOnly && !x.read_only ? "disabled" : ""}`} title={x.description}>
|
<Checkbox key={x.name} className={`tool-item ${readOnly && !x.read_only ? "disabled" : ""}`} title={x.description} checked={value.includes(x.name)} disabled={readOnly && !x.read_only} onChange={() => toggle(x.name)}>
|
||||||
<input type="checkbox" checked={value.includes(x.name)} disabled={readOnly && !x.read_only} onChange={() => toggle(x.name)} />
|
|
||||||
<span className="mono">{x.name}</span>
|
<span className="mono">{x.name}</span>
|
||||||
</label>
|
</Checkbox>
|
||||||
))}
|
))}
|
||||||
{extra.map((n) => (
|
{extra.map((n) => (
|
||||||
<label key={n} className="tool-item">
|
<Checkbox key={n} className="tool-item" checked onChange={() => toggle(n)}>
|
||||||
<input type="checkbox" checked onChange={() => toggle(n)} />
|
|
||||||
<span className="mono">{n}</span>
|
<span className="mono">{n}</span>
|
||||||
</label>
|
</Checkbox>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -125,13 +125,13 @@ function AgentRow({ a, raw, tools, onSaved }: { a: AgentInfo; raw: any; tools: T
|
|||||||
{a.read_only && <span className="chip">{t("agents.readOnly")}</span>}
|
{a.read_only && <span className="chip">{t("agents.readOnly")}</span>}
|
||||||
<span className="spacer" />
|
<span className="spacer" />
|
||||||
{!builtin && (a.source === "config" || a.source === "file") && (
|
{!builtin && (a.source === "config" || a.source === "file") && (
|
||||||
<button className="small ghost danger" onClick={a.source === "file" ? removeFile : reset} title={t("common.delete")} aria-label={t("common.delete")}>
|
<Button type="text" danger size="small" onClick={a.source === "file" ? removeFile : reset} title={t("common.delete")} aria-label={t("common.delete")}>
|
||||||
<Icon name="trash" />
|
<Icon name="trash" />
|
||||||
</button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
<button className="small" onClick={() => setOpen(!open)}>
|
<Button size="small" onClick={() => setOpen(!open)}>
|
||||||
{open ? t("common.collapse") : t("common.edit")}
|
{open ? t("common.collapse") : t("common.edit")}
|
||||||
</button>
|
</Button>
|
||||||
</h3>
|
</h3>
|
||||||
<div style={{ fontSize: 13, color: "var(--fg3)" }}>{a.description}</div>
|
<div style={{ fontSize: 13, color: "var(--fg3)" }}>{a.description}</div>
|
||||||
<div className="row" style={{ marginTop: 8 }}>
|
<div className="row" style={{ marginTop: 8 }}>
|
||||||
@@ -149,75 +149,72 @@ function AgentRow({ a, raw, tools, onSaved }: { a: AgentInfo; raw: any; tools: T
|
|||||||
{a.mode !== "primary" && (
|
{a.mode !== "primary" && (
|
||||||
<>
|
<>
|
||||||
<label>{t("agents.maxParallel")}</label>
|
<label>{t("agents.maxParallel")}</label>
|
||||||
<input type="number" min={1} value={form.max_parallel} placeholder="∞" onChange={(e) => setForm({ ...form, max_parallel: e.target.value })} />
|
<Input type="number" min={1} value={form.max_parallel} placeholder="∞" onChange={(e) => setForm({ ...form, max_parallel: e.target.value })} />
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{a.mode === "primary" && (
|
{a.mode === "primary" && (
|
||||||
<>
|
<>
|
||||||
<label>{t("agents.refineRounds")}</label>
|
<label>{t("agents.refineRounds")}</label>
|
||||||
<input type="number" min={0} max={10} value={form.refine_rounds} placeholder={t("agents.refineOff")} onChange={(e) => setForm({ ...form, refine_rounds: e.target.value })} />
|
<Input type="number" min={0} max={10} value={form.refine_rounds} placeholder={t("agents.refineOff")} onChange={(e) => setForm({ ...form, refine_rounds: e.target.value })} />
|
||||||
<label>{t("agents.refineModel")}</label>
|
<label>{t("agents.refineModel")}</label>
|
||||||
<ModelSelect value={form.refine_model} onChange={(v) => setForm({ ...form, refine_model: v })} emptyLabel={t("agents.sessionModel")} />
|
<ModelSelect value={form.refine_model} onChange={(v) => setForm({ ...form, refine_model: v })} emptyLabel={t("agents.sessionModel")} />
|
||||||
<label>{t("agents.refineCriteria")}</label>
|
<label>{t("agents.refineCriteria")}</label>
|
||||||
<textarea rows={3} value={form.refine_criteria} onChange={(e) => setForm({ ...form, refine_criteria: e.target.value })} />
|
<Input.TextArea rows={3} value={form.refine_criteria} onChange={(e) => setForm({ ...form, refine_criteria: e.target.value })} />
|
||||||
<div className="hint">{t("agents.refineCriteriaHint")}</div>
|
<div className="hint">{t("agents.refineCriteriaHint")}</div>
|
||||||
<label className="check">
|
<Checkbox checked={form.refine_after_todos} onChange={(e) => setForm({ ...form, refine_after_todos: e.target.checked })}>
|
||||||
<input type="checkbox" checked={form.refine_after_todos} onChange={(e) => setForm({ ...form, refine_after_todos: e.target.checked })} />
|
|
||||||
{t("agents.refineAfterTodos")}
|
{t("agents.refineAfterTodos")}
|
||||||
</label>
|
</Checkbox>
|
||||||
<div className="hint">{t("agents.refineAfterTodosHint")}</div>
|
<div className="hint">{t("agents.refineAfterTodosHint")}</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{a.name !== "craft" && (
|
{a.name !== "craft" && (
|
||||||
<>
|
<>
|
||||||
<label className="check">
|
<Checkbox checked={form.reverse_tools} onChange={(e) => setForm({ ...form, reverse_tools: e.target.checked })}>
|
||||||
<input type="checkbox" checked={form.reverse_tools} onChange={(e) => setForm({ ...form, reverse_tools: e.target.checked })} />
|
|
||||||
{t("agents.reverseTools")}
|
{t("agents.reverseTools")}
|
||||||
</label>
|
</Checkbox>
|
||||||
<div className="hint">{t("agents.reverseToolsHint")}</div>
|
<div className="hint">{t("agents.reverseToolsHint")}</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<label>{t("agents.description")}</label>
|
<label>{t("agents.description")}</label>
|
||||||
<input value={form.description} placeholder={a.description} onChange={(e) => setForm({ ...form, description: e.target.value })} />
|
<Input value={form.description} placeholder={a.description} onChange={(e) => setForm({ ...form, description: e.target.value })} />
|
||||||
{a.mode !== "primary" && <div className="hint">{t("agents.descriptionHint")}</div>}
|
{a.mode !== "primary" && <div className="hint">{t("agents.descriptionHint")}</div>}
|
||||||
{!builtin && (
|
{!builtin && (
|
||||||
<>
|
<>
|
||||||
<label>{t("agents.mode")}</label>
|
<label>{t("agents.mode")}</label>
|
||||||
<select value={form.mode} onChange={(e) => setForm({ ...form, mode: e.target.value })}>
|
<Select value={form.mode} onChange={(e) => setForm({ ...form, mode: e.target.value })}>
|
||||||
<option value="subagent">{t("agents.modeSubagent")}</option>
|
<option value="subagent">{t("agents.modeSubagent")}</option>
|
||||||
<option value="primary">{t("agents.modePrimary")}</option>
|
<option value="primary">{t("agents.modePrimary")}</option>
|
||||||
</select>
|
</Select>
|
||||||
{form.mode === "primary" && (
|
{form.mode === "primary" && (
|
||||||
<>
|
<>
|
||||||
<label>{t("agents.style")}</label>
|
<label>{t("agents.style")}</label>
|
||||||
<select value={form.style} onChange={(e) => setForm({ ...form, style: e.target.value as "coding" | "chat" })}>
|
<Select value={form.style} onChange={(e) => setForm({ ...form, style: e.target.value as "coding" | "chat" })}>
|
||||||
<option value="coding">{t("agents.styleCoding")}</option>
|
<option value="coding">{t("agents.styleCoding")}</option>
|
||||||
<option value="chat">{t("agents.styleChat")}</option>
|
<option value="chat">{t("agents.styleChat")}</option>
|
||||||
</select>
|
</Select>
|
||||||
<div className="hint">{t("agents.styleHint")}</div>
|
<div className="hint">{t("agents.styleHint")}</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<label>{t("agents.readOnlyLabel")}</label>
|
<label>{t("agents.readOnlyLabel")}</label>
|
||||||
<label className="row" style={{ gap: 6, alignItems: "center" }}>
|
<Checkbox className="row" style={{ gap: 6, alignItems: "center" }} checked={form.read_only} onChange={(e) => setForm({ ...form, read_only: e.target.checked })}>
|
||||||
<input type="checkbox" checked={form.read_only} onChange={(e) => setForm({ ...form, read_only: e.target.checked })} />
|
|
||||||
<span className="hint">{t("agents.readOnlyHint")}</span>
|
<span className="hint">{t("agents.readOnlyHint")}</span>
|
||||||
</label>
|
</Checkbox>
|
||||||
<label>{t("agents.tools")}</label>
|
<label>{t("agents.tools")}</label>
|
||||||
<ToolPicker tools={tools} value={form.tools} onChange={(v) => setForm({ ...form, tools: v })} readOnly={form.read_only} />
|
<ToolPicker tools={tools} value={form.tools} onChange={(v) => setForm({ ...form, tools: v })} readOnly={form.read_only} />
|
||||||
<label>{t("agents.prompt")}</label>
|
<label>{t("agents.prompt")}</label>
|
||||||
<textarea rows={6} value={form.prompt} onChange={(e) => setForm({ ...form, prompt: e.target.value })} />
|
<Input.TextArea rows={6} value={form.prompt} onChange={(e) => setForm({ ...form, prompt: e.target.value })} />
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="row" style={{ marginTop: 12 }}>
|
<div className="row" style={{ marginTop: 12 }}>
|
||||||
<button className="primary" onClick={save}>
|
<Button type="primary" onClick={save}>
|
||||||
{t("common.save")}
|
{t("common.save")}
|
||||||
</button>
|
</Button>
|
||||||
<span className="spacer" />
|
<span className="spacer" />
|
||||||
{a.source === "config" && builtin && (
|
{a.source === "config" && builtin && (
|
||||||
<button className="danger" onClick={reset}>
|
<Button danger onClick={reset}>
|
||||||
{t("agents.reset")}
|
{t("agents.reset")}
|
||||||
</button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
@@ -274,14 +271,14 @@ export function AgentsEditor({ rawAgents, reloadConfig }: { rawAgents: Record<st
|
|||||||
<div className="panel">
|
<div className="panel">
|
||||||
<h3>{t("agents.add")}</h3>
|
<h3>{t("agents.add")}</h3>
|
||||||
<div className="row">
|
<div className="row">
|
||||||
<input placeholder={t("settings.name")} value={name} onChange={(e) => setName(e.target.value)} />
|
<Input placeholder={t("settings.name")} value={name} onChange={(e) => setName(e.target.value)} />
|
||||||
<button className="primary" onClick={() => add("mode")} disabled={!name.trim()}>
|
<Button type="primary" onClick={() => add("mode")} disabled={!name.trim()}>
|
||||||
+ {t("agents.addMode")}
|
+ {t("agents.addMode")}
|
||||||
</button>
|
</Button>
|
||||||
<button onClick={() => add("writer")}>+ {t("agents.addWriter")}</button>
|
<Button onClick={() => add("writer")}>+ {t("agents.addWriter")}</Button>
|
||||||
<button onClick={() => add("blank")} disabled={!name.trim()}>
|
<Button onClick={() => add("blank")} disabled={!name.trim()}>
|
||||||
+ {t("agents.addBlank")}
|
+ {t("agents.addBlank")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="two-col">
|
<div className="two-col">
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { Button, Input } from "antd";
|
||||||
|
import { Select } from "../../ui/Select";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { del, get, post } from "../../api";
|
import { del, get, post } from "../../api";
|
||||||
import { fmtRelative, useT } from "../../i18n";
|
import { fmtRelative, useT } from "../../i18n";
|
||||||
@@ -52,12 +54,11 @@ export function ApiTokens() {
|
|||||||
<div>{t("tokens.copyNow")}</div>
|
<div>{t("tokens.copyNow")}</div>
|
||||||
<div className="row" style={{ gap: 6, marginTop: 6 }}>
|
<div className="row" style={{ gap: 6, marginTop: 6 }}>
|
||||||
<code className="token-value">{created}</code>
|
<code className="token-value">{created}</code>
|
||||||
<button
|
<Button size="small"
|
||||||
className="small"
|
|
||||||
onClick={() => navigator.clipboard.writeText(created).then(() => toast(t("tokens.copied"), "success"))}
|
onClick={() => navigator.clipboard.writeText(created).then(() => toast(t("tokens.copied"), "success"))}
|
||||||
>
|
>
|
||||||
<Icon name="copy" /> {t("tokens.copy")}
|
<Icon name="copy" /> {t("tokens.copy")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<pre className="mono token-example">{`codecraft login ${location.origin}`}</pre>
|
<pre className="mono token-example">{`codecraft login ${location.origin}`}</pre>
|
||||||
</div>
|
</div>
|
||||||
@@ -83,8 +84,7 @@ export function ApiTokens() {
|
|||||||
<td>{k.last_used ? fmtRelative(k.last_used) : "–"}</td>
|
<td>{k.last_used ? fmtRelative(k.last_used) : "–"}</td>
|
||||||
<td>{k.expires_at ? new Date(k.expires_at).toLocaleDateString() : t("tokens.never")}</td>
|
<td>{k.expires_at ? new Date(k.expires_at).toLocaleDateString() : t("tokens.never")}</td>
|
||||||
<td>
|
<td>
|
||||||
<button
|
<Button type="text" danger size="small"
|
||||||
className="small ghost danger"
|
|
||||||
aria-label={t("tokens.revoke")}
|
aria-label={t("tokens.revoke")}
|
||||||
title={t("tokens.revoke")}
|
title={t("tokens.revoke")}
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
@@ -95,7 +95,7 @@ export function ApiTokens() {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Icon name="trash" />
|
<Icon name="trash" />
|
||||||
</button>
|
</Button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
))}
|
))}
|
||||||
@@ -103,20 +103,20 @@ export function ApiTokens() {
|
|||||||
</table>
|
</table>
|
||||||
)}
|
)}
|
||||||
<div className="row" style={{ gap: 6, marginTop: 10, flexWrap: "wrap" }}>
|
<div className="row" style={{ gap: 6, marginTop: 10, flexWrap: "wrap" }}>
|
||||||
<input style={{ flex: 1, minWidth: 160 }} placeholder={t("tokens.namePlaceholder")} value={name} onChange={(e) => setName(e.target.value)} />
|
<Input style={{ flex: 1, minWidth: 160 }} placeholder={t("tokens.namePlaceholder")} value={name} onChange={(e) => setName(e.target.value)} />
|
||||||
<select value={scope} onChange={(e) => setScope(e.target.value as "full" | "read")}>
|
<Select value={scope} onChange={(e) => setScope(e.target.value as "full" | "read")}>
|
||||||
<option value="full">{t("tokens.scopeFull")}</option>
|
<option value="full">{t("tokens.scopeFull")}</option>
|
||||||
<option value="read">{t("tokens.scopeRead")}</option>
|
<option value="read">{t("tokens.scopeRead")}</option>
|
||||||
</select>
|
</Select>
|
||||||
<select value={days} onChange={(e) => setDays(e.target.value)}>
|
<Select value={days} onChange={(e) => setDays(e.target.value)}>
|
||||||
<option value="">{t("tokens.noExpiry")}</option>
|
<option value="">{t("tokens.noExpiry")}</option>
|
||||||
<option value="30">30 {t("tokens.days")}</option>
|
<option value="30">30 {t("tokens.days")}</option>
|
||||||
<option value="90">90 {t("tokens.days")}</option>
|
<option value="90">90 {t("tokens.days")}</option>
|
||||||
<option value="365">365 {t("tokens.days")}</option>
|
<option value="365">365 {t("tokens.days")}</option>
|
||||||
</select>
|
</Select>
|
||||||
<button className="primary" disabled={!name.trim()} onClick={create}>
|
<Button type="primary" disabled={!name.trim()} onClick={create}>
|
||||||
<Icon name="plus" /> {t("tokens.create")}
|
<Icon name="plus" /> {t("tokens.create")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { Button } from "antd";
|
||||||
|
import { Select } from "../../ui/Select";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { useFetch } from "../../hooks";
|
import { useFetch } from "../../hooks";
|
||||||
import { fmtDate, useT } from "../../i18n";
|
import { fmtDate, useT } from "../../i18n";
|
||||||
@@ -24,17 +26,17 @@ export function Audit() {
|
|||||||
<h3>
|
<h3>
|
||||||
{t("audit.title")}
|
{t("audit.title")}
|
||||||
<span className="spacer" />
|
<span className="spacer" />
|
||||||
<select value={filter} onChange={(e) => setFilter(e.target.value)}>
|
<Select value={filter} onChange={(e) => setFilter(e.target.value)}>
|
||||||
<option value="">{t("audit.all")}</option>
|
<option value="">{t("audit.all")}</option>
|
||||||
{["login", "permission", "config", "user", "folder", "session", "git", "backup"].map((a) => (
|
{["login", "permission", "config", "user", "folder", "session", "git", "backup"].map((a) => (
|
||||||
<option key={a} value={a}>
|
<option key={a} value={a}>
|
||||||
{a}
|
{a}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</Select>
|
||||||
<button className="small" onClick={reload} aria-label={t("common.refresh")}>
|
<Button size="small" onClick={reload} aria-label={t("common.refresh")}>
|
||||||
<Icon name="refresh" />
|
<Icon name="refresh" />
|
||||||
</button>
|
</Button>
|
||||||
</h3>
|
</h3>
|
||||||
<div style={{ overflowX: "auto" }}>
|
<div style={{ overflowX: "auto" }}>
|
||||||
<table className="grid">
|
<table className="grid">
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { Button, Checkbox, Input } from "antd";
|
||||||
import { uploadBatch } from "../../uploads";
|
import { uploadBatch } from "../../uploads";
|
||||||
import { useEffect, useRef, useState } from "react";
|
import { useEffect, useRef, useState } from "react";
|
||||||
import { api, get, patch, post } from "../../api";
|
import { api, get, patch, post } from "../../api";
|
||||||
@@ -142,9 +143,9 @@ export function Backups() {
|
|||||||
<a className="button small" href="/api/backup">
|
<a className="button small" href="/api/backup">
|
||||||
<Icon name="download" /> {t("audit.download")}
|
<Icon name="download" /> {t("audit.download")}
|
||||||
</a>
|
</a>
|
||||||
<button className="small" onClick={() => fileInput.current?.click()} disabled={restoring}>
|
<Button size="small" onClick={() => fileInput.current?.click()} disabled={restoring}>
|
||||||
<Icon name="upload" /> {restoring ? t("backup.restoring") : t("backup.restoreFile")}
|
<Icon name="upload" /> {restoring ? t("backup.restoring") : t("backup.restoreFile")}
|
||||||
</button>
|
</Button>
|
||||||
<input
|
<input
|
||||||
ref={fileInput}
|
ref={fileInput}
|
||||||
type="file"
|
type="file"
|
||||||
@@ -156,9 +157,9 @@ export function Backups() {
|
|||||||
if (file) void restore({ file });
|
if (file) void restore({ file });
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<button className="small primary" onClick={runNow} disabled={busy}>
|
<Button type="primary" size="small" onClick={runNow} disabled={busy}>
|
||||||
{busy ? t("backup.running") : t("backup.now")}
|
{busy ? t("backup.running") : t("backup.now")}
|
||||||
</button>
|
</Button>
|
||||||
</h3>
|
</h3>
|
||||||
<div className="hint" style={{ marginBottom: 10 }}>
|
<div className="hint" style={{ marginBottom: 10 }}>
|
||||||
{t("audit.backupHint")}
|
{t("audit.backupHint")}
|
||||||
@@ -166,18 +167,17 @@ export function Backups() {
|
|||||||
{form && (
|
{form && (
|
||||||
<>
|
<>
|
||||||
<div className="row" style={{ gap: 12, flexWrap: "wrap", alignItems: "center" }}>
|
<div className="row" style={{ gap: 12, flexWrap: "wrap", alignItems: "center" }}>
|
||||||
<label className="row" style={{ gap: 6, alignItems: "center" }}>
|
<Checkbox className="row" style={{ gap: 6, alignItems: "center" }} checked={form.enabled} onChange={(e) => setForm({ ...form, enabled: e.target.checked })}>
|
||||||
<input type="checkbox" checked={form.enabled} onChange={(e) => setForm({ ...form, enabled: e.target.checked })} />
|
|
||||||
{t("backup.daily")}
|
{t("backup.daily")}
|
||||||
</label>
|
</Checkbox>
|
||||||
<label className="row" style={{ gap: 6, alignItems: "center" }}>
|
<label className="row" style={{ gap: 6, alignItems: "center" }}>
|
||||||
{t("backup.at")}
|
{t("backup.at")}
|
||||||
<input type="number" min={0} max={23} style={{ width: 64 }} value={form.hour} onChange={(e) => setForm({ ...form, hour: Number(e.target.value) })} />
|
<Input type="number" min={0} max={23} style={{ width: 64 }} value={form.hour} onChange={(e) => setForm({ ...form, hour: Number(e.target.value) })} />
|
||||||
{t("backup.oclock")}
|
{t("backup.oclock")}
|
||||||
</label>
|
</label>
|
||||||
<label className="row" style={{ gap: 6, alignItems: "center" }}>
|
<label className="row" style={{ gap: 6, alignItems: "center" }}>
|
||||||
{t("backup.keep")}
|
{t("backup.keep")}
|
||||||
<input type="number" min={1} style={{ width: 70 }} value={form.keep} onChange={(e) => setForm({ ...form, keep: Number(e.target.value) })} />
|
<Input type="number" min={1} style={{ width: 70 }} value={form.keep} onChange={(e) => setForm({ ...form, keep: Number(e.target.value) })} />
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
{data && <div className="hint mono" style={{ marginTop: 6 }}>{data.dir}</div>}
|
{data && <div className="hint mono" style={{ marginTop: 6 }}>{data.dir}</div>}
|
||||||
@@ -194,8 +194,7 @@ export function Backups() {
|
|||||||
{s3("access_key", t("backup.accessKey"), "AKIA… or ${S3_ACCESS_KEY}")}
|
{s3("access_key", t("backup.accessKey"), "AKIA… or ${S3_ACCESS_KEY}")}
|
||||||
<label className="field">
|
<label className="field">
|
||||||
<span>{t("backup.secretKey")}</span>
|
<span>{t("backup.secretKey")}</span>
|
||||||
<input
|
<Input.Password
|
||||||
type="password"
|
|
||||||
value={secret}
|
value={secret}
|
||||||
autoComplete="new-password"
|
autoComplete="new-password"
|
||||||
placeholder={form.s3.secret_key === MASK ? t("backup.secretStored") : form.s3.secret_key || "${S3_SECRET_KEY}"}
|
placeholder={form.s3.secret_key === MASK ? t("backup.secretStored") : form.s3.secret_key || "${S3_SECRET_KEY}"}
|
||||||
@@ -206,9 +205,9 @@ export function Backups() {
|
|||||||
</div>
|
</div>
|
||||||
</details>
|
</details>
|
||||||
<div className="row" style={{ marginTop: 10, justifyContent: "flex-end" }}>
|
<div className="row" style={{ marginTop: 10, justifyContent: "flex-end" }}>
|
||||||
<button className="primary" onClick={save}>
|
<Button type="primary" onClick={save}>
|
||||||
{t("common.save")}
|
{t("common.save")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
@@ -225,9 +224,9 @@ export function Backups() {
|
|||||||
<Icon name="file" />
|
<Icon name="file" />
|
||||||
<span className="grow">{f.name}</span>
|
<span className="grow">{f.name}</span>
|
||||||
<span className="hint">{formatSize(f.size)}</span>
|
<span className="hint">{formatSize(f.size)}</span>
|
||||||
<button className="small" title={t("backup.restore")} onClick={() => void restore({ name: f.name })} disabled={restoring}>
|
<Button size="small" title={t("backup.restore")} onClick={() => void restore({ name: f.name })} disabled={restoring}>
|
||||||
<Icon name="undo" />
|
<Icon name="undo" />
|
||||||
</button>
|
</Button>
|
||||||
<a className="button small" title={t("audit.download")} href={`/api/backups/${encodeURIComponent(f.name)}`}>
|
<a className="button small" title={t("audit.download")} href={`/api/backups/${encodeURIComponent(f.name)}`}>
|
||||||
<Icon name="download" />
|
<Icon name="download" />
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { Button, Checkbox, Input } from "antd";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { api, get, post } from "../../api";
|
import { api, get, post } from "../../api";
|
||||||
import { confirmDialog, toast } from "../../dialogs";
|
import { confirmDialog, toast } from "../../dialogs";
|
||||||
@@ -111,9 +112,9 @@ export function ClaudeCode() {
|
|||||||
<Icon name="robot" /> {t("claude.title")}
|
<Icon name="robot" /> {t("claude.title")}
|
||||||
<span className="spacer" />
|
<span className="spacer" />
|
||||||
{status?.logged_in && (
|
{status?.logged_in && (
|
||||||
<button className="small ghost danger" onClick={logout}>
|
<Button type="text" danger size="small" onClick={logout}>
|
||||||
{t("claude.logout")}
|
{t("claude.logout")}
|
||||||
</button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</h3>
|
</h3>
|
||||||
<div className="hint" style={{ marginBottom: 10 }}>{t("claude.intro")}</div>
|
<div className="hint" style={{ marginBottom: 10 }}>{t("claude.intro")}</div>
|
||||||
@@ -126,9 +127,9 @@ export function ClaudeCode() {
|
|||||||
<>
|
<>
|
||||||
<span className="chip warn">{t("claude.updateAvailable", { version: status.latest ?? "" })}</span>
|
<span className="chip warn">{t("claude.updateAvailable", { version: status.latest ?? "" })}</span>
|
||||||
{isAdmin ? (
|
{isAdmin ? (
|
||||||
<button className="small primary" disabled={updating} onClick={update}>
|
<Button type="primary" size="small" disabled={updating} onClick={update}>
|
||||||
{updating ? <Spinner small /> : <Icon name="download" />} {updating ? t("claude.updating") : t("claude.update")}
|
{updating ? <Spinner small /> : <Icon name="download" />} {updating ? t("claude.updating") : t("claude.update")}
|
||||||
</button>
|
</Button>
|
||||||
) : (
|
) : (
|
||||||
<span className="hint">{t("claude.updateAdmin")}</span>
|
<span className="hint">{t("claude.updateAdmin")}</span>
|
||||||
)}
|
)}
|
||||||
@@ -136,9 +137,9 @@ export function ClaudeCode() {
|
|||||||
) : (
|
) : (
|
||||||
status.latest && <span className="chip">{t("claude.upToDate")}</span>
|
status.latest && <span className="chip">{t("claude.upToDate")}</span>
|
||||||
)}
|
)}
|
||||||
<button className="small ghost" disabled={checking || updating} onClick={check} title={t("claude.checkNow")} aria-label={t("claude.checkNow")}>
|
<Button type="text" size="small" disabled={checking || updating} onClick={check} title={t("claude.checkNow")} aria-label={t("claude.checkNow")}>
|
||||||
{checking ? <Spinner small /> : <Icon name="refresh" />}
|
{checking ? <Spinner small /> : <Icon name="refresh" />}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{updateLog && (
|
{updateLog && (
|
||||||
@@ -158,12 +159,11 @@ export function ClaudeCode() {
|
|||||||
)}
|
)}
|
||||||
{status?.installed && !status.logged_in && !url && (
|
{status?.installed && !status.logged_in && !url && (
|
||||||
<>
|
<>
|
||||||
<label className="row" style={{ marginBottom: 8 }}>
|
<Checkbox className="row" style={{ marginBottom: 8 }} checked={console_} onChange={(e) => setConsole(e.target.checked)}> {t("claude.console")}
|
||||||
<input type="checkbox" checked={console_} onChange={(e) => setConsole(e.target.checked)} /> {t("claude.console")}
|
</Checkbox>
|
||||||
</label>
|
<Button type="primary" disabled={busy} onClick={start}>
|
||||||
<button className="primary" disabled={busy} onClick={start}>
|
|
||||||
{busy ? <Spinner small /> : <Icon name="lock" />} {t("claude.signIn")}
|
{busy ? <Spinner small /> : <Icon name="lock" />} {t("claude.signIn")}
|
||||||
</button>
|
</Button>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{url && (
|
{url && (
|
||||||
@@ -177,11 +177,11 @@ export function ClaudeCode() {
|
|||||||
<li>
|
<li>
|
||||||
{t("claude.step2")}
|
{t("claude.step2")}
|
||||||
<div className="row" style={{ marginTop: 6 }}>
|
<div className="row" style={{ marginTop: 6 }}>
|
||||||
<input style={{ flex: 1 }} value={code} placeholder={t("claude.codePlaceholder")} autoComplete="off" autoCapitalize="off" spellCheck={false} onChange={(e) => setCode(e.target.value)} onKeyDown={(e) => e.key === "Enter" && code.trim() && void submit()} />
|
<Input style={{ flex: 1 }} value={code} placeholder={t("claude.codePlaceholder")} autoComplete="off" autoCapitalize="off" spellCheck={false} onChange={(e) => setCode(e.target.value)} onKeyDown={(e) => e.key === "Enter" && code.trim() && void submit()} />
|
||||||
<button className="primary" disabled={busy || !code.trim()} onClick={submit}>
|
<Button type="primary" disabled={busy || !code.trim()} onClick={submit}>
|
||||||
{busy ? <Spinner small /> : <Icon name="check" />} {t("claude.confirm")}
|
{busy ? <Spinner small /> : <Icon name="check" />} {t("claude.confirm")}
|
||||||
</button>
|
</Button>
|
||||||
<button onClick={cancel}>{t("common.cancel")}</button>
|
<Button onClick={cancel}>{t("common.cancel")}</Button>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
</ol>
|
</ol>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { Button } from "antd";
|
||||||
import { useT } from "../../i18n";
|
import { useT } from "../../i18n";
|
||||||
import { toast } from "../../dialogs";
|
import { toast } from "../../dialogs";
|
||||||
import { Icon } from "../Icon";
|
import { Icon } from "../Icon";
|
||||||
@@ -25,18 +26,18 @@ export function CliInstall() {
|
|||||||
{t(prebuilt ? "cli.step1" : "cli.step1Source")}
|
{t(prebuilt ? "cli.step1" : "cli.step1Source")}
|
||||||
<div className="row" style={{ gap: 6, marginTop: 4 }}>
|
<div className="row" style={{ gap: 6, marginTop: 4 }}>
|
||||||
<code className="token-value">{cmd}</code>
|
<code className="token-value">{cmd}</code>
|
||||||
<button className="small" onClick={() => copy(cmd)}>
|
<Button size="small" onClick={() => copy(cmd)}>
|
||||||
<Icon name="copy" /> {t("tokens.copy")}
|
<Icon name="copy" /> {t("tokens.copy")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
{t("cli.step2")}
|
{t("cli.step2")}
|
||||||
<div className="row" style={{ gap: 6, marginTop: 4 }}>
|
<div className="row" style={{ gap: 6, marginTop: 4 }}>
|
||||||
<code className="token-value">{`codecraft login ${location.origin}`}</code>
|
<code className="token-value">{`codecraft login ${location.origin}`}</code>
|
||||||
<button className="small" onClick={() => copy(`codecraft login ${location.origin}`)}>
|
<Button size="small" onClick={() => copy(`codecraft login ${location.origin}`)}>
|
||||||
<Icon name="copy" /> {t("tokens.copy")}
|
<Icon name="copy" /> {t("tokens.copy")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li>{t("cli.step3")}</li>
|
<li>{t("cli.step3")}</li>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { Button, Checkbox, Input } from "antd";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { del, post, put } from "../../api";
|
import { del, post, put } from "../../api";
|
||||||
import { useFetch } from "../../hooks";
|
import { useFetch } from "../../hooks";
|
||||||
@@ -45,17 +46,16 @@ export function Folders() {
|
|||||||
<h3>
|
<h3>
|
||||||
📁 <code>{f.path.slice(ws.length) || "/"}</code>
|
📁 <code>{f.path.slice(ws.length) || "/"}</code>
|
||||||
<span className="spacer" />
|
<span className="spacer" />
|
||||||
<button className="small danger" onClick={() => void confirmDialog({ message: t("folders.removeConfirm"), danger: true, confirmLabel: t("folders.remove") }).then((ok): unknown => ok && run(() => del(`/folders/${f.id}`)))}>
|
<Button danger size="small" onClick={() => void confirmDialog({ message: t("folders.removeConfirm"), danger: true, confirmLabel: t("folders.remove") }).then((ok): unknown => ok && run(() => del(`/folders/${f.id}`)))}>
|
||||||
{t("folders.remove")}
|
{t("folders.remove")}
|
||||||
</button>
|
</Button>
|
||||||
</h3>
|
</h3>
|
||||||
<div className="check-list">
|
<div className="check-list">
|
||||||
{users.length === 0 && <div style={{ color: "var(--muted)" }}>{t("folders.noUsers")}</div>}
|
{users.length === 0 && <div style={{ color: "var(--muted)" }}>{t("folders.noUsers")}</div>}
|
||||||
{users.map((u) => (
|
{users.map((u) => (
|
||||||
<label key={u.id}>
|
<Checkbox key={u.id} checked={f.users.includes(u.id)} onChange={() => toggle(f, u.id)}>
|
||||||
<input type="checkbox" checked={f.users.includes(u.id)} onChange={() => toggle(f, u.id)} />
|
|
||||||
{u.display_name || u.username} <span style={{ color: "var(--muted)" }}>@{u.username}</span>
|
{u.display_name || u.username} <span style={{ color: "var(--muted)" }}>@{u.username}</span>
|
||||||
</label>
|
</Checkbox>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -64,10 +64,10 @@ export function Folders() {
|
|||||||
<h3>{t("folders.add")}</h3>
|
<h3>{t("folders.add")}</h3>
|
||||||
<div className="row">
|
<div className="row">
|
||||||
<code>{ws}/</code>
|
<code>{ws}/</code>
|
||||||
<input value={path} onChange={(e) => setPath(e.target.value)} placeholder="team/project" style={{ flex: 1, minWidth: 160 }} />
|
<Input value={path} onChange={(e) => setPath(e.target.value)} placeholder="team/project" style={{ flex: 1, minWidth: 160 }} />
|
||||||
<button className="primary" disabled={!path.trim()} onClick={() => run(async () => (await post("/folders", { path }), setPath("")))}>
|
<Button type="primary" disabled={!path.trim()} onClick={() => run(async () => (await post("/folders", { path }), setPath("")))}>
|
||||||
+ {t("common.add")}
|
+ {t("common.add")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<div style={{ fontSize: 12, color: "var(--muted)", marginTop: 6 }}>{t("folders.addHint")}</div>
|
<div style={{ fontSize: 12, color: "var(--muted)", marginTop: 6 }}>{t("folders.addHint")}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { Button, Input } from "antd";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { get, put } from "../../api";
|
import { get, put } from "../../api";
|
||||||
import { useT } from "../../i18n";
|
import { useT } from "../../i18n";
|
||||||
@@ -54,19 +55,18 @@ export function GitAccount() {
|
|||||||
</div>
|
</div>
|
||||||
<div className="form">
|
<div className="form">
|
||||||
<label>{t("gitcred.name")}</label>
|
<label>{t("gitcred.name")}</label>
|
||||||
<input value={s.name} onChange={(e) => setS({ ...s, name: e.target.value })} placeholder="Jane Doe" autoComplete="name" />
|
<Input value={s.name} onChange={(e) => setS({ ...s, name: e.target.value })} placeholder="Jane Doe" autoComplete="name" />
|
||||||
<label>{t("gitcred.email")}</label>
|
<label>{t("gitcred.email")}</label>
|
||||||
<input value={s.email} onChange={(e) => setS({ ...s, email: e.target.value })} placeholder="jane@example.com" autoComplete="email" />
|
<Input value={s.email} onChange={(e) => setS({ ...s, email: e.target.value })} placeholder="jane@example.com" autoComplete="email" />
|
||||||
</div>
|
</div>
|
||||||
<h4 style={{ margin: "16px 0 8px" }}>{t("gitcred.credentials")}</h4>
|
<h4 style={{ margin: "16px 0 8px" }}>{t("gitcred.credentials")}</h4>
|
||||||
<div className="gitcred-list">
|
<div className="gitcred-list">
|
||||||
{s.credentials.length === 0 && <div className="empty" style={{ padding: 8 }}>{t("gitcred.none")}</div>}
|
{s.credentials.length === 0 && <div className="empty" style={{ padding: 8 }}>{t("gitcred.none")}</div>}
|
||||||
{s.credentials.map((c, i) => (
|
{s.credentials.map((c, i) => (
|
||||||
<div key={i} className="gitcred-row">
|
<div key={i} className="gitcred-row">
|
||||||
<input value={c.host} placeholder="git.example.com" onChange={(e) => setCred(i, { host: e.target.value })} aria-label={t("gitcred.host")} />
|
<Input value={c.host} placeholder="git.example.com" onChange={(e) => setCred(i, { host: e.target.value })} aria-label={t("gitcred.host")} />
|
||||||
<input value={c.username} placeholder={t("gitcred.user")} onChange={(e) => setCred(i, { username: e.target.value })} aria-label={t("gitcred.user")} autoComplete="off" />
|
<Input value={c.username} placeholder={t("gitcred.user")} onChange={(e) => setCred(i, { username: e.target.value })} aria-label={t("gitcred.user")} autoComplete="off" />
|
||||||
<input
|
<Input.Password
|
||||||
type="password"
|
|
||||||
value={c.token}
|
value={c.token}
|
||||||
placeholder={t("gitcred.token")}
|
placeholder={t("gitcred.token")}
|
||||||
onFocus={(e) => c.token.startsWith("•") && e.target.select()}
|
onFocus={(e) => c.token.startsWith("•") && e.target.select()}
|
||||||
@@ -74,20 +74,20 @@ export function GitAccount() {
|
|||||||
aria-label={t("gitcred.token")}
|
aria-label={t("gitcred.token")}
|
||||||
autoComplete="new-password"
|
autoComplete="new-password"
|
||||||
/>
|
/>
|
||||||
<button className="ghost small" onClick={() => setS({ ...s, credentials: s.credentials.filter((_, j) => j !== i) })} aria-label={t("common.remove")}>
|
<Button type="text" size="small" onClick={() => setS({ ...s, credentials: s.credentials.filter((_, j) => j !== i) })} aria-label={t("common.remove")}>
|
||||||
<Icon name="trash" />
|
<Icon name="trash" />
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
<div className="row" style={{ marginTop: 10, gap: 8 }}>
|
<div className="row" style={{ marginTop: 10, gap: 8 }}>
|
||||||
<button className="small" onClick={() => setS({ ...s, credentials: [...s.credentials, { host: "", username: "", token: "" }] })}>
|
<Button size="small" onClick={() => setS({ ...s, credentials: [...s.credentials, { host: "", username: "", token: "" }] })}>
|
||||||
<Icon name="plus" /> {t("gitcred.add")}
|
<Icon name="plus" /> {t("gitcred.add")}
|
||||||
</button>
|
</Button>
|
||||||
<span className="grow" />
|
<span className="grow" />
|
||||||
<button className="primary" onClick={save} disabled={saving}>
|
<Button type="primary" onClick={save} disabled={saving}>
|
||||||
{t("common.save")}
|
{t("common.save")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { Button, Input } from "antd";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { get, put } from "../../api";
|
import { get, put } from "../../api";
|
||||||
import { useT } from "../../i18n";
|
import { useT } from "../../i18n";
|
||||||
@@ -22,12 +23,12 @@ export function Memory() {
|
|||||||
<div className="hint" style={{ marginBottom: 8 }}>
|
<div className="hint" style={{ marginBottom: 8 }}>
|
||||||
{t("memory.hint")}
|
{t("memory.hint")}
|
||||||
</div>
|
</div>
|
||||||
<textarea rows={6} style={{ width: "100%" }} value={text} placeholder={t("memory.placeholder")} onChange={(e) => setText(e.target.value)} />
|
<Input.TextArea rows={6} style={{ width: "100%" }} value={text} placeholder={t("memory.placeholder")} onChange={(e) => setText(e.target.value)} />
|
||||||
<div className="row" style={{ marginTop: 8 }}>
|
<div className="row" style={{ marginTop: 8 }}>
|
||||||
<span className="grow" />
|
<span className="grow" />
|
||||||
<button className="primary" onClick={() => put("/account/memory", { memory: text }).then(() => toast(t("settings.saved"), "success")).catch((e) => toast(e.message))}>
|
<Button type="primary" onClick={() => put("/account/memory", { memory: text }).then(() => toast(t("settings.saved"), "success")).catch((e) => toast(e.message))}>
|
||||||
{t("common.save")}
|
{t("common.save")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { Button, Checkbox, Input } from "antd";
|
||||||
|
import { Select } from "../../ui/Select";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { get, put } from "../../api";
|
import { get, put } from "../../api";
|
||||||
import { confirmDialog, toast } from "../../dialogs";
|
import { confirmDialog, toast } from "../../dialogs";
|
||||||
@@ -70,10 +72,10 @@ export function PersonalModes() {
|
|||||||
<div className="panel">
|
<div className="panel">
|
||||||
<h3>{t("agents.addMode")}</h3>
|
<h3>{t("agents.addMode")}</h3>
|
||||||
<div className="row">
|
<div className="row">
|
||||||
<input placeholder={t("settings.name")} value={name} onChange={(e) => setName(e.target.value)} onKeyDown={(e) => e.key === "Enter" && void add()} />
|
<Input placeholder={t("settings.name")} value={name} onChange={(e) => setName(e.target.value)} onKeyDown={(e) => e.key === "Enter" && void add()} />
|
||||||
<button className="primary" onClick={() => void add()} disabled={!name.trim()}>
|
<Button type="primary" onClick={() => void add()} disabled={!name.trim()}>
|
||||||
+ {t("agents.addMode")}
|
+ {t("agents.addMode")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
@@ -106,40 +108,39 @@ function ModeRow({ name, mode, tools, open, onToggle, onSave, onRemove }: { name
|
|||||||
<span className="chip">{form.style === "chat" ? t("agents.styleChatShort") : t("agents.styleCodingShort")}</span>
|
<span className="chip">{form.style === "chat" ? t("agents.styleChatShort") : t("agents.styleCodingShort")}</span>
|
||||||
{form.read_only && <span className="chip">{t("agents.readOnly")}</span>}
|
{form.read_only && <span className="chip">{t("agents.readOnly")}</span>}
|
||||||
<span className="spacer" />
|
<span className="spacer" />
|
||||||
<button className="small ghost danger" onClick={onRemove} title={t("common.delete")} aria-label={t("common.delete")}>
|
<Button type="text" danger size="small" onClick={onRemove} title={t("common.delete")} aria-label={t("common.delete")}>
|
||||||
<Icon name="trash" />
|
<Icon name="trash" />
|
||||||
</button>
|
</Button>
|
||||||
<button className="small" onClick={onToggle}>
|
<Button size="small" onClick={onToggle}>
|
||||||
{open ? t("common.collapse") : t("common.edit")}
|
{open ? t("common.collapse") : t("common.edit")}
|
||||||
</button>
|
</Button>
|
||||||
</h3>
|
</h3>
|
||||||
{!open && mode.description && <div className="hint">{mode.description}</div>}
|
{!open && mode.description && <div className="hint">{mode.description}</div>}
|
||||||
{open && (
|
{open && (
|
||||||
<>
|
<>
|
||||||
<div className="form">
|
<div className="form">
|
||||||
<label>{t("agents.description")}</label>
|
<label>{t("agents.description")}</label>
|
||||||
<input value={form.description} onChange={(e) => setForm({ ...form, description: e.target.value })} />
|
<Input value={form.description} onChange={(e) => setForm({ ...form, description: e.target.value })} />
|
||||||
<label>{t("agents.style")}</label>
|
<label>{t("agents.style")}</label>
|
||||||
<select value={form.style} onChange={(e) => setForm({ ...form, style: e.target.value as "coding" | "chat" })}>
|
<Select value={form.style} onChange={(e) => setForm({ ...form, style: e.target.value as "coding" | "chat" })}>
|
||||||
<option value="coding">{t("agents.styleCoding")}</option>
|
<option value="coding">{t("agents.styleCoding")}</option>
|
||||||
<option value="chat">{t("agents.styleChat")}</option>
|
<option value="chat">{t("agents.styleChat")}</option>
|
||||||
</select>
|
</Select>
|
||||||
<label>{t("agents.model")}</label>
|
<label>{t("agents.model")}</label>
|
||||||
<ModelSelect value={form.model} onChange={(v) => setForm({ ...form, model: v })} emptyLabel={t("agents.sessionModel")} />
|
<ModelSelect value={form.model} onChange={(v) => setForm({ ...form, model: v })} emptyLabel={t("agents.sessionModel")} />
|
||||||
<label>{t("agents.readOnlyLabel")}</label>
|
<label>{t("agents.readOnlyLabel")}</label>
|
||||||
<label className="row" style={{ gap: 6, alignItems: "center" }}>
|
<Checkbox className="row" style={{ gap: 6, alignItems: "center" }} checked={form.read_only} onChange={(e) => setForm({ ...form, read_only: e.target.checked })}>
|
||||||
<input type="checkbox" checked={form.read_only} onChange={(e) => setForm({ ...form, read_only: e.target.checked })} />
|
|
||||||
<span className="hint">{t("agents.readOnlyHint")}</span>
|
<span className="hint">{t("agents.readOnlyHint")}</span>
|
||||||
</label>
|
</Checkbox>
|
||||||
<label>{t("agents.tools")}</label>
|
<label>{t("agents.tools")}</label>
|
||||||
<ToolPicker tools={tools} value={form.tools} onChange={(v) => setForm({ ...form, tools: v })} readOnly={form.read_only} />
|
<ToolPicker tools={tools} value={form.tools} onChange={(v) => setForm({ ...form, tools: v })} readOnly={form.read_only} />
|
||||||
<label>{t("agents.prompt")}</label>
|
<label>{t("agents.prompt")}</label>
|
||||||
<textarea rows={8} value={form.prompt} placeholder={t("modes.promptPlaceholder")} onChange={(e) => setForm({ ...form, prompt: e.target.value })} />
|
<Input.TextArea rows={8} value={form.prompt} placeholder={t("modes.promptPlaceholder")} onChange={(e) => setForm({ ...form, prompt: e.target.value })} />
|
||||||
</div>
|
</div>
|
||||||
<div className="row" style={{ marginTop: 12 }}>
|
<div className="row" style={{ marginTop: 12 }}>
|
||||||
<button className="primary" onClick={submit}>
|
<Button type="primary" onClick={submit}>
|
||||||
{t("common.save")}
|
{t("common.save")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { Button, Checkbox, Input } from "antd";
|
||||||
|
import { Modal } from "../../ui/Modal";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { del, get, post, put } from "../../api";
|
import { del, get, post, put } from "../../api";
|
||||||
import { confirmDialog, promptDialog, toast } from "../../dialogs";
|
import { confirmDialog, promptDialog, toast } from "../../dialogs";
|
||||||
@@ -54,14 +56,14 @@ export function Skills() {
|
|||||||
{t("skills.hint")}
|
{t("skills.hint")}
|
||||||
</div>
|
</div>
|
||||||
<div className="row" style={{ gap: 6, marginBottom: 8 }}>
|
<div className="row" style={{ gap: 6, marginBottom: 8 }}>
|
||||||
<button className="primary" onClick={() => setEditing({ name: "", isNew: true })}>
|
<Button type="primary" onClick={() => setEditing({ name: "", isNew: true })}>
|
||||||
<Icon name="plus" /> {t("skills.new")}
|
<Icon name="plus" /> {t("skills.new")}
|
||||||
</button>
|
</Button>
|
||||||
<button onClick={() => setImporting(true)}>
|
<Button onClick={() => setImporting(true)}>
|
||||||
<Icon name="git" /> {t("skills.import")}
|
<Icon name="git" /> {t("skills.import")}
|
||||||
</button>
|
</Button>
|
||||||
<span className="spacer" />
|
<span className="spacer" />
|
||||||
{(data?.skills.length ?? 0) > 8 && <input placeholder={t("skills.filter")} value={filter} onChange={(e) => setFilter(e.target.value)} />}
|
{(data?.skills.length ?? 0) > 8 && <Input placeholder={t("skills.filter")} value={filter} onChange={(e) => setFilter(e.target.value)} />}
|
||||||
</div>
|
</div>
|
||||||
{!data ? (
|
{!data ? (
|
||||||
<Spinner />
|
<Spinner />
|
||||||
@@ -77,12 +79,12 @@ export function Skills() {
|
|||||||
{s.description}
|
{s.description}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<button className="small" onClick={() => setEditing({ name: s.name, isNew: false })}>
|
<Button size="small" onClick={() => setEditing({ name: s.name, isNew: false })}>
|
||||||
<Icon name="edit" /> {t("common.edit")}
|
<Icon name="edit" /> {t("common.edit")}
|
||||||
</button>
|
</Button>
|
||||||
<button className="small danger" onClick={() => void remove(s)} aria-label={t("common.delete")}>
|
<Button danger size="small" onClick={() => void remove(s)} aria-label={t("common.delete")}>
|
||||||
<Icon name="trash" />
|
<Icon name="trash" />
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
))
|
))
|
||||||
)}
|
)}
|
||||||
@@ -152,8 +154,7 @@ function SkillEditor({ name: initial, isNew, onClose }: { name: string; isNew: b
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="modal-backdrop">
|
<Modal className="draft-modal" role="dialog" aria-label={t("skills.edit")}>
|
||||||
<div className="modal draft-modal" role="dialog" aria-label={t("skills.edit")}>
|
|
||||||
<h3>{isNew ? t("skills.new") : t("skills.edit")}</h3>
|
<h3>{isNew ? t("skills.new") : t("skills.edit")}</h3>
|
||||||
{!loaded ? (
|
{!loaded ? (
|
||||||
<Spinner />
|
<Spinner />
|
||||||
@@ -161,38 +162,37 @@ function SkillEditor({ name: initial, isNew, onClose }: { name: string; isNew: b
|
|||||||
<>
|
<>
|
||||||
<label style={{ display: "block", marginBottom: 8 }}>
|
<label style={{ display: "block", marginBottom: 8 }}>
|
||||||
<span className="hint">{t("skills.name")}</span>
|
<span className="hint">{t("skills.name")}</span>
|
||||||
<input className="mono" style={{ width: "100%" }} value={name} disabled={!isNew} placeholder="frontend" onChange={(e) => setName(e.target.value.toLowerCase().replace(/[^a-z0-9_-]/g, "-"))} />
|
<Input className="mono" style={{ width: "100%" }} value={name} disabled={!isNew} placeholder="frontend" onChange={(e) => setName(e.target.value.toLowerCase().replace(/[^a-z0-9_-]/g, "-"))} />
|
||||||
</label>
|
</label>
|
||||||
<div className="row" style={{ gap: 4, flexWrap: "wrap", marginBottom: 6 }}>
|
<div className="row" style={{ gap: 4, flexWrap: "wrap", marginBottom: 6 }}>
|
||||||
{files.map((f) => (
|
{files.map((f) => (
|
||||||
<button key={f.path} className={`small ${f.path === file?.path ? "primary" : ""}`} onClick={() => setCurrent(f.path)}>
|
<Button key={f.path} size="small" type={f.path === file?.path ? "primary" : "default"} onClick={() => setCurrent(f.path)}>
|
||||||
{f.path}
|
{f.path}
|
||||||
</button>
|
</Button>
|
||||||
))}
|
))}
|
||||||
<button className="small ghost" onClick={() => void addFile()}>
|
<Button type="text" size="small" onClick={() => void addFile()}>
|
||||||
<Icon name="plus" /> {t("skills.file")}
|
<Icon name="plus" /> {t("skills.file")}
|
||||||
</button>
|
</Button>
|
||||||
{file && file.path !== "SKILL.md" && (
|
{file && file.path !== "SKILL.md" && (
|
||||||
<button className="small danger" onClick={removeFile} aria-label={t("common.delete")}>
|
<Button danger size="small" onClick={removeFile} aria-label={t("common.delete")}>
|
||||||
<Icon name="trash" />
|
<Icon name="trash" />
|
||||||
</button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<textarea className="mono" rows={18} style={{ width: "100%" }} value={file?.content ?? ""} onChange={(e) => setContent(e.target.value)} spellCheck={false} />
|
<Input.TextArea className="mono" rows={18} style={{ width: "100%" }} value={file?.content ?? ""} onChange={(e) => setContent(e.target.value)} spellCheck={false} />
|
||||||
<div className="hint">{t("skills.fileHint")}</div>
|
<div className="hint">{t("skills.fileHint")}</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{error && <div className="notice err">{error}</div>}
|
{error && <div className="notice err">{error}</div>}
|
||||||
<div className="row" style={{ marginTop: 10, justifyContent: "flex-end", gap: 6 }}>
|
<div className="row" style={{ marginTop: 10, justifyContent: "flex-end", gap: 6 }}>
|
||||||
<button onClick={() => onClose(false)} disabled={busy}>
|
<Button onClick={() => onClose(false)} disabled={busy}>
|
||||||
{t("common.cancel")}
|
{t("common.cancel")}
|
||||||
</button>
|
</Button>
|
||||||
<button className="primary" onClick={() => void save()} disabled={busy || !loaded || !name.trim() || !files.some((f) => f.path === "SKILL.md")}>
|
<Button type="primary" onClick={() => void save()} disabled={busy || !loaded || !name.trim() || !files.some((f) => f.path === "SKILL.md")}>
|
||||||
{busy ? <Spinner small /> : <Icon name="check" />} {t("common.save")}
|
{busy ? <Spinner small /> : <Icon name="check" />} {t("common.save")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
</Modal>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,51 +240,48 @@ function ImportDialog({ onClose }: { onClose: (done: boolean) => void }) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="modal-backdrop">
|
<Modal className="draft-modal" role="dialog" aria-label={t("skills.import")}>
|
||||||
<div className="modal draft-modal" role="dialog" aria-label={t("skills.import")}>
|
|
||||||
<h3>{t("skills.import")}</h3>
|
<h3>{t("skills.import")}</h3>
|
||||||
<div className="hint" style={{ marginBottom: 8 }}>
|
<div className="hint" style={{ marginBottom: 8 }}>
|
||||||
{t("skills.importHint")}
|
{t("skills.importHint")}
|
||||||
</div>
|
</div>
|
||||||
<div className="row" style={{ gap: 6 }}>
|
<div className="row" style={{ gap: 6 }}>
|
||||||
<input className="mono" style={{ flex: 1 }} value={url} placeholder="https://github.com/owner/repo/tree/main/skills" onChange={(e) => setUrl(e.target.value)} onKeyDown={(e) => e.key === "Enter" && url.trim() && !busy && void scan()} />
|
<Input className="mono" style={{ flex: 1 }} value={url} placeholder="https://github.com/owner/repo/tree/main/skills" onChange={(e) => setUrl(e.target.value)} onKeyDown={(e) => e.key === "Enter" && url.trim() && !busy && void scan()} />
|
||||||
<button onClick={() => void scan()} disabled={busy || !url.trim()}>
|
<Button onClick={() => void scan()} disabled={busy || !url.trim()}>
|
||||||
{busy && !found ? <Spinner small /> : <Icon name="search" />} {t("skills.scan")}
|
{busy && !found ? <Spinner small /> : <Icon name="search" />} {t("skills.scan")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
{found && found.length > 0 && (
|
{found && found.length > 0 && (
|
||||||
<>
|
<>
|
||||||
<div className="row" style={{ gap: 6, margin: "8px 0" }}>
|
<div className="row" style={{ gap: 6, margin: "8px 0" }}>
|
||||||
<input style={{ flex: 1 }} placeholder={t("skills.filter")} value={filter} onChange={(e) => setFilter(e.target.value)} />
|
<Input style={{ flex: 1 }} placeholder={t("skills.filter")} value={filter} onChange={(e) => setFilter(e.target.value)} />
|
||||||
<button className="small" onClick={() => setPicked(new Set([...picked, ...shown.map((s) => s.path)]))}>
|
<Button size="small" onClick={() => setPicked(new Set([...picked, ...shown.map((s) => s.path)]))}>
|
||||||
{t("skills.selectShown", { n: shown.length })}
|
{t("skills.selectShown", { n: shown.length })}
|
||||||
</button>
|
</Button>
|
||||||
<button className="small ghost" onClick={() => setPicked(new Set())}>
|
<Button type="text" size="small" onClick={() => setPicked(new Set())}>
|
||||||
{t("skills.selectNone")}
|
{t("skills.selectNone")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<div className="issue-list">
|
<div className="issue-list">
|
||||||
{shown.map((s) => (
|
{shown.map((s) => (
|
||||||
<label key={s.path} className="row" style={{ gap: 8, padding: "2px 0" }}>
|
<Checkbox key={s.path} className="row" style={{ gap: 8, padding: "2px 0" }} checked={picked.has(s.path)} onChange={() => toggle(s.path)}>
|
||||||
<input type="checkbox" checked={picked.has(s.path)} onChange={() => toggle(s.path)} />
|
|
||||||
<span>
|
<span>
|
||||||
<code>{s.name}</code> <span className="hint">{s.path} · {t("skills.files", { n: s.files })}</span>
|
<code>{s.name}</code> <span className="hint">{s.path} · {t("skills.files", { n: s.files })}</span>
|
||||||
</span>
|
</span>
|
||||||
</label>
|
</Checkbox>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{error && <div className="notice err">{error}</div>}
|
{error && <div className="notice err">{error}</div>}
|
||||||
<div className="row" style={{ marginTop: 10, justifyContent: "flex-end", gap: 6 }}>
|
<div className="row" style={{ marginTop: 10, justifyContent: "flex-end", gap: 6 }}>
|
||||||
<button onClick={() => onClose(false)} disabled={busy}>
|
<Button onClick={() => onClose(false)} disabled={busy}>
|
||||||
{t("common.cancel")}
|
{t("common.cancel")}
|
||||||
</button>
|
</Button>
|
||||||
<button className="primary" onClick={() => void run()} disabled={busy || picked.size === 0}>
|
<Button type="primary" onClick={() => void run()} disabled={busy || picked.size === 0}>
|
||||||
{busy && found ? <Spinner small /> : <Icon name="check" />} {t("skills.importN", { n: picked.size })}
|
{busy && found ? <Spinner small /> : <Icon name="check" />} {t("skills.importN", { n: picked.size })}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
</Modal>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { Button, Input } from "antd";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { get, put } from "../../api";
|
import { get, put } from "../../api";
|
||||||
import { useT } from "../../i18n";
|
import { useT } from "../../i18n";
|
||||||
@@ -39,22 +40,22 @@ export function Snippets() {
|
|||||||
<div key={s.id ?? i} className="snippet-row">
|
<div key={s.id ?? i} className="snippet-row">
|
||||||
<div className="row">
|
<div className="row">
|
||||||
<span className="snippet-slash">/</span>
|
<span className="snippet-slash">/</span>
|
||||||
<input value={s.name} placeholder={t("snippets.name")} maxLength={40} onChange={(e) => set(i, { name: e.target.value })} aria-label={t("snippets.name")} />
|
<Input value={s.name} placeholder={t("snippets.name")} maxLength={40} onChange={(e) => set(i, { name: e.target.value })} aria-label={t("snippets.name")} />
|
||||||
<button title={t("common.delete")} aria-label={t("common.delete")} onClick={() => setItems(items.filter((_, j) => j !== i))}>
|
<Button title={t("common.delete")} aria-label={t("common.delete")} onClick={() => setItems(items.filter((_, j) => j !== i))}>
|
||||||
<Icon name="trash" />
|
<Icon name="trash" />
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<textarea rows={2} value={s.text} placeholder={t("snippets.text")} onChange={(e) => set(i, { text: e.target.value })} aria-label={t("snippets.text")} />
|
<Input.TextArea rows={2} value={s.text} placeholder={t("snippets.text")} onChange={(e) => set(i, { text: e.target.value })} aria-label={t("snippets.text")} />
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
<div className="row" style={{ marginTop: 8 }}>
|
<div className="row" style={{ marginTop: 8 }}>
|
||||||
<button onClick={() => setItems([...items, { name: "", text: "" }])}>
|
<Button onClick={() => setItems([...items, { name: "", text: "" }])}>
|
||||||
<Icon name="plus" /> {t("snippets.add")}
|
<Icon name="plus" /> {t("snippets.add")}
|
||||||
</button>
|
</Button>
|
||||||
<span className="grow" />
|
<span className="grow" />
|
||||||
<button className="primary" onClick={save}>
|
<Button type="primary" onClick={save}>
|
||||||
{t("common.save")}
|
{t("common.save")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { Button, Checkbox, Input } from "antd";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { del, get, post } from "../../api";
|
import { del, get, post } from "../../api";
|
||||||
import { useT } from "../../i18n";
|
import { useT } from "../../i18n";
|
||||||
@@ -58,11 +59,10 @@ export function SshKeys() {
|
|||||||
<b>{k.name}</b>
|
<b>{k.name}</b>
|
||||||
<span className="hint mono">{k.fingerprint}</span>
|
<span className="hint mono">{k.fingerprint}</span>
|
||||||
<span className="spacer" />
|
<span className="spacer" />
|
||||||
<button className="small" onClick={() => copy(k.public)}>
|
<Button size="small" onClick={() => copy(k.public)}>
|
||||||
<Icon name="copy" /> {t("ssh.copyPublic")}
|
<Icon name="copy" /> {t("ssh.copyPublic")}
|
||||||
</button>
|
</Button>
|
||||||
<button
|
<Button size="small"
|
||||||
className="small"
|
|
||||||
title={t("common.delete")}
|
title={t("common.delete")}
|
||||||
aria-label={t("common.delete")}
|
aria-label={t("common.delete")}
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
@@ -72,24 +72,23 @@ export function SshKeys() {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Icon name="trash" />
|
<Icon name="trash" />
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<input readOnly value={k.public} onFocus={(e) => e.currentTarget.select()} aria-label={t("ssh.public")} className="mono" />
|
<Input readOnly value={k.public} onFocus={(e) => e.currentTarget.select()} aria-label={t("ssh.public")} className="mono" />
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
<div className="row" style={{ marginTop: 10, flexWrap: "wrap" }}>
|
<div className="row" style={{ marginTop: 10, flexWrap: "wrap" }}>
|
||||||
<input value={name} onChange={(e) => setName(e.target.value)} placeholder={t("ssh.name")} maxLength={60} aria-label={t("ssh.name")} style={{ flex: "1 1 160px" }} />
|
<Input value={name} onChange={(e) => setName(e.target.value)} placeholder={t("ssh.name")} maxLength={60} aria-label={t("ssh.name")} style={{ flex: "1 1 160px" }} />
|
||||||
<button className="primary" disabled={busy || !name.trim() || (importing && !priv.trim())} onClick={add}>
|
<Button type="primary" disabled={busy || !name.trim() || (importing && !priv.trim())} onClick={add}>
|
||||||
{importing ? t("ssh.import") : t("ssh.generate")}
|
{importing ? t("ssh.import") : t("ssh.generate")}
|
||||||
</button>
|
</Button>
|
||||||
<label className="row" style={{ gap: 6 }}>
|
<Checkbox className="row" style={{ gap: 6 }} checked={importing} onChange={(e) => setImporting(e.target.checked)}>
|
||||||
<input type="checkbox" checked={importing} onChange={(e) => setImporting(e.target.checked)} />
|
|
||||||
{t("ssh.importExisting")}
|
{t("ssh.importExisting")}
|
||||||
</label>
|
</Checkbox>
|
||||||
</div>
|
</div>
|
||||||
{importing && (
|
{importing && (
|
||||||
<>
|
<>
|
||||||
<textarea rows={5} className="mono" value={priv} onChange={(e) => setPriv(e.target.value)} placeholder="-----BEGIN OPENSSH PRIVATE KEY-----" aria-label={t("ssh.private")} style={{ width: "100%", marginTop: 8 }} spellCheck={false} autoComplete="off" />
|
<Input.TextArea rows={5} className="mono" value={priv} onChange={(e) => setPriv(e.target.value)} placeholder="-----BEGIN OPENSSH PRIVATE KEY-----" aria-label={t("ssh.private")} style={{ width: "100%", marginTop: 8 }} spellCheck={false} autoComplete="off" />
|
||||||
<div className="hint">{t("ssh.importHint")}</div>
|
<div className="hint">{t("ssh.importHint")}</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { Button, Checkbox, Input } from "antd";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { del, put } from "../../api";
|
import { del, put } from "../../api";
|
||||||
import { confirmDialog, toast } from "../../dialogs";
|
import { confirmDialog, toast } from "../../dialogs";
|
||||||
@@ -59,9 +60,9 @@ export function Telegram() {
|
|||||||
<Icon name="share" /> {t("telegram.title")}
|
<Icon name="share" /> {t("telegram.title")}
|
||||||
<span className="spacer" />
|
<span className="spacer" />
|
||||||
{data?.configured && (
|
{data?.configured && (
|
||||||
<button className="small ghost danger" onClick={disconnect}>
|
<Button type="text" danger size="small" onClick={disconnect}>
|
||||||
{t("telegram.disconnect")}
|
{t("telegram.disconnect")}
|
||||||
</button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</h3>
|
</h3>
|
||||||
<div className="hint" style={{ marginBottom: 10 }}>
|
<div className="hint" style={{ marginBottom: 10 }}>
|
||||||
@@ -74,7 +75,7 @@ export function Telegram() {
|
|||||||
<li>{t("telegram.step2")}</li>
|
<li>{t("telegram.step2")}</li>
|
||||||
</ol>
|
</ol>
|
||||||
<div className="row" style={{ gap: 6 }}>
|
<div className="row" style={{ gap: 6 }}>
|
||||||
<input
|
<Input
|
||||||
type="text"
|
type="text"
|
||||||
name="telegram-bot-token"
|
name="telegram-bot-token"
|
||||||
value={token}
|
value={token}
|
||||||
@@ -85,9 +86,9 @@ export function Telegram() {
|
|||||||
onChange={(e) => setToken(e.target.value)}
|
onChange={(e) => setToken(e.target.value)}
|
||||||
style={{ flex: 1 }}
|
style={{ flex: 1 }}
|
||||||
/>
|
/>
|
||||||
<button className="primary" onClick={() => void connect()} disabled={busy || !token.trim()}>
|
<Button type="primary" onClick={() => void connect()} disabled={busy || !token.trim()}>
|
||||||
{busy ? t("telegram.checking") : t("telegram.connect")}
|
{busy ? t("telegram.checking") : t("telegram.connect")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
@@ -112,18 +113,16 @@ export function Telegram() {
|
|||||||
{data.error && <div className="notice err" style={{ marginTop: 10 }}>{data.error}</div>}
|
{data.error && <div className="notice err" style={{ marginTop: 10 }}>{data.error}</div>}
|
||||||
{data.paired && <div className="hint" style={{ marginTop: 10 }}>{t("telegram.commands")}</div>}
|
{data.paired && <div className="hint" style={{ marginTop: 10 }}>{t("telegram.commands")}</div>}
|
||||||
<h4 style={{ margin: "16px 0 6px" }}>{t("telegram.notify")}</h4>
|
<h4 style={{ margin: "16px 0 6px" }}>{t("telegram.notify")}</h4>
|
||||||
<label className="row" style={{ gap: 8, alignItems: "center" }}>
|
<Checkbox className="row" style={{ gap: 8, alignItems: "center" }} checked={data.factory_alerts} onChange={(e) => void savePrefs({ factory_alerts: e.target.checked })}>
|
||||||
<input type="checkbox" checked={data.factory_alerts} onChange={(e) => void savePrefs({ factory_alerts: e.target.checked })} />
|
|
||||||
<span>{t("telegram.factoryAlerts")}</span>
|
<span>{t("telegram.factoryAlerts")}</span>
|
||||||
</label>
|
</Checkbox>
|
||||||
<label className="row" style={{ gap: 8, alignItems: "center", marginTop: 6 }}>
|
<Checkbox className="row" style={{ gap: 8, alignItems: "center", marginTop: 6 }} checked={data.quiet} onChange={(e) => void savePrefs({ quiet: e.target.checked })}>
|
||||||
<input type="checkbox" checked={data.quiet} onChange={(e) => void savePrefs({ quiet: e.target.checked })} />
|
|
||||||
<span>{t("telegram.quiet")}</span>
|
<span>{t("telegram.quiet")}</span>
|
||||||
</label>
|
</Checkbox>
|
||||||
<div className="row" style={{ gap: 8, alignItems: "center", marginTop: 6, marginLeft: 24, flexWrap: "wrap", opacity: data.quiet ? 1 : 0.5 }}>
|
<div className="row" style={{ gap: 8, alignItems: "center", marginTop: 6, marginLeft: 24, flexWrap: "wrap", opacity: data.quiet ? 1 : 0.5 }}>
|
||||||
<input type="time" value={data.quiet_from} disabled={!data.quiet} onChange={(e) => e.target.value && void savePrefs({ quiet_from: e.target.value })} />
|
<Input type="time" value={data.quiet_from} disabled={!data.quiet} onChange={(e) => e.target.value && void savePrefs({ quiet_from: e.target.value })} />
|
||||||
<span>–</span>
|
<span>–</span>
|
||||||
<input type="time" value={data.quiet_to} disabled={!data.quiet} onChange={(e) => e.target.value && void savePrefs({ quiet_to: e.target.value })} />
|
<Input type="time" value={data.quiet_to} disabled={!data.quiet} onChange={(e) => e.target.value && void savePrefs({ quiet_to: e.target.value })} />
|
||||||
<span className="hint">{t("telegram.serverTime", { time: data.server_time })}{data.quiet_now ? ` · ${t("telegram.quietNow")}` : ""}</span>
|
<span className="hint">{t("telegram.serverTime", { time: data.server_time })}{data.quiet_now ? ` · ${t("telegram.quietNow")}` : ""}</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="hint" style={{ marginTop: 6 }}>{t("telegram.quietHint")}</div>
|
<div className="hint" style={{ marginTop: 6 }}>{t("telegram.quietHint")}</div>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { Button, Input } from "antd";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { confirmDialog, toast } from "../../dialogs";
|
import { confirmDialog, toast } from "../../dialogs";
|
||||||
import { useT } from "../../i18n";
|
import { useT } from "../../i18n";
|
||||||
@@ -33,12 +34,12 @@ function List({ scope, initial }: { scope: "personal" | "global"; initial: Templ
|
|||||||
{list.map((x, i) => (
|
{list.map((x, i) => (
|
||||||
<div key={x.id || `new${i}`} className="tpl-edit">
|
<div key={x.id || `new${i}`} className="tpl-edit">
|
||||||
<div className="row">
|
<div className="row">
|
||||||
<input className="grow" value={x.name} placeholder={t("templates.name")} onChange={(e) => set(i, { name: e.target.value })} />
|
<Input className="grow" value={x.name} placeholder={t("templates.name")} onChange={(e) => set(i, { name: e.target.value })} />
|
||||||
<button className="ghost small" onClick={() => remove(i)} aria-label={t("common.delete")}>
|
<Button type="text" size="small" onClick={() => remove(i)} aria-label={t("common.delete")}>
|
||||||
<Icon name="trash" />
|
<Icon name="trash" />
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<textarea rows={4} value={x.text} placeholder={t("templates.textPlaceholder")} onChange={(e) => set(i, { text: e.target.value })} />
|
<Input.TextArea rows={4} value={x.text} placeholder={t("templates.textPlaceholder")} onChange={(e) => set(i, { text: e.target.value })} />
|
||||||
{placeholders(x.text).length > 0 && (
|
{placeholders(x.text).length > 0 && (
|
||||||
<div className="tpl-ph">
|
<div className="tpl-ph">
|
||||||
{placeholders(x.text).map((p) => (
|
{placeholders(x.text).map((p) => (
|
||||||
@@ -51,13 +52,13 @@ function List({ scope, initial }: { scope: "personal" | "global"; initial: Templ
|
|||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
<div className="row" style={{ marginTop: 8 }}>
|
<div className="row" style={{ marginTop: 8 }}>
|
||||||
<button onClick={() => (setList([...list, { id: "", name: "", text: "" }]), setDirty(true))}>
|
<Button onClick={() => (setList([...list, { id: "", name: "", text: "" }]), setDirty(true))}>
|
||||||
<Icon name="plus" /> {t("templates.add")}
|
<Icon name="plus" /> {t("templates.add")}
|
||||||
</button>
|
</Button>
|
||||||
<span className="grow" />
|
<span className="grow" />
|
||||||
<button className="primary" disabled={!dirty} onClick={save}>
|
<Button type="primary" disabled={!dirty} onClick={save}>
|
||||||
{t("common.save")}
|
{t("common.save")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { Button } from "antd";
|
||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
import { post } from "../../api";
|
import { post } from "../../api";
|
||||||
import { useFetch } from "../../hooks";
|
import { useFetch } from "../../hooks";
|
||||||
@@ -32,9 +33,9 @@ export function Tools() {
|
|||||||
<Spinner /> {t("tools.installing")}
|
<Spinner /> {t("tools.installing")}
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<button className="primary" onClick={() => post("/tools/ghidra/install").then(reload).catch((e) => toast(e.message))}>
|
<Button type="primary" onClick={() => post("/tools/ghidra/install").then(reload).catch((e) => toast(e.message))}>
|
||||||
{g?.installed ? t("tools.reinstall") : t("tools.install")}
|
{g?.installed ? t("tools.reinstall") : t("tools.install")}
|
||||||
</button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
{g?.log && <pre className="git-output" style={{ marginTop: 10 }}>{g.log}</pre>}
|
{g?.log && <pre className="git-output" style={{ marginTop: 10 }}>{g.log}</pre>}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { Button, Input } from "antd";
|
||||||
|
import { Select } from "../../ui/Select";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { del, patch, post } from "../../api";
|
import { del, patch, post } from "../../api";
|
||||||
import { useFetch } from "../../hooks";
|
import { useFetch } from "../../hooks";
|
||||||
@@ -54,17 +56,16 @@ export function Users() {
|
|||||||
</td>
|
</td>
|
||||||
<td>{u.display_name}</td>
|
<td>{u.display_name}</td>
|
||||||
<td>
|
<td>
|
||||||
<select value={u.role} onChange={(e) => run(() => patch(`/users/${u.id}`, { role: e.target.value }))}>
|
<Select value={u.role} onChange={(e) => run(() => patch(`/users/${u.id}`, { role: e.target.value }))}>
|
||||||
<option value="user">{t("users.roleUser")}</option>
|
<option value="user">{t("users.roleUser")}</option>
|
||||||
<option value="admin">{t("users.roleAdmin")}</option>
|
<option value="admin">{t("users.roleAdmin")}</option>
|
||||||
</select>
|
</Select>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{u.has_password && <span className="chip">{t("users.password")}</span>} {u.oidc && <span className="chip">SSO</span>}
|
{u.has_password && <span className="chip">{t("users.password")}</span>} {u.oidc && <span className="chip">SSO</span>}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<button
|
<Button type="text" size="small"
|
||||||
className="small ghost"
|
|
||||||
title={t("users.quotaHint")}
|
title={t("users.quotaHint")}
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
const v = await promptDialog({ message: t("users.quotaPrompt", { name: u.username }), defaultValue: u.monthly_quota != null ? String(u.monthly_quota) : "" });
|
const v = await promptDialog({ message: t("users.quotaPrompt", { name: u.username }), defaultValue: u.monthly_quota != null ? String(u.monthly_quota) : "" });
|
||||||
@@ -73,21 +74,21 @@ export function Users() {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{u.monthly_quota != null ? u.monthly_quota : "∞"}
|
{u.monthly_quota != null ? u.monthly_quota : "∞"}
|
||||||
</button>
|
</Button>
|
||||||
</td>
|
</td>
|
||||||
<td>{fmtDate(u.created_at, false)}</td>
|
<td>{fmtDate(u.created_at, false)}</td>
|
||||||
<td>
|
<td>
|
||||||
<div className="row" style={{ flexWrap: "nowrap" }}>
|
<div className="row" style={{ flexWrap: "nowrap" }}>
|
||||||
<button className="small" onClick={() => resetPassword(u)}>
|
<Button size="small" onClick={() => resetPassword(u)}>
|
||||||
{t("users.setPassword")}
|
{t("users.setPassword")}
|
||||||
</button>
|
</Button>
|
||||||
<button className="small" onClick={() => run(() => patch(`/users/${u.id}`, { disabled: !u.disabled }))}>
|
<Button size="small" onClick={() => run(() => patch(`/users/${u.id}`, { disabled: !u.disabled }))}>
|
||||||
{u.disabled ? t("users.enable") : t("users.disable")}
|
{u.disabled ? t("users.enable") : t("users.disable")}
|
||||||
</button>
|
</Button>
|
||||||
{u.id !== me?.id && (
|
{u.id !== me?.id && (
|
||||||
<button className="small danger" onClick={() => void confirmDialog({ message: t("users.deleteConfirm", { name: u.username }), danger: true, confirmLabel: t("common.delete") }).then((ok): unknown => ok && run(() => del(`/users/${u.id}`)))}>
|
<Button danger size="small" onClick={() => void confirmDialog({ message: t("users.deleteConfirm", { name: u.username }), danger: true, confirmLabel: t("common.delete") }).then((ok): unknown => ok && run(() => del(`/users/${u.id}`)))}>
|
||||||
{t("common.delete")}
|
{t("common.delete")}
|
||||||
</button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
@@ -100,21 +101,20 @@ export function Users() {
|
|||||||
<h3>{t("users.add")}</h3>
|
<h3>{t("users.add")}</h3>
|
||||||
<div className="form">
|
<div className="form">
|
||||||
<label>{t("users.username")}</label>
|
<label>{t("users.username")}</label>
|
||||||
<input value={form.username} onChange={(e) => setForm({ ...form, username: e.target.value })} autoCapitalize="none" />
|
<Input value={form.username} onChange={(e) => setForm({ ...form, username: e.target.value })} autoCapitalize="none" />
|
||||||
<div className="hint">{t("users.usernameHint")}</div>
|
<div className="hint">{t("users.usernameHint")}</div>
|
||||||
<label>{t("users.displayName")}</label>
|
<label>{t("users.displayName")}</label>
|
||||||
<input value={form.display_name} onChange={(e) => setForm({ ...form, display_name: e.target.value })} />
|
<Input value={form.display_name} onChange={(e) => setForm({ ...form, display_name: e.target.value })} />
|
||||||
<label>{t("users.password")}</label>
|
<label>{t("users.password")}</label>
|
||||||
<input type="password" value={form.password} onChange={(e) => setForm({ ...form, password: e.target.value })} autoComplete="new-password" />
|
<Input.Password value={form.password} onChange={(e) => setForm({ ...form, password: e.target.value })} autoComplete="new-password" />
|
||||||
<div className="hint">{t("users.passwordHint")}</div>
|
<div className="hint">{t("users.passwordHint")}</div>
|
||||||
<label>{t("users.role")}</label>
|
<label>{t("users.role")}</label>
|
||||||
<select value={form.role} onChange={(e) => setForm({ ...form, role: e.target.value })}>
|
<Select value={form.role} onChange={(e) => setForm({ ...form, role: e.target.value })}>
|
||||||
<option value="user">{t("users.roleUser")}</option>
|
<option value="user">{t("users.roleUser")}</option>
|
||||||
<option value="admin">{t("users.roleAdmin")}</option>
|
<option value="admin">{t("users.roleAdmin")}</option>
|
||||||
</select>
|
</Select>
|
||||||
</div>
|
</div>
|
||||||
<button
|
<Button type="primary"
|
||||||
className="primary"
|
|
||||||
style={{ marginTop: 12 }}
|
style={{ marginTop: 12 }}
|
||||||
disabled={!form.username.trim()}
|
disabled={!form.username.trim()}
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
@@ -125,7 +125,7 @@ export function Users() {
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
+ {t("common.add")}
|
+ {t("common.add")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
+47
-58
@@ -1,8 +1,9 @@
|
|||||||
|
import { App, Button, Input, type InputRef } from "antd";
|
||||||
import { UploadPanel } from "./components/UploadPanel";
|
import { UploadPanel } from "./components/UploadPanel";
|
||||||
import { Icon } from "./components/Icon";
|
|
||||||
// In-app dialogs and toasts instead of the browser's alert/confirm/prompt.
|
// In-app dialogs and toasts instead of the browser's alert/confirm/prompt.
|
||||||
import { useEffect, useRef, useState, useSyncExternalStore } from "react";
|
import { useEffect, useRef, useState, useSyncExternalStore } from "react";
|
||||||
import { t } from "./i18n";
|
import { t } from "./i18n";
|
||||||
|
import { Modal } from "./ui/Modal";
|
||||||
|
|
||||||
interface ConfirmOpts {
|
interface ConfirmOpts {
|
||||||
title?: string;
|
title?: string;
|
||||||
@@ -39,7 +40,9 @@ interface Toast {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let dialogs: Dialog[] = [];
|
let dialogs: Dialog[] = [];
|
||||||
let toasts: Toast[] = [];
|
/** Shows a notice; set by the DialogHost once it is mounted. */
|
||||||
|
let show: ((x: Toast) => void) | undefined;
|
||||||
|
const waiting: Toast[] = [];
|
||||||
let seq = 0;
|
let seq = 0;
|
||||||
const listeners = new Set<() => void>();
|
const listeners = new Set<() => void>();
|
||||||
const emit = () => listeners.forEach((l) => l());
|
const emit = () => listeners.forEach((l) => l());
|
||||||
@@ -71,13 +74,9 @@ export function promptDialog(opts: PromptOpts | string): Promise<string | null>
|
|||||||
|
|
||||||
export function toast(message: unknown, kind: Toast["kind"] = "error") {
|
export function toast(message: unknown, kind: Toast["kind"] = "error") {
|
||||||
const text = message instanceof Error ? message.message : typeof message === "string" ? message : String((message as any)?.message ?? message);
|
const text = message instanceof Error ? message.message : typeof message === "string" ? message : String((message as any)?.message ?? message);
|
||||||
const id = ++seq;
|
const x = { id: ++seq, message: text, kind };
|
||||||
toasts = [...toasts, { id, message: text, kind }];
|
if (show) show(x);
|
||||||
emit();
|
else waiting.push(x);
|
||||||
setTimeout(() => {
|
|
||||||
toasts = toasts.filter((x) => x.id !== id);
|
|
||||||
emit();
|
|
||||||
}, kind === "error" ? 7000 : 3500);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function close(d: Dialog, value: any) {
|
function close(d: Dialog, value: any) {
|
||||||
@@ -88,86 +87,76 @@ function close(d: Dialog, value: any) {
|
|||||||
|
|
||||||
function DialogView({ d }: { d: Dialog }) {
|
function DialogView({ d }: { d: Dialog }) {
|
||||||
const [value, setValue] = useState(d.kind === "prompt" ? d.defaultValue ?? "" : "");
|
const [value, setValue] = useState(d.kind === "prompt" ? d.defaultValue ?? "" : "");
|
||||||
const input = useRef<HTMLInputElement>(null);
|
const input = useRef<InputRef>(null);
|
||||||
const ok = useRef<HTMLButtonElement>(null);
|
const ok = useRef<HTMLButtonElement>(null);
|
||||||
const cancelValue = d.kind === "confirm" ? false : null;
|
const cancelValue = d.kind === "confirm" ? false : null;
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (d.kind === "prompt") {
|
// After the window has opened (it takes the focus itself first).
|
||||||
input.current?.focus();
|
const timer = setTimeout(() => (d.kind === "prompt" ? input.current?.focus({ cursor: "all" }) : ok.current?.focus()), 60);
|
||||||
input.current?.select();
|
return () => clearTimeout(timer);
|
||||||
} else ok.current?.focus();
|
|
||||||
const h = (e: KeyboardEvent) => e.key === "Escape" && close(d, cancelValue);
|
|
||||||
window.addEventListener("keydown", h);
|
|
||||||
return () => window.removeEventListener("keydown", h);
|
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, []);
|
}, []);
|
||||||
const submit = () => close(d, d.kind === "confirm" ? true : value);
|
const submit = () => close(d, d.kind === "confirm" ? true : value);
|
||||||
|
const field = {
|
||||||
|
ref: input,
|
||||||
|
value,
|
||||||
|
placeholder: d.kind === "prompt" ? d.placeholder : undefined,
|
||||||
|
onChange: (e: React.ChangeEvent<HTMLInputElement>) => setValue(e.target.value),
|
||||||
|
};
|
||||||
return (
|
return (
|
||||||
<div className="modal-backdrop" onClick={() => close(d, cancelValue)}>
|
<Modal onClose={() => close(d, cancelValue)} className="dialog">
|
||||||
<form
|
<form role={d.kind === "confirm" ? "alertdialog" : "dialog"} aria-label={d.title ?? d.message} onSubmit={(e) => (e.preventDefault(), submit())}>
|
||||||
className="modal dialog"
|
|
||||||
role={d.kind === "confirm" ? "alertdialog" : "dialog"}
|
|
||||||
aria-label={d.title ?? d.message}
|
|
||||||
onClick={(e) => e.stopPropagation()}
|
|
||||||
onSubmit={(e) => (e.preventDefault(), submit())}
|
|
||||||
>
|
|
||||||
{d.title && <h3>{d.title}</h3>}
|
{d.title && <h3>{d.title}</h3>}
|
||||||
<p className="dialog-message">{d.message}</p>
|
<p className="dialog-message">{d.message}</p>
|
||||||
{d.kind === "prompt" && (
|
{d.kind === "prompt" && (d.password ? <Input.Password {...field} autoComplete="new-password" /> : <Input {...field} autoComplete="off" />)}
|
||||||
<input
|
|
||||||
ref={input}
|
|
||||||
type={d.password ? "password" : "text"}
|
|
||||||
value={value}
|
|
||||||
placeholder={d.placeholder}
|
|
||||||
onChange={(e) => setValue(e.target.value)}
|
|
||||||
autoComplete={d.password ? "new-password" : "off"}
|
|
||||||
style={{ width: "100%" }}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{d.kind === "choice" ? (
|
{d.kind === "choice" ? (
|
||||||
<div className="row dialog-actions dialog-choices">
|
<div className="row dialog-actions dialog-choices">
|
||||||
<button type="button" onClick={() => close(d, null)}>
|
<Button onClick={() => close(d, null)}>{t("common.cancel")}</Button>
|
||||||
{t("common.cancel")}
|
{d.choices.map((c, i) => {
|
||||||
</button>
|
const last = i === d.choices.length - 1;
|
||||||
{d.choices.map((c, i) => (
|
return (
|
||||||
<button key={c.value} ref={i === d.choices.length - 1 ? ok : undefined} type="button" className={c.danger ? "danger-solid" : i === d.choices.length - 1 ? "primary" : undefined} onClick={() => close(d, c.value)}>
|
<Button key={c.value} ref={last ? ok : undefined} type={c.danger || last ? "primary" : "default"} danger={c.danger} onClick={() => close(d, c.value)}>
|
||||||
{c.label}
|
{c.label}
|
||||||
</button>
|
</Button>
|
||||||
))}
|
);
|
||||||
|
})}
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="row dialog-actions">
|
<div className="row dialog-actions">
|
||||||
<button type="button" onClick={() => close(d, cancelValue)}>
|
<Button onClick={() => close(d, cancelValue)}>{t("common.cancel")}</Button>
|
||||||
{t("common.cancel")}
|
<Button ref={ok} htmlType="submit" type="primary" danger={d.kind === "confirm" && d.danger}>
|
||||||
</button>
|
|
||||||
<button ref={ok} type="submit" className={d.kind === "confirm" && d.danger ? "danger-solid" : "primary"}>
|
|
||||||
{d.confirmLabel ?? t("common.ok")}
|
{d.confirmLabel ?? t("common.ok")}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</Modal>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Renders open dialogs and toasts; mounted once in App. */
|
/** Renders open dialogs and toasts; mounted once in App. */
|
||||||
export function DialogHost() {
|
export function DialogHost() {
|
||||||
const state = useSyncExternalStore(subscribe, () => dialogs);
|
const state = useSyncExternalStore(subscribe, () => dialogs);
|
||||||
const ts = useSyncExternalStore(subscribe, () => toasts);
|
const { message } = App.useApp();
|
||||||
|
useEffect(() => {
|
||||||
|
show = (x) =>
|
||||||
|
void message.open({
|
||||||
|
key: x.id,
|
||||||
|
type: x.kind,
|
||||||
|
// A click dismisses the notice.
|
||||||
|
content: <span onClick={() => message.destroy(x.id)}>{x.message}</span>,
|
||||||
|
duration: x.kind === "error" ? 7 : 3.5,
|
||||||
|
});
|
||||||
|
// Notices raised before the host was there.
|
||||||
|
waiting.splice(0).forEach(show);
|
||||||
|
return () => void (show = undefined);
|
||||||
|
}, [message]);
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{state.map((d) => (
|
{state.map((d) => (
|
||||||
<DialogView key={d.id} d={d} />
|
<DialogView key={d.id} d={d} />
|
||||||
))}
|
))}
|
||||||
<UploadPanel />
|
<UploadPanel />
|
||||||
<div className="toasts" role="status" aria-live="polite">
|
|
||||||
{ts.map((x) => (
|
|
||||||
<div key={x.id} className={`toast ${x.kind}`} onClick={() => ((toasts = toasts.filter((y) => y.id !== x.id)), emit())}>
|
|
||||||
{x.kind === "error" ? <Icon name="warning" /> : x.kind === "success" ? <Icon name="check" /> : null}
|
|
||||||
{x.message}
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
+5
-3
@@ -69,9 +69,11 @@ export const de: Messages = {
|
|||||||
"settings.pricesFetched": "Preise für {n} Modelle aktualisiert – zum Übernehmen speichern.",
|
"settings.pricesFetched": "Preise für {n} Modelle aktualisiert – zum Übernehmen speichern.",
|
||||||
"stats.perMillion": "pro 1 Mio. Tok.",
|
"stats.perMillion": "pro 1 Mio. Tok.",
|
||||||
"stats.perMillionHint": "Effektive Kosten pro Million Tokens (Input inkl. Cache + Output)",
|
"stats.perMillionHint": "Effektive Kosten pro Million Tokens (Input inkl. Cache + Output)",
|
||||||
"queue.pending": "{n} Nachricht(en) in der Warteschlange – werden beim nächsten Schritt übergeben",
|
"queue.pending": "{n} Nachricht(en) in der Warteschlange – werden beim nächsten Schritt übergeben (Enter im leeren Feld erzwingt sofort)",
|
||||||
"queue.stopped": "{n} Nachricht(en) in der Warteschlange",
|
"queue.stopped": "{n} Nachricht(en) in der Warteschlange",
|
||||||
"queue.sendNow": "Jetzt senden",
|
"queue.sendNow": "Jetzt senden",
|
||||||
|
"queue.force": "Jetzt erzwingen",
|
||||||
|
"queue.forceHint": "Unterbricht den laufenden Schritt, das Modell liest die Nachricht sofort (Enter im leeren Feld oder Strg+Enter)",
|
||||||
"queue.remove": "Aus der Warteschlange entfernen",
|
"queue.remove": "Aus der Warteschlange entfernen",
|
||||||
"queue.backgroundResult": "Ergebnis einer Hintergrundaufgabe",
|
"queue.backgroundResult": "Ergebnis einer Hintergrundaufgabe",
|
||||||
"permissionMode.auto": "Automatisch (fragt einmal, Sicheres läuft)",
|
"permissionMode.auto": "Automatisch (fragt einmal, Sicheres läuft)",
|
||||||
@@ -819,8 +821,8 @@ export const de: Messages = {
|
|||||||
"chat.delete": "Session löschen",
|
"chat.delete": "Session löschen",
|
||||||
"chat.deleteConfirm": "Diese Session inklusive Subagenten löschen? Die Statistik bleibt erhalten.",
|
"chat.deleteConfirm": "Diese Session inklusive Subagenten löschen? Die Statistik bleibt erhalten.",
|
||||||
|
|
||||||
"composer.placeholder": "Nachricht… (/ für Befehle, @ für Dateien, Dateien anhängen oder einfügen)",
|
"composer.placeholder": "Nachricht… (/ für Befehle, @ für Dateien, Shift+Enter oder Strg+J für neue Zeile)",
|
||||||
"composer.placeholderBusy": "Nachricht wird eingereiht und beim nächsten Schritt gesendet…",
|
"composer.placeholderBusy": "Nachricht wird eingereiht und beim nächsten Schritt gesendet… (Strg+Enter sendet sofort)",
|
||||||
"composer.send": "Senden",
|
"composer.send": "Senden",
|
||||||
"composer.queue": "Einreihen",
|
"composer.queue": "Einreihen",
|
||||||
"composer.stop": "Stopp",
|
"composer.stop": "Stopp",
|
||||||
|
|||||||
+5
-3
@@ -68,9 +68,11 @@ export const en = {
|
|||||||
"settings.pricesFetched": "Prices updated for {n} models – save to keep them.",
|
"settings.pricesFetched": "Prices updated for {n} models – save to keep them.",
|
||||||
"stats.perMillion": "per 1M tok",
|
"stats.perMillion": "per 1M tok",
|
||||||
"stats.perMillionHint": "Effective cost per million tokens (input incl. cache + output)",
|
"stats.perMillionHint": "Effective cost per million tokens (input incl. cache + output)",
|
||||||
"queue.pending": "{n} message(s) waiting – delivered at the agent's next step",
|
"queue.pending": "{n} message(s) waiting – delivered at the agent's next step (Enter on an empty field forces it now)",
|
||||||
"queue.stopped": "{n} message(s) waiting",
|
"queue.stopped": "{n} message(s) waiting",
|
||||||
"queue.sendNow": "Send now",
|
"queue.sendNow": "Send now",
|
||||||
|
"queue.force": "Force now",
|
||||||
|
"queue.forceHint": "Interrupts the running step so the model reads the message at once (Enter on an empty field or Ctrl+Enter)",
|
||||||
"queue.remove": "Remove from queue",
|
"queue.remove": "Remove from queue",
|
||||||
"queue.backgroundResult": "Result of a background task",
|
"queue.backgroundResult": "Result of a background task",
|
||||||
"permissionMode.auto": "Automatic (asks once, safe steps run)",
|
"permissionMode.auto": "Automatic (asks once, safe steps run)",
|
||||||
@@ -818,8 +820,8 @@ export const en = {
|
|||||||
"chat.delete": "Delete session",
|
"chat.delete": "Delete session",
|
||||||
"chat.deleteConfirm": "Delete this session including its subagents? Statistics are kept.",
|
"chat.deleteConfirm": "Delete this session including its subagents? Statistics are kept.",
|
||||||
|
|
||||||
"composer.placeholder": "Message… (/ for commands, @ for files, attach or paste files)",
|
"composer.placeholder": "Message… (/ for commands, @ for files, Shift+Enter or Ctrl+J for a new line)",
|
||||||
"composer.placeholderBusy": "Message is queued and sent at the next step…",
|
"composer.placeholderBusy": "Message is queued and sent at the next step… (Ctrl+Enter sends it now)",
|
||||||
"composer.send": "Send",
|
"composer.send": "Send",
|
||||||
"composer.queue": "Queue",
|
"composer.queue": "Queue",
|
||||||
"composer.stop": "Stop",
|
"composer.stop": "Stop",
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import "./styles.css";
|
|||||||
import { App } from "./App";
|
import { App } from "./App";
|
||||||
import { applyTheme } from "./theme";
|
import { applyTheme } from "./theme";
|
||||||
import { captureShare } from "./share";
|
import { captureShare } from "./share";
|
||||||
|
import { AntdProvider } from "./ui/AntdProvider";
|
||||||
|
|
||||||
applyTheme();
|
applyTheme();
|
||||||
captureShare();
|
captureShare();
|
||||||
@@ -50,6 +51,8 @@ function undoKeyboardShift() {
|
|||||||
|
|
||||||
createRoot(document.getElementById("root")!).render(
|
createRoot(document.getElementById("root")!).render(
|
||||||
<StrictMode>
|
<StrictMode>
|
||||||
|
<AntdProvider>
|
||||||
<App />
|
<App />
|
||||||
|
</AntdProvider>
|
||||||
</StrictMode>,
|
</StrictMode>,
|
||||||
);
|
);
|
||||||
+192
-148
@@ -31,61 +31,62 @@ pre,
|
|||||||
font-size: 12.5px;
|
font-size: 12.5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
button,
|
/* Plain elements (custom-shaped buttons, the message field); Ant Design components bring their own style. */
|
||||||
input,
|
button:where(:not([class*="ant-"])),
|
||||||
select,
|
input:where(:not([class*="ant-"])),
|
||||||
textarea {
|
select:where(:not([class*="ant-"])),
|
||||||
|
textarea:where(:not([class*="ant-"])) {
|
||||||
font: inherit;
|
font: inherit;
|
||||||
color: inherit;
|
color: inherit;
|
||||||
}
|
}
|
||||||
|
|
||||||
button {
|
button:where(:not([class*="ant-"])) {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
border: 1px solid var(--bg3);
|
border: 1px solid var(--bg3);
|
||||||
background: var(--bg2);
|
background: var(--bg2);
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
padding: 5px 12px;
|
padding: 5px 12px;
|
||||||
}
|
}
|
||||||
button:hover:not(:disabled) {
|
button:where(:not([class*="ant-"])):hover:not(:disabled) {
|
||||||
border-color: var(--fg3);
|
border-color: var(--fg3);
|
||||||
}
|
}
|
||||||
button:disabled {
|
button:where(:not([class*="ant-"])):disabled {
|
||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
cursor: default;
|
cursor: default;
|
||||||
}
|
}
|
||||||
button.primary {
|
button:where(:not([class*="ant-"])).primary {
|
||||||
background: var(--accent);
|
background: var(--accent);
|
||||||
border-color: var(--accent);
|
border-color: var(--accent);
|
||||||
color: var(--on-accent);
|
color: var(--on-accent);
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
button.danger {
|
button:where(:not([class*="ant-"])).danger {
|
||||||
color: var(--red);
|
color: var(--red);
|
||||||
}
|
}
|
||||||
button.ghost {
|
button:where(:not([class*="ant-"])).ghost {
|
||||||
background: transparent;
|
background: transparent;
|
||||||
border-color: transparent;
|
border-color: transparent;
|
||||||
}
|
}
|
||||||
button.ghost:hover:not(:disabled) {
|
button:where(:not([class*="ant-"])).ghost:hover:not(:disabled) {
|
||||||
background: var(--bg2);
|
background: var(--bg2);
|
||||||
}
|
}
|
||||||
button.small {
|
button:where(:not([class*="ant-"])).small {
|
||||||
padding: 2px 8px;
|
padding: 2px 8px;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
input,
|
input:where(:not([class*="ant-"])),
|
||||||
select,
|
select:where(:not([class*="ant-"])),
|
||||||
textarea {
|
textarea:where(:not([class*="ant-"])) {
|
||||||
background: var(--bg1);
|
background: var(--bg1);
|
||||||
border: 1px solid var(--bg3);
|
border: 1px solid var(--bg3);
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
padding: 5px 8px;
|
padding: 5px 8px;
|
||||||
outline: none;
|
outline: none;
|
||||||
}
|
}
|
||||||
input:focus,
|
input:where(:not([class*="ant-"])):focus,
|
||||||
select:focus,
|
select:where(:not([class*="ant-"])):focus,
|
||||||
textarea:focus {
|
textarea:where(:not([class*="ant-"])):focus {
|
||||||
border-color: var(--accent);
|
border-color: var(--accent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -993,10 +994,9 @@ button.session-group:hover {
|
|||||||
margin-top: 6px;
|
margin-top: 6px;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
}
|
}
|
||||||
.composer-bar select {
|
.composer-bar .ant-select {
|
||||||
max-width: 220px;
|
max-width: 240px;
|
||||||
font-size: 12.5px;
|
min-width: 0;
|
||||||
padding: 3px 6px;
|
|
||||||
}
|
}
|
||||||
.composer-options {
|
.composer-options {
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -1022,24 +1022,6 @@ button.session-group:hover {
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
.mode-tabs {
|
|
||||||
display: inline-flex;
|
|
||||||
border: 1px solid var(--bg3);
|
|
||||||
border-radius: 6px;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
.mode-tabs button {
|
|
||||||
border: none;
|
|
||||||
border-radius: 0;
|
|
||||||
background: transparent;
|
|
||||||
padding: 3px 10px;
|
|
||||||
font-size: 12.5px;
|
|
||||||
}
|
|
||||||
.mode-tabs button.active {
|
|
||||||
background: var(--accent);
|
|
||||||
color: var(--on-accent);
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
.attachments {
|
.attachments {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 6px;
|
gap: 6px;
|
||||||
@@ -1128,17 +1110,6 @@ button.session-group:hover {
|
|||||||
margin-bottom: 16px;
|
margin-bottom: 16px;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
}
|
}
|
||||||
.tabs button {
|
|
||||||
border: none;
|
|
||||||
border-bottom: 2px solid transparent;
|
|
||||||
border-radius: 0;
|
|
||||||
background: transparent;
|
|
||||||
padding: 8px 12px;
|
|
||||||
}
|
|
||||||
.tabs button.active {
|
|
||||||
border-bottom-color: var(--accent);
|
|
||||||
color: var(--fg0);
|
|
||||||
}
|
|
||||||
|
|
||||||
.form {
|
.form {
|
||||||
display: grid;
|
display: grid;
|
||||||
@@ -1455,8 +1426,8 @@ table.grid input[type="number"] {
|
|||||||
.menu-pop-body .mobile-only {
|
.menu-pop-body .mobile-only {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
.topbar button.small {
|
.topbar .ant-btn-sm {
|
||||||
padding: 2px 5px;
|
padding-inline: 5px;
|
||||||
}
|
}
|
||||||
/* One scrollable row of options, actions stay visible. */
|
/* One scrollable row of options, actions stay visible. */
|
||||||
.composer-bar {
|
.composer-bar {
|
||||||
@@ -1470,7 +1441,8 @@ table.grid input[type="number"] {
|
|||||||
.composer-options::-webkit-scrollbar {
|
.composer-options::-webkit-scrollbar {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
.composer-options select {
|
.composer-options .ant-select {
|
||||||
|
flex: none;
|
||||||
max-width: 150px;
|
max-width: 150px;
|
||||||
}
|
}
|
||||||
/* Avoid iOS zoom on focus. */
|
/* Avoid iOS zoom on focus. */
|
||||||
@@ -2115,7 +2087,7 @@ button.entry {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
}
|
}
|
||||||
.git-branch select {
|
.git-branch .ant-select {
|
||||||
max-width: 160px;
|
max-width: 160px;
|
||||||
}
|
}
|
||||||
.git-output {
|
.git-output {
|
||||||
@@ -2400,9 +2372,6 @@ a.button.primary {
|
|||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mode-tabs button.active.deep {
|
|
||||||
background: var(--accent2);
|
|
||||||
}
|
|
||||||
|
|
||||||
.rewind-files {
|
.rewind-files {
|
||||||
max-height: 200px;
|
max-height: 200px;
|
||||||
@@ -2432,34 +2401,6 @@ button.danger-solid {
|
|||||||
color: var(--bg0);
|
color: var(--bg0);
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
.toasts {
|
|
||||||
position: fixed;
|
|
||||||
right: 16px;
|
|
||||||
bottom: 16px;
|
|
||||||
display: grid;
|
|
||||||
gap: 8px;
|
|
||||||
z-index: 50;
|
|
||||||
max-width: min(420px, calc(100vw - 32px));
|
|
||||||
padding-bottom: env(safe-area-inset-bottom);
|
|
||||||
}
|
|
||||||
.toast {
|
|
||||||
background: var(--bg1);
|
|
||||||
border: 1px solid var(--bg3);
|
|
||||||
border-left: 4px solid var(--blue);
|
|
||||||
border-radius: var(--radius);
|
|
||||||
padding: 10px 14px;
|
|
||||||
box-shadow: var(--shadow);
|
|
||||||
font-size: 13px;
|
|
||||||
cursor: pointer;
|
|
||||||
animation: toast-in 0.18s ease-out;
|
|
||||||
word-break: break-word;
|
|
||||||
}
|
|
||||||
.toast.error {
|
|
||||||
border-left-color: var(--red);
|
|
||||||
}
|
|
||||||
.toast.success {
|
|
||||||
border-left-color: var(--green);
|
|
||||||
}
|
|
||||||
@keyframes toast-in {
|
@keyframes toast-in {
|
||||||
from {
|
from {
|
||||||
transform: translateY(8px);
|
transform: translateY(8px);
|
||||||
@@ -2479,18 +2420,6 @@ button.danger-solid {
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.segmented {
|
|
||||||
display: inline-flex;
|
|
||||||
gap: 2px;
|
|
||||||
background: var(--bg1);
|
|
||||||
border-radius: 8px;
|
|
||||||
padding: 2px;
|
|
||||||
width: fit-content;
|
|
||||||
}
|
|
||||||
.segmented button.active {
|
|
||||||
background: var(--accent);
|
|
||||||
color: var(--on-accent);
|
|
||||||
}
|
|
||||||
.sidebar-user .theme-toggle {
|
.sidebar-user .theme-toggle {
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
@@ -2859,17 +2788,6 @@ button.danger-solid {
|
|||||||
margin-top: 12px;
|
margin-top: 12px;
|
||||||
color: var(--fg2);
|
color: var(--fg2);
|
||||||
}
|
}
|
||||||
.chip-btn {
|
|
||||||
border: 1px solid var(--bg3);
|
|
||||||
border-radius: 8px;
|
|
||||||
background: var(--bg0);
|
|
||||||
color: var(--fg1);
|
|
||||||
padding: 6px 12px;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
.chip-btn:hover {
|
|
||||||
border-color: var(--accent);
|
|
||||||
}
|
|
||||||
.wiz-foot {
|
.wiz-foot {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@@ -3322,10 +3240,8 @@ button.danger-solid {
|
|||||||
.job-grid > span:nth-child(odd) {
|
.job-grid > span:nth-child(odd) {
|
||||||
color: var(--fg3);
|
color: var(--fg3);
|
||||||
}
|
}
|
||||||
.job-grid select {
|
.job-grid .ant-select {
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
font-size: 13px;
|
|
||||||
padding: 2px 6px;
|
|
||||||
}
|
}
|
||||||
.job-prompt {
|
.job-prompt {
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
@@ -3765,10 +3681,6 @@ button.danger-solid {
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
resize: vertical;
|
resize: vertical;
|
||||||
}
|
}
|
||||||
.chip-btn.active {
|
|
||||||
border-color: var(--accent);
|
|
||||||
color: var(--accent);
|
|
||||||
}
|
|
||||||
.job-tpl-card.active {
|
.job-tpl-card.active {
|
||||||
outline: 2px solid var(--accent);
|
outline: 2px solid var(--accent);
|
||||||
outline-offset: -2px;
|
outline-offset: -2px;
|
||||||
@@ -3788,19 +3700,6 @@ button.danger-solid {
|
|||||||
display: none;
|
display: none;
|
||||||
border-bottom: 1px solid var(--bg2);
|
border-bottom: 1px solid var(--bg2);
|
||||||
}
|
}
|
||||||
.job-tabs button {
|
|
||||||
flex: 1;
|
|
||||||
border: none;
|
|
||||||
border-radius: 0;
|
|
||||||
background: transparent;
|
|
||||||
padding: 8px 6px;
|
|
||||||
color: var(--muted);
|
|
||||||
border-bottom: 2px solid transparent;
|
|
||||||
}
|
|
||||||
.job-tabs button.active {
|
|
||||||
color: var(--fg0);
|
|
||||||
border-bottom-color: var(--accent);
|
|
||||||
}
|
|
||||||
.job-editor {
|
.job-editor {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-height: 0;
|
min-height: 0;
|
||||||
@@ -3832,7 +3731,7 @@ button.danger-solid {
|
|||||||
min-width: 150px;
|
min-width: 150px;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
.job-editor-row select,
|
.job-editor-row .ant-select,
|
||||||
.job-editor-row input {
|
.job-editor-row input {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
@@ -3931,14 +3830,6 @@ button.danger-solid {
|
|||||||
gap: 6px;
|
gap: 6px;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
.cron-modes .chip-btn,
|
|
||||||
.cron-days .chip-btn {
|
|
||||||
padding: 4px 10px;
|
|
||||||
font-size: 13px;
|
|
||||||
}
|
|
||||||
.cron-days .chip-btn {
|
|
||||||
min-width: 44px;
|
|
||||||
}
|
|
||||||
.cron-fields {
|
.cron-fields {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
@@ -4196,7 +4087,7 @@ span.chat-tab > button {
|
|||||||
padding-top: max(4px, env(safe-area-inset-top));
|
padding-top: max(4px, env(safe-area-inset-top));
|
||||||
gap: 4px;
|
gap: 4px;
|
||||||
}
|
}
|
||||||
.topbar button.ghost {
|
.topbar .ant-btn {
|
||||||
padding: 4px 6px;
|
padding: 4px 6px;
|
||||||
}
|
}
|
||||||
.chat {
|
.chat {
|
||||||
@@ -4224,9 +4115,8 @@ span.chat-tab > button {
|
|||||||
margin-top: 4px;
|
margin-top: 4px;
|
||||||
gap: 4px;
|
gap: 4px;
|
||||||
}
|
}
|
||||||
.composer-bar select {
|
.composer-bar .ant-select {
|
||||||
max-width: 150px;
|
max-width: 124px;
|
||||||
padding: 2px 4px;
|
|
||||||
}
|
}
|
||||||
.composer-actions button {
|
.composer-actions button {
|
||||||
padding: 4px 10px;
|
padding: 4px 10px;
|
||||||
@@ -4403,10 +4293,6 @@ span.chat-tab > button {
|
|||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
}
|
}
|
||||||
.media-filters .chip-btn {
|
|
||||||
padding: 3px 10px;
|
|
||||||
font-size: 13px;
|
|
||||||
}
|
|
||||||
.media-filters small {
|
.media-filters small {
|
||||||
color: var(--muted);
|
color: var(--muted);
|
||||||
margin-left: 2px;
|
margin-left: 2px;
|
||||||
@@ -5085,12 +4971,26 @@ td.fold-indent {
|
|||||||
border-radius: var(--radius);
|
border-radius: var(--radius);
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
min-height: 120px;
|
min-height: 120px;
|
||||||
|
/* Each column scrolls on its own; the board as a whole stays about one screen high. */
|
||||||
|
max-height: max(360px, calc(100dvh - 140px));
|
||||||
|
overflow-y: auto;
|
||||||
|
overscroll-behavior: contain;
|
||||||
|
scrollbar-width: thin;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 6px;
|
gap: 6px;
|
||||||
}
|
}
|
||||||
|
.factory-col > * {
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
.factory-col h4 {
|
.factory-col h4 {
|
||||||
margin: 0 0 2px;
|
/* The column title stays visible while its cards scroll. */
|
||||||
|
position: sticky;
|
||||||
|
top: -8px;
|
||||||
|
z-index: 1;
|
||||||
|
background: var(--bg1);
|
||||||
|
margin: -8px 0 -4px;
|
||||||
|
padding: 8px 0 6px;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
@@ -5458,7 +5358,7 @@ td.fold-indent {
|
|||||||
position: fixed;
|
position: fixed;
|
||||||
left: 16px;
|
left: 16px;
|
||||||
bottom: 16px;
|
bottom: 16px;
|
||||||
z-index: 55;
|
z-index: 160;
|
||||||
display: grid;
|
display: grid;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
width: min(380px, calc(100vw - 32px));
|
width: min(380px, calc(100vw - 32px));
|
||||||
@@ -5529,3 +5429,147 @@ td.fold-indent {
|
|||||||
.upload-file.error .upload-bar i {
|
.upload-file.error .upload-bar i {
|
||||||
background: var(--red, #e5484d);
|
background: var(--red, #e5484d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --- Ant Design ------------------------------------------------------------- */
|
||||||
|
/* The dialog window is drawn by Ant Design; `.modal` only lays out its content. */
|
||||||
|
.ant-modal .modal {
|
||||||
|
background: none;
|
||||||
|
border: 0;
|
||||||
|
border-radius: 0;
|
||||||
|
box-shadow: none;
|
||||||
|
padding: 0;
|
||||||
|
width: auto;
|
||||||
|
max-height: calc(100dvh - 96px);
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
.ant-modal .modal.wide {
|
||||||
|
max-height: calc(100dvh - 64px);
|
||||||
|
}
|
||||||
|
.ant-modal .modal > h3:first-child,
|
||||||
|
.ant-modal .modal > form > h3:first-child {
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
|
/* Buttons with an icon and a label keep the app's spacing; long labels may wrap. */
|
||||||
|
.ant-btn > svg + span,
|
||||||
|
.ant-btn > span + svg {
|
||||||
|
margin-inline-start: 0;
|
||||||
|
}
|
||||||
|
.dialog-actions .ant-btn,
|
||||||
|
.dialog-choices .ant-btn {
|
||||||
|
height: auto;
|
||||||
|
min-height: 32px;
|
||||||
|
white-space: normal;
|
||||||
|
}
|
||||||
|
/* Fields fill their form column like before; in a row they share the space. */
|
||||||
|
.form .ant-input,
|
||||||
|
.field .ant-input,
|
||||||
|
.modal label > .ant-input,
|
||||||
|
.modal label > .ant-input-password {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.row > .ant-input,
|
||||||
|
.row > .ant-input-password {
|
||||||
|
width: auto;
|
||||||
|
}
|
||||||
|
.ant-checkbox-wrapper {
|
||||||
|
align-items: flex-start;
|
||||||
|
}
|
||||||
|
/* Touch screens: comfortable targets. */
|
||||||
|
@media (pointer: coarse) {
|
||||||
|
.ant-btn-sm {
|
||||||
|
min-height: 32px;
|
||||||
|
}
|
||||||
|
.ant-input,
|
||||||
|
.ant-select {
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.settings-tabs .tab-label {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
.seg-wrap {
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
|
.seg-wrap .ant-segmented-group {
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
.ant-segmented {
|
||||||
|
width: fit-content;
|
||||||
|
}
|
||||||
|
.ant-segmented.ant-segmented-block {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.ant-segmented-item-selected {
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
/* A toggled or current plain button (navigation, filters). */
|
||||||
|
.ant-btn.active {
|
||||||
|
background: var(--bg3);
|
||||||
|
color: var(--fg0);
|
||||||
|
}
|
||||||
|
.cron-days .ant-btn {
|
||||||
|
min-width: 44px;
|
||||||
|
}
|
||||||
|
.sidebar-foot .ant-btn {
|
||||||
|
flex: 1;
|
||||||
|
justify-content: flex-start;
|
||||||
|
}
|
||||||
|
/* Icons next to a label: the component already spaces them. */
|
||||||
|
.ant-btn .nav-icon,
|
||||||
|
.settings-tabs .nav-icon {
|
||||||
|
margin-right: 0;
|
||||||
|
}
|
||||||
|
.sidebar-foot .ant-btn {
|
||||||
|
min-width: 0;
|
||||||
|
padding-inline: 10px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
/* All settings sections stay visible: the tab bar wraps instead of hiding tabs in a menu. */
|
||||||
|
.settings-tabs .ant-tabs-nav-wrap {
|
||||||
|
overflow: visible;
|
||||||
|
}
|
||||||
|
.settings-tabs .ant-tabs-nav-list {
|
||||||
|
flex-wrap: wrap;
|
||||||
|
transform: none !important;
|
||||||
|
}
|
||||||
|
.settings-tabs .ant-tabs-nav-operations,
|
||||||
|
.settings-tabs .ant-tabs-ink-bar {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.settings-tabs .ant-tabs-tab {
|
||||||
|
border-bottom: 2px solid transparent;
|
||||||
|
padding-block: 8px;
|
||||||
|
margin-inline: 0 18px !important;
|
||||||
|
}
|
||||||
|
.settings-tabs .ant-tabs-tab-active {
|
||||||
|
border-bottom-color: var(--accent);
|
||||||
|
}
|
||||||
|
@media (max-width: 700px) {
|
||||||
|
.panel .row,
|
||||||
|
.card .row {
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* The app's own visibility classes also apply to Ant Design buttons. */
|
||||||
|
.ant-btn.mobile-only {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.ant-btn.git-name {
|
||||||
|
justify-content: flex-start;
|
||||||
|
}
|
||||||
|
@media (max-width: 800px) {
|
||||||
|
.ant-btn.mobile-only {
|
||||||
|
display: inline-flex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@media (max-width: 700px) {
|
||||||
|
.panel h3,
|
||||||
|
.card h3 {
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
.topbar.stats-bar {
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
// Ant Design setup: its tokens come from the app's theme variables (src/themes/*.css), so every theme applies to
|
||||||
|
// the components too; the language follows the app's language.
|
||||||
|
import { App as AntApp, ConfigProvider, theme as antTheme } from "antd";
|
||||||
|
import deDE from "antd/locale/de_DE";
|
||||||
|
import enUS from "antd/locale/en_US";
|
||||||
|
import { useMemo, useSyncExternalStore, type ReactNode } from "react";
|
||||||
|
import { onThemeChange } from "../theme";
|
||||||
|
import { getLang, onLangChange } from "../i18n";
|
||||||
|
|
||||||
|
/** Any CSS colour (hex, color-mix(), …) as the hex form Ant Design can calculate with. */
|
||||||
|
function resolver() {
|
||||||
|
const probe = document.createElement("span");
|
||||||
|
probe.style.display = "none";
|
||||||
|
document.body.appendChild(probe);
|
||||||
|
const ctx = document.createElement("canvas").getContext("2d", { willReadFrequently: true })!;
|
||||||
|
return {
|
||||||
|
color(name: string, fallback: string) {
|
||||||
|
probe.style.color = fallback;
|
||||||
|
probe.style.color = `var(${name}, ${fallback})`;
|
||||||
|
ctx.clearRect(0, 0, 1, 1);
|
||||||
|
ctx.fillStyle = getComputedStyle(probe).color;
|
||||||
|
ctx.fillRect(0, 0, 1, 1);
|
||||||
|
const [r, g, b] = ctx.getImageData(0, 0, 1, 1).data;
|
||||||
|
return `#${[r, g, b].map((v) => v.toString(16).padStart(2, "0")).join("")}`;
|
||||||
|
},
|
||||||
|
done: () => probe.remove(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function themeConfig() {
|
||||||
|
const root = document.documentElement;
|
||||||
|
const dark = root.dataset.mode !== "light";
|
||||||
|
const r = resolver();
|
||||||
|
const c = (name: string, fallback = "#888888") => r.color(name, fallback);
|
||||||
|
const [bg0, bg1, bg2, bg3] = [c("--bg0"), c("--bg1"), c("--bg2"), c("--bg3")];
|
||||||
|
const [fg0, fg1, fg2, fg3, muted] = [c("--fg0"), c("--fg1"), c("--fg2"), c("--fg3"), c("--muted")];
|
||||||
|
const [accent, onAccent, red, green, blue, warn] = [c("--accent"), c("--on-accent"), c("--red"), c("--green"), c("--blue"), c("--accent2")];
|
||||||
|
r.done();
|
||||||
|
const css = getComputedStyle(root);
|
||||||
|
return {
|
||||||
|
algorithm: dark ? antTheme.darkAlgorithm : antTheme.defaultAlgorithm,
|
||||||
|
token: {
|
||||||
|
colorPrimary: accent,
|
||||||
|
colorError: red,
|
||||||
|
colorSuccess: green,
|
||||||
|
colorWarning: warn,
|
||||||
|
colorInfo: blue,
|
||||||
|
colorLink: blue,
|
||||||
|
colorBgBase: bg0,
|
||||||
|
colorTextBase: fg1,
|
||||||
|
colorBgLayout: bg0,
|
||||||
|
colorBgContainer: bg1,
|
||||||
|
colorBgElevated: bg1,
|
||||||
|
colorBorder: bg3,
|
||||||
|
colorBorderSecondary: bg2,
|
||||||
|
colorText: fg1,
|
||||||
|
colorTextSecondary: fg2,
|
||||||
|
colorTextTertiary: fg3,
|
||||||
|
colorTextQuaternary: muted,
|
||||||
|
colorTextPlaceholder: muted,
|
||||||
|
colorTextHeading: fg0,
|
||||||
|
borderRadius: 6,
|
||||||
|
// Below the full-screen image viewer (200), above the app's own panels and menus.
|
||||||
|
zIndexPopupBase: 100,
|
||||||
|
fontSize: 14,
|
||||||
|
fontFamily: css.getPropertyValue("--font").trim() || "system-ui, sans-serif",
|
||||||
|
fontFamilyCode: css.getPropertyValue("--mono").trim() || "monospace",
|
||||||
|
},
|
||||||
|
components: {
|
||||||
|
Button: { primaryColor: onAccent, dangerColor: onAccent, defaultBg: bg2, defaultHoverBg: bg2, fontWeight: 500, primaryShadow: "none", defaultShadow: "none", dangerShadow: "none" },
|
||||||
|
Select: { optionSelectedBg: bg3 },
|
||||||
|
Modal: { contentBg: bg1, headerBg: bg1 },
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
let version = 0;
|
||||||
|
const subscribeTheme = (fn: () => void) => onThemeChange(() => (version++, fn()));
|
||||||
|
|
||||||
|
export function AntdProvider({ children }: { children: ReactNode }) {
|
||||||
|
const themeVersion = useSyncExternalStore(subscribeTheme, () => version);
|
||||||
|
const lang = useSyncExternalStore(onLangChange, getLang);
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
const theme = useMemo(themeConfig, [themeVersion]);
|
||||||
|
return (
|
||||||
|
<ConfigProvider theme={theme} locale={lang === "de" ? deDE : enUS} button={{ autoInsertSpace: false }}>
|
||||||
|
<AntApp component={false}>{children}</AntApp>
|
||||||
|
</ConfigProvider>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
// The app's dialog window: an Ant Design modal around the dialog's own content (heading, fields, action row).
|
||||||
|
import { Modal as AntModal } from "antd";
|
||||||
|
import type { HTMLAttributes, ReactNode } from "react";
|
||||||
|
|
||||||
|
interface Props extends Omit<HTMLAttributes<HTMLDivElement>, "onClick"> {
|
||||||
|
/** Escape and a click outside close the dialog; without it the dialog stays until its own buttons close it. */
|
||||||
|
onClose?: () => void;
|
||||||
|
/** Extra classes of the content ("wide" makes the window wider). */
|
||||||
|
className?: string;
|
||||||
|
children?: ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function Modal({ onClose, className = "", children, ...rest }: Props) {
|
||||||
|
const wide = /\bwide\b/.test(className);
|
||||||
|
return (
|
||||||
|
<AntModal
|
||||||
|
open
|
||||||
|
centered
|
||||||
|
footer={null}
|
||||||
|
closable={false}
|
||||||
|
width={wide ? 960 : 560}
|
||||||
|
keyboard={!!onClose}
|
||||||
|
mask={{ closable: !!onClose }}
|
||||||
|
onCancel={() => onClose?.()}
|
||||||
|
destroyOnHidden
|
||||||
|
>
|
||||||
|
<div className={`modal ${className}`.trim()} {...rest}>
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
</AntModal>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
// A drop-down with the interface of a native <select> (value, onChange with `target.value`, <option> and
|
||||||
|
// <optgroup> children) drawn by Ant Design.
|
||||||
|
import { Select as AntSelect } from "antd";
|
||||||
|
import { Children, Fragment, isValidElement, useState, type CSSProperties, type ReactNode } from "react";
|
||||||
|
|
||||||
|
export interface SelectChange {
|
||||||
|
target: { value: string };
|
||||||
|
currentTarget: { value: string };
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
value?: string | number;
|
||||||
|
defaultValue?: string | number;
|
||||||
|
onChange?: (e: SelectChange) => void;
|
||||||
|
children?: ReactNode;
|
||||||
|
className?: string;
|
||||||
|
style?: CSSProperties;
|
||||||
|
title?: string;
|
||||||
|
id?: string;
|
||||||
|
disabled?: boolean;
|
||||||
|
autoFocus?: boolean;
|
||||||
|
required?: boolean;
|
||||||
|
size?: "small" | "middle" | "large";
|
||||||
|
"aria-label"?: string;
|
||||||
|
onClick?: (e: React.MouseEvent) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
type Option = { value: string; label: ReactNode; text: string; disabled?: boolean; title?: string };
|
||||||
|
type Entry = Option | { label: ReactNode; title?: string; options: Option[] };
|
||||||
|
|
||||||
|
const textOf = (node: ReactNode): string => {
|
||||||
|
if (typeof node === "string" || typeof node === "number") return String(node);
|
||||||
|
if (Array.isArray(node)) return node.map(textOf).join("");
|
||||||
|
return isValidElement<{ children?: ReactNode }>(node) ? textOf(node.props.children) : "";
|
||||||
|
};
|
||||||
|
|
||||||
|
function entries(children: ReactNode): Entry[] {
|
||||||
|
const out: Entry[] = [];
|
||||||
|
Children.forEach(children, (child) => {
|
||||||
|
if (!isValidElement<any>(child)) return;
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
const p = child.props as any;
|
||||||
|
if (child.type === Fragment) out.push(...entries(p.children));
|
||||||
|
else if (child.type === "optgroup") out.push({ label: p.label, options: entries(p.children).flatMap((e) => ("options" in e ? e.options : [e])) });
|
||||||
|
else if (child.type === "option") {
|
||||||
|
const text = textOf(p.children);
|
||||||
|
out.push({ value: String(p.value ?? text), label: p.children, text, disabled: p.disabled, title: p.title ?? text });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
const SEARCH_FROM = 12;
|
||||||
|
|
||||||
|
export function Select({ value, defaultValue, onChange, children, className, style, size, ...rest }: Props) {
|
||||||
|
const options = entries(children);
|
||||||
|
const flat = options.flatMap((e) => ("options" in e ? e.options : [e]));
|
||||||
|
// Like a native select, an uncontrolled one starts with its first option.
|
||||||
|
const [own, setOwn] = useState(() => String(defaultValue ?? flat[0]?.value ?? ""));
|
||||||
|
const current = value === undefined ? own : String(value);
|
||||||
|
return (
|
||||||
|
<AntSelect<string, Entry>
|
||||||
|
{...rest}
|
||||||
|
size={size}
|
||||||
|
className={className}
|
||||||
|
style={style}
|
||||||
|
value={flat.some((o) => o.value === current) ? current : undefined}
|
||||||
|
options={options}
|
||||||
|
popupMatchSelectWidth={false}
|
||||||
|
showSearch={flat.length >= SEARCH_FROM ? { filterOption: (q, o) => String((o as Option | undefined)?.text ?? "").toLowerCase().includes(q.toLowerCase()) } : false}
|
||||||
|
onChange={(v) => {
|
||||||
|
setOwn(v);
|
||||||
|
onChange?.({ target: { value: v }, currentTarget: { value: v } });
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -3,6 +3,14 @@
|
|||||||
* under "unreleased"; scripts/release.sh renames the key to the release version.
|
* under "unreleased"; scripts/release.sh renames the key to the release version.
|
||||||
*/
|
*/
|
||||||
export const WHATS_NEW: Record<string, { en: string[]; de: string[] }> = {
|
export const WHATS_NEW: Record<string, { en: string[]; de: string[] }> = {
|
||||||
|
"202611-00082": {
|
||||||
|
en: ["New uniform look: buttons, fields, drop-downs, tabs and dialogs are Ant Design components in your theme's colours", "Factory: every board column scrolls on its own", "Fixed: deleting the open chat no longer leaves an empty page"],
|
||||||
|
de: ["Neuer einheitlicher Look: Buttons, Felder, Auswahllisten, Reiter und Dialoge sind Ant-Design-Komponenten in den Farben deines Themes", "Factory: jede Spalte des Boards hat ihren eigenen Scrollbalken", "Behoben: Das Löschen des geöffneten Chats hinterlässt keine leere Seite mehr"],
|
||||||
|
},
|
||||||
|
"202611-00081": {
|
||||||
|
en: ["Queued messages can be forced: Enter on the empty input, Ctrl+Enter with text or the \"Force now\" button interrupts the running step so the model reads the message at once (also in the terminal client)", "Terminal client: long input and long questions wrap instead of being cut off; queued messages are shown above the input"],
|
||||||
|
de: ["Eingereihte Nachrichten lassen sich erzwingen: Enter im leeren Feld, Strg+Enter mit Text oder der Button „Jetzt erzwingen“ unterbricht den laufenden Schritt, sodass das Modell die Nachricht sofort liest (auch im Terminal-Client)", "Terminal-Client: lange Eingaben und lange Fragen werden umbrochen statt abgeschnitten; wartende Nachrichten stehen über dem Eingabefeld"],
|
||||||
|
},
|
||||||
"202611-00080": {
|
"202611-00080": {
|
||||||
en: ["Fixed: the Factory page no longer makes the server stall (504 errors, high CPU)"],
|
en: ["Fixed: the Factory page no longer makes the server stall (504 errors, high CPU)"],
|
||||||
de: ["Behoben: die Factory-Seite lässt den Server nicht mehr hängen (504-Fehler, hohe CPU-Last)"],
|
de: ["Behoben: die Factory-Seite lässt den Server nicht mehr hängen (504-Fehler, hohe CPU-Last)"],
|
||||||
|
|||||||
Reference in new issue
Block a user