Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9a4c6e5b9b | ||
|
|
c2d7fefb47 | ||
|
|
ede2e46d50 | ||
|
|
3c4425a408 | ||
|
|
1d67312ee4 | ||
|
|
201bb90bf7 | ||
|
|
9c371ec520 | ||
|
|
835bfae254 | ||
|
|
2bacd473fc | ||
|
|
65e5508d4b | ||
|
|
1576f61234 | ||
|
|
08de211ba0 | ||
|
|
7001616779 | ||
|
|
9228cd1e08 | ||
|
|
399ba80550 | ||
|
|
b69538de85 | ||
|
|
7b90f4bcc2 | ||
|
|
96eb8c109c | ||
|
|
276dfbab07 | ||
|
|
883cf3ebd1 | ||
|
|
6e283ddf83 | ||
|
|
979d5aed80 | ||
|
|
791d686c48 | ||
|
|
7ca6abf962 |
@@ -71,7 +71,14 @@
|
||||
"Bash(echo \"EXIT:$?\")",
|
||||
"Bash(ls target/)",
|
||||
"Bash(rustup target *)",
|
||||
"Bash(echo \"exit code: $?\")"
|
||||
"Bash(echo \"exit code: $?\")",
|
||||
"Read(//home/cbr/.cargo/registry/src/**)",
|
||||
"Bash(find / -maxdepth 6 -iname \"mistralrs-*\" -type d)",
|
||||
"Bash(grep -A2 '^name = \"tauri\"$' \"/mnt/c/Users/cbr/Desktop/Neuer Ordner \\(6\\)/src-tauri/Cargo.lock\")",
|
||||
"Bash(rustfmt --edition 2024 --check src/badge.rs src/main.rs)",
|
||||
"Bash(rustfmt --edition 2024 --check src/git.rs)",
|
||||
"Bash(rustfmt --edition 2024 --check src/badge.rs)",
|
||||
"Bash(rustfmt --edition 2024 --check src/git.rs src/main.rs)"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,45 +1 @@
|
||||
# Tauri Git Lite
|
||||
|
||||
Eine kleine Git-Desktop-App mit Tauri, Rust und Svelte.
|
||||
|
||||
## Funktionen
|
||||
|
||||
- Repository per lokalem Pfad öffnen
|
||||
- aktuellen Branch, Upstream, Ahead/Behind und Arbeitsbaumstatus anzeigen
|
||||
- Branches auflisten und auschecken
|
||||
- Branches in den aktuellen Branch mergen
|
||||
- Commit-History mit geänderten Dateien anzeigen
|
||||
- Explorer-Ansicht mit Ordnerbaum sowie getrackten und ungetrackten Dateien
|
||||
- Datei- und Ordner-History direkt aus dem Explorer anzeigen
|
||||
- einzelne Dateien stagen, unstagen und wiederherstellen
|
||||
- einzelne Dateien oder ganze Ordner aus einem History-Commit wiederherstellen
|
||||
- aktuellen Branch auf einen ausgewählten Commit zurücksetzen
|
||||
- Commit mit Message erstellen
|
||||
- Pull mit Fast-Forward-Strategie
|
||||
- Push auf den konfigurierten Upstream
|
||||
|
||||
## Entwicklung
|
||||
|
||||
```powershell
|
||||
npm install
|
||||
npm run tauri:dev
|
||||
```
|
||||
|
||||
Frontend allein:
|
||||
|
||||
```powershell
|
||||
npm run dev
|
||||
```
|
||||
|
||||
Checks:
|
||||
|
||||
```powershell
|
||||
npm run check
|
||||
npm run build
|
||||
cd src-tauri
|
||||
cargo check
|
||||
```
|
||||
|
||||
## Hinweis
|
||||
|
||||
Die App nutzt das lokal installierte `git` CLI. Ein Repository muss daher bereits auf der Maschine vorhanden sein, und Push/Pull verwenden die Credentials, die Git lokal kennt.
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "tauri-git-lite",
|
||||
"version": "2026.7.6",
|
||||
"version": "2026.7.10",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "tauri-git-lite",
|
||||
"version": "2026.7.6",
|
||||
"version": "2026.7.10",
|
||||
"dependencies": {
|
||||
"@lucide/svelte": "^1.21.0",
|
||||
"@tailwindcss/vite": "^4.3.1",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "git-lite",
|
||||
"version": "2026.7.6",
|
||||
"version": "2026.7.10",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
||||
@@ -2,7 +2,7 @@ use std::time::Duration;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{build_messages, sanitize_message};
|
||||
use crate::{build_messages, looks_like_diff_echo, sanitize_message};
|
||||
|
||||
// Generous sizing so a detailed body with bullet points isn't cut off.
|
||||
const DEFAULT_MAX_TOKENS: u32 = 1500;
|
||||
@@ -56,8 +56,14 @@ async fn openai_compatible_request(
|
||||
let body = OpenAiRequest {
|
||||
model: model.to_string(),
|
||||
messages: vec![
|
||||
OpenAiMessage { role: "system", content: system },
|
||||
OpenAiMessage { role: "user", content: user },
|
||||
OpenAiMessage {
|
||||
role: "system",
|
||||
content: system,
|
||||
},
|
||||
OpenAiMessage {
|
||||
role: "user",
|
||||
content: user,
|
||||
},
|
||||
],
|
||||
temperature: 0.3,
|
||||
};
|
||||
@@ -82,17 +88,22 @@ async fn openai_compatible_request(
|
||||
return Err(format!("API error ({status}): {text}"));
|
||||
}
|
||||
|
||||
let parsed: OpenAiResponse = serde_json::from_str(&text)
|
||||
.map_err(|err| format!("Could not process response: {err}"))?;
|
||||
let parsed: OpenAiResponse =
|
||||
serde_json::from_str(&text).map_err(|err| format!("Could not process response: {err}"))?;
|
||||
|
||||
parsed
|
||||
let message = parsed
|
||||
.choices
|
||||
.into_iter()
|
||||
.next()
|
||||
.and_then(|choice| choice.message.content)
|
||||
.map(|content| sanitize_message(&content))
|
||||
.filter(|content| !content.is_empty())
|
||||
.ok_or_else(|| "The model did not return a response.".to_string())
|
||||
.ok_or_else(|| "The model did not return a response.".to_string())?;
|
||||
|
||||
if looks_like_diff_echo(&message) {
|
||||
return Err("The model returned the diff instead of a commit message.".to_string());
|
||||
}
|
||||
Ok(message)
|
||||
}
|
||||
|
||||
pub async fn generate_openai(
|
||||
@@ -168,7 +179,10 @@ pub async fn generate_anthropic(
|
||||
model: model.to_string(),
|
||||
max_tokens: DEFAULT_MAX_TOKENS,
|
||||
system,
|
||||
messages: vec![AnthropicMessage { role: "user", content: user }],
|
||||
messages: vec![AnthropicMessage {
|
||||
role: "user",
|
||||
content: user,
|
||||
}],
|
||||
};
|
||||
|
||||
let client = http_client()?;
|
||||
@@ -190,14 +204,19 @@ pub async fn generate_anthropic(
|
||||
return Err(format!("API error ({status}): {text}"));
|
||||
}
|
||||
|
||||
let parsed: AnthropicResponse = serde_json::from_str(&text)
|
||||
.map_err(|err| format!("Could not process response: {err}"))?;
|
||||
let parsed: AnthropicResponse =
|
||||
serde_json::from_str(&text).map_err(|err| format!("Could not process response: {err}"))?;
|
||||
|
||||
parsed
|
||||
let message = parsed
|
||||
.content
|
||||
.into_iter()
|
||||
.find_map(|block| block.text)
|
||||
.map(|text| sanitize_message(&text))
|
||||
.filter(|text| !text.is_empty())
|
||||
.ok_or_else(|| "The model did not return a response.".to_string())
|
||||
.ok_or_else(|| "The model did not return a response.".to_string())?;
|
||||
|
||||
if looks_like_diff_echo(&message) {
|
||||
return Err("The model returned the diff instead of a commit message.".to_string());
|
||||
}
|
||||
Ok(message)
|
||||
}
|
||||
|
||||
@@ -2,9 +2,13 @@ mod cloud;
|
||||
|
||||
pub use cloud::{generate_anthropic, generate_custom, generate_openai};
|
||||
|
||||
use std::sync::Arc;
|
||||
use std::{
|
||||
collections::hash_map::DefaultHasher,
|
||||
hash::{Hash, Hasher},
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
use mistralrs::{GgufModelBuilder, Model, TextMessageRole, TextMessages};
|
||||
use mistralrs::{GgufModelBuilder, Model, RequestBuilder, TextMessageRole};
|
||||
use tokio::sync::RwLock;
|
||||
|
||||
/// One selectable local (on-device) model. Larger models produce better commit messages
|
||||
@@ -19,7 +23,7 @@ pub struct LocalModelOption {
|
||||
tokenizer_repo: &'static str,
|
||||
}
|
||||
|
||||
pub const DEFAULT_LOCAL_MODEL_ID: &str = "qwen2.5-1.5b";
|
||||
pub const DEFAULT_LOCAL_MODEL_ID: &str = "qwen2.5-0.5b";
|
||||
|
||||
pub const LOCAL_MODELS: &[LocalModelOption] = &[
|
||||
LocalModelOption {
|
||||
@@ -52,6 +56,59 @@ fn find_local_model(model_id: &str) -> Option<&'static LocalModelOption> {
|
||||
LOCAL_MODELS.iter().find(|option| option.id == model_id)
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum LocalGenerationProfile {
|
||||
Fast,
|
||||
Balanced,
|
||||
Detailed,
|
||||
}
|
||||
|
||||
impl Default for LocalGenerationProfile {
|
||||
fn default() -> Self {
|
||||
Self::Fast
|
||||
}
|
||||
}
|
||||
|
||||
impl LocalGenerationProfile {
|
||||
pub fn from_id(value: Option<&str>) -> Self {
|
||||
match value
|
||||
.unwrap_or_default()
|
||||
.trim()
|
||||
.to_ascii_lowercase()
|
||||
.as_str()
|
||||
{
|
||||
"balanced" => Self::Balanced,
|
||||
"detailed" => Self::Detailed,
|
||||
_ => Self::Fast,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn diff_unified_context(self) -> &'static str {
|
||||
match self {
|
||||
Self::Fast => "--unified=1",
|
||||
Self::Balanced => "--unified=2",
|
||||
Self::Detailed => "--unified=3",
|
||||
}
|
||||
}
|
||||
|
||||
fn max_diff_chars(self) -> usize {
|
||||
match self {
|
||||
Self::Fast => 8_000,
|
||||
Self::Balanced => 12_000,
|
||||
Self::Detailed => 24_000,
|
||||
}
|
||||
}
|
||||
|
||||
fn max_output_tokens(self) -> usize {
|
||||
match self {
|
||||
Self::Fast => 160,
|
||||
Self::Balanced => 360,
|
||||
Self::Detailed => 750,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum CommitAiPhase {
|
||||
@@ -75,6 +132,20 @@ struct Inner {
|
||||
model_id: Option<String>,
|
||||
error: Option<String>,
|
||||
model: Option<Arc<Model>>,
|
||||
cache: Option<GenerationCache>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
struct GenerationCacheKey {
|
||||
model_id: String,
|
||||
profile: LocalGenerationProfile,
|
||||
input_hash: u64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
struct GenerationCache {
|
||||
key: GenerationCacheKey,
|
||||
message: String,
|
||||
}
|
||||
|
||||
/// Manages the local (on-device) model only. Cloud providers are stateless HTTP calls
|
||||
@@ -92,6 +163,7 @@ impl Default for CommitAiEngine {
|
||||
model_id: None,
|
||||
error: None,
|
||||
model: None,
|
||||
cache: None,
|
||||
})),
|
||||
}
|
||||
}
|
||||
@@ -129,6 +201,7 @@ impl CommitAiEngine {
|
||||
guard.phase = CommitAiPhase::Error;
|
||||
guard.model_id = Some(model_id.to_string());
|
||||
guard.error = Some(format!("Unknown local model: {model_id}"));
|
||||
guard.cache = None;
|
||||
return;
|
||||
};
|
||||
|
||||
@@ -138,6 +211,7 @@ impl CommitAiEngine {
|
||||
guard.model_id = Some(model_id.to_string());
|
||||
guard.error = None;
|
||||
guard.model = None;
|
||||
guard.cache = None;
|
||||
}
|
||||
|
||||
let result = GgufModelBuilder::new(option.repo, vec![option.file])
|
||||
@@ -157,10 +231,12 @@ impl CommitAiEngine {
|
||||
guard.model = Some(Arc::new(model));
|
||||
guard.phase = CommitAiPhase::Ready;
|
||||
guard.error = None;
|
||||
guard.cache = None;
|
||||
}
|
||||
Err(err) => {
|
||||
guard.phase = CommitAiPhase::Error;
|
||||
guard.error = Some(err.to_string());
|
||||
guard.cache = None;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -169,22 +245,36 @@ impl CommitAiEngine {
|
||||
&self,
|
||||
diff: &str,
|
||||
notes: Option<&str>,
|
||||
profile: LocalGenerationProfile,
|
||||
) -> Result<String, String> {
|
||||
let model = {
|
||||
let (model, cache_key) = {
|
||||
let guard = self.inner.read().await;
|
||||
match (guard.phase, &guard.model) {
|
||||
(CommitAiPhase::Ready, Some(model)) => model.clone(),
|
||||
(CommitAiPhase::Ready, Some(model)) => {
|
||||
let cache_key = GenerationCacheKey {
|
||||
model_id: guard.model_id.clone().unwrap_or_default(),
|
||||
profile,
|
||||
input_hash: generation_input_hash(diff, notes),
|
||||
};
|
||||
if let Some(cache) = &guard.cache {
|
||||
if cache.key == cache_key {
|
||||
return Ok(cache.message.clone());
|
||||
}
|
||||
}
|
||||
(model.clone(), cache_key)
|
||||
}
|
||||
_ => return Err("The local AI model is not ready yet.".to_string()),
|
||||
}
|
||||
};
|
||||
|
||||
let (system, user) = build_messages(diff, notes)?;
|
||||
let messages = TextMessages::new()
|
||||
let (system, user) = build_local_messages(diff, notes, profile)?;
|
||||
let request = RequestBuilder::new()
|
||||
.set_sampler_max_len(profile.max_output_tokens())
|
||||
.add_message(TextMessageRole::System, system)
|
||||
.add_message(TextMessageRole::User, user);
|
||||
|
||||
let response = model
|
||||
.send_chat_request(messages)
|
||||
.send_chat_request(request)
|
||||
.await
|
||||
.map_err(|err| err.to_string())?;
|
||||
|
||||
@@ -198,10 +288,29 @@ impl CommitAiEngine {
|
||||
if message.is_empty() {
|
||||
return Err("The model did not return a response.".to_string());
|
||||
}
|
||||
if looks_like_diff_echo(&message) {
|
||||
return Err(
|
||||
"The local model returned the diff instead of a commit message. Try a larger local model (1.5B or 3B) or a cloud provider.".to_string(),
|
||||
);
|
||||
}
|
||||
{
|
||||
let mut guard = self.inner.write().await;
|
||||
guard.cache = Some(GenerationCache {
|
||||
key: cache_key,
|
||||
message: message.clone(),
|
||||
});
|
||||
}
|
||||
Ok(message)
|
||||
}
|
||||
}
|
||||
|
||||
fn generation_input_hash(diff: &str, notes: Option<&str>) -> u64 {
|
||||
let mut hasher = DefaultHasher::new();
|
||||
diff.hash(&mut hasher);
|
||||
notes.unwrap_or("").hash(&mut hasher);
|
||||
hasher.finish()
|
||||
}
|
||||
|
||||
/// Models occasionally ignore the "no code fences" instruction (small local models
|
||||
/// especially) — strip a wrapping ``` fence and wrapping quotes so the result can go
|
||||
/// straight into the commit-message box.
|
||||
@@ -221,6 +330,74 @@ pub(crate) fn sanitize_message(raw: &str) -> String {
|
||||
trimmed.to_string()
|
||||
}
|
||||
|
||||
/// Weak models (small local ones especially) sometimes just echo the prompt's diff
|
||||
/// sections back instead of writing a commit message. Catch that so the UI can show a
|
||||
/// clear error instead of dumping raw diff text into the commit-message box.
|
||||
pub(crate) fn looks_like_diff_echo(message: &str) -> bool {
|
||||
let lower = message.to_ascii_lowercase();
|
||||
lower.contains("diff --git")
|
||||
|| lower.contains("staged files:")
|
||||
|| lower.contains("staged changes:")
|
||||
|| lower.contains("diff stat:")
|
||||
|| lower.contains("detailed diff:")
|
||||
|| message.lines().any(|line| line.starts_with("@@ "))
|
||||
}
|
||||
|
||||
fn truncate_at_char_boundary(input: &str, max_chars: usize) -> String {
|
||||
if input.len() <= max_chars {
|
||||
return input.to_string();
|
||||
}
|
||||
|
||||
let mut cut = max_chars;
|
||||
while !input.is_char_boundary(cut) {
|
||||
cut -= 1;
|
||||
}
|
||||
format!("{}\n\n[... diff truncated ...]", &input[..cut])
|
||||
}
|
||||
|
||||
pub(crate) fn build_local_messages(
|
||||
diff: &str,
|
||||
notes: Option<&str>,
|
||||
profile: LocalGenerationProfile,
|
||||
) -> Result<(String, String), String> {
|
||||
if diff.trim().is_empty() {
|
||||
return Err("No staged changes available for a commit message.".to_string());
|
||||
}
|
||||
|
||||
let diff = truncate_at_char_boundary(diff, profile.max_diff_chars());
|
||||
// Appended to every profile below: small local models occasionally just echo the input
|
||||
// (the "Staged files:" / "Diff stat:" / "Detailed diff:" sections built in git.rs's
|
||||
// `staged_diff_local`) instead of writing a new commit message. Naming those exact
|
||||
// section headers here makes the failure mode explicit enough for weak models to avoid.
|
||||
const ANTI_ECHO: &str = " Never repeat, quote, or paraphrase the diff or its headers — \
|
||||
do not include 'diff --git', '@@', 'Staged files:', 'Diff stat:', or 'Detailed diff:' \
|
||||
anywhere in your answer.";
|
||||
let system = match profile {
|
||||
LocalGenerationProfile::Fast => {
|
||||
format!(
|
||||
"You generate Git commit messages. Respond only with one Conventional Commits subject line: <type>(<scope>): <subject>. Max 72 characters. No body, bullets, preamble, explanation, code fences, or quotes. Answer in English.{ANTI_ECHO}"
|
||||
)
|
||||
}
|
||||
LocalGenerationProfile::Balanced => {
|
||||
format!(
|
||||
"You generate Git commit messages. Respond with a Conventional Commits subject line, then a blank line, then at most two short bullet points. Keep every line under 72 characters. No preamble, explanation, code fences, or quotes. Answer in English.{ANTI_ECHO}"
|
||||
)
|
||||
}
|
||||
LocalGenerationProfile::Detailed => {
|
||||
format!(
|
||||
"You generate Git commit messages. Respond with a Conventional Commits subject line, then a blank line, then a concise body and up to four short bullet points grouped by affected area/file. Keep every line under 72 characters. No preamble, explanation, code fences, or quotes. Answer in English.{ANTI_ECHO}"
|
||||
)
|
||||
}
|
||||
};
|
||||
|
||||
let mut user = String::new();
|
||||
if let Some(n) = notes.filter(|n| !n.trim().is_empty()) {
|
||||
user.push_str(&format!("Developer notes:\n{n}\n\n"));
|
||||
}
|
||||
user.push_str(&format!("Staged changes:\n{diff}"));
|
||||
Ok((system, user))
|
||||
}
|
||||
|
||||
pub(crate) fn build_messages(diff: &str, notes: Option<&str>) -> Result<(String, String), String> {
|
||||
if diff.trim().is_empty() {
|
||||
return Err("No staged changes available for a commit message.".to_string());
|
||||
@@ -228,26 +405,35 @@ pub(crate) fn build_messages(diff: &str, notes: Option<&str>) -> Result<(String,
|
||||
|
||||
// Rough token estimate — small models often have an 8-32k context window.
|
||||
const MAX_CHARS: usize = 24_000;
|
||||
let diff = if diff.len() > MAX_CHARS {
|
||||
// Pull the byte index back to a valid UTF-8 char boundary, otherwise
|
||||
// slicing mid-multi-byte-character would panic.
|
||||
let mut cut = MAX_CHARS;
|
||||
while !diff.is_char_boundary(cut) {
|
||||
cut -= 1;
|
||||
}
|
||||
format!("{}\n\n[... diff truncated ...]", &diff[..cut])
|
||||
} else {
|
||||
diff.to_string()
|
||||
};
|
||||
let diff = truncate_at_char_boundary(diff, MAX_CHARS);
|
||||
|
||||
let system = "You are a tool that generates Git commit messages. \
|
||||
Respond only with the commit message in Conventional Commits format \
|
||||
(<type>(<scope>): <subject>), followed by a body after a blank line. \
|
||||
Subject in imperative mood, max. 72 characters. \
|
||||
The body is required: summarize in a short paragraph what changed and why, \
|
||||
then list the key changes as bullet points (- ...), \
|
||||
grouped by affected area/file. Lines in the body max. 72 characters. \
|
||||
No preamble, no explanation, no code fences, answer in English"
|
||||
let system = "You are a tool that writes a Git commit message describing a staged diff. \
|
||||
Output ONLY the commit message text. Never quote, restate, or paraphrase the diff itself: \
|
||||
do not include lines starting with 'diff --git', '@@', '+', '-', 'index ', 'Staged files:', \
|
||||
or 'Diff stat:' anywhere in your answer. \
|
||||
Format: a Conventional Commits header (<type>(<scope>): <subject>) in imperative mood, \
|
||||
max. 72 characters, then a blank line, then a body. \
|
||||
The body is required: a short, general paragraph (2-4 sentences) summarizing what changed \
|
||||
and why at a high level — do NOT enumerate every changed file individually. \
|
||||
You may optionally add up to 3 bullet points (- ...) afterward, but only for the most \
|
||||
significant changes overall, never one bullet or heading per file. \
|
||||
Never use bold text, backticks, or markdown headings for file names. \
|
||||
Lines in the body max. 72 characters. \
|
||||
No preamble, no explanation, no code fences, answer in English.\n\n\
|
||||
Example:\n\
|
||||
Diff:\n\
|
||||
diff --git a/src/auth.py b/src/auth.py\n\
|
||||
+def hash_password(pw):\n\
|
||||
+ return bcrypt.hash(pw)\n\
|
||||
diff --git a/src/routes.py b/src/routes.py\n\
|
||||
-if password == stored_password:\n\
|
||||
+if bcrypt.check(password, stored_password):\n\n\
|
||||
Commit message:\n\
|
||||
feat(auth): hash and verify passwords with bcrypt\n\n\
|
||||
Passwords were previously compared as plain text. This adds a bcrypt-based\n\
|
||||
hashing helper and updates the login check to verify against the hash\n\
|
||||
instead of a direct string comparison.\n\n\
|
||||
- Hash passwords on write, verify with bcrypt on login"
|
||||
.to_string();
|
||||
|
||||
let mut user = String::new();
|
||||
|
||||
@@ -0,0 +1,186 @@
|
||||
//! Renders the combined repository attention count as a taskbar badge and applies it as the
|
||||
//! Windows taskbar overlay. Windows has no native numeric taskbar badge (unlike
|
||||
//! macOS/Linux, which support `Window::set_badge_count`), so the numbers have to be drawn
|
||||
//! into a plain RGBA icon ourselves and set via `Window::set_overlay_icon`.
|
||||
|
||||
use tauri::Manager;
|
||||
use tauri::image::Image;
|
||||
|
||||
const GLYPH_WIDTH: usize = 3;
|
||||
const GLYPH_HEIGHT: usize = 5;
|
||||
|
||||
/// A minimal 3x5 pixel-grid font, just enough to draw digits and "+" legibly at badge size.
|
||||
fn glyph_rows(ch: char) -> [&'static str; GLYPH_HEIGHT] {
|
||||
match ch {
|
||||
'0' => ["111", "101", "101", "101", "111"],
|
||||
'1' => ["010", "110", "010", "010", "111"],
|
||||
'2' => ["111", "001", "111", "100", "111"],
|
||||
'3' => ["111", "001", "111", "001", "111"],
|
||||
'4' => ["101", "101", "111", "001", "001"],
|
||||
'5' => ["111", "100", "111", "001", "111"],
|
||||
'6' => ["111", "100", "111", "101", "111"],
|
||||
'7' => ["111", "001", "010", "010", "010"],
|
||||
'8' => ["111", "101", "111", "101", "111"],
|
||||
'9' => ["111", "101", "111", "001", "111"],
|
||||
'+' => ["000", "010", "111", "010", "000"],
|
||||
_ => ["000", "000", "000", "000", "000"],
|
||||
}
|
||||
}
|
||||
|
||||
const BADGE_FILL: [u8; 4] = [224, 160, 64, 255];
|
||||
const BADGE_BORDER: [u8; 4] = [176, 118, 40, 255];
|
||||
const TEXT_FILL: [u8; 4] = [255, 255, 255, 255];
|
||||
const TEXT_SHADOW: [u8; 4] = [10, 12, 24, 190];
|
||||
const CIRCLE_BORDER_WIDTH: f32 = 3.0;
|
||||
|
||||
/// Caps the displayed text at three characters ("99+") so it always fits legibly.
|
||||
fn cap_text(count: u32) -> String {
|
||||
if count > 99 {
|
||||
"99+".to_string()
|
||||
} else {
|
||||
count.to_string()
|
||||
}
|
||||
}
|
||||
|
||||
/// Draws a filled circle (with a slightly darker rim) centered at `(cx, cy)`.
|
||||
fn draw_circle(
|
||||
rgba: &mut [u8],
|
||||
size: usize,
|
||||
cx: f32,
|
||||
cy: f32,
|
||||
radius: f32,
|
||||
fill: [u8; 4],
|
||||
border: [u8; 4],
|
||||
) {
|
||||
for y in 0..size {
|
||||
for x in 0..size {
|
||||
let dx = x as f32 + 0.5 - cx;
|
||||
let dy = y as f32 + 0.5 - cy;
|
||||
let dist = (dx * dx + dy * dy).sqrt();
|
||||
if dist <= radius {
|
||||
let color = if dist >= radius - CIRCLE_BORDER_WIDTH {
|
||||
border
|
||||
} else {
|
||||
fill
|
||||
};
|
||||
let idx = (y * size + x) * 4;
|
||||
rgba[idx..idx + 4].copy_from_slice(&color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn draw_text_layer(
|
||||
rgba: &mut [u8],
|
||||
size: usize,
|
||||
text: &str,
|
||||
cx: f32,
|
||||
cy: f32,
|
||||
scale: usize,
|
||||
offset: (isize, isize),
|
||||
color: [u8; 4],
|
||||
) {
|
||||
let glyphs: Vec<[&'static str; GLYPH_HEIGHT]> = text.chars().map(glyph_rows).collect();
|
||||
let glyph_px_w = GLYPH_WIDTH * scale;
|
||||
let glyph_px_h = GLYPH_HEIGHT * scale;
|
||||
let gap = scale.max(1);
|
||||
let total_w = glyphs.len() * glyph_px_w + gap * glyphs.len().saturating_sub(1);
|
||||
let start_x = (cx - total_w as f32 / 2.0).round() as isize + offset.0;
|
||||
let start_y = (cy - glyph_px_h as f32 / 2.0).round() as isize + offset.1;
|
||||
|
||||
for (gi, rows) in glyphs.iter().enumerate() {
|
||||
let glyph_x = start_x + (gi * (glyph_px_w + gap)) as isize;
|
||||
for (gy, row) in rows.iter().enumerate() {
|
||||
for (gx, pixel) in row.chars().enumerate() {
|
||||
if pixel != '1' {
|
||||
continue;
|
||||
}
|
||||
for py in 0..scale {
|
||||
for px in 0..scale {
|
||||
let x = glyph_x + (gx * scale + px) as isize;
|
||||
let y = start_y + (gy * scale + py) as isize;
|
||||
if x >= 0 && y >= 0 && (x as usize) < size && (y as usize) < size {
|
||||
let idx = (y as usize * size + x as usize) * 4;
|
||||
rgba[idx..idx + 4].copy_from_slice(&color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Draws white `text` centered at `(cx, cy)`, scaling each font pixel up by `scale`.
|
||||
fn draw_text(rgba: &mut [u8], size: usize, text: &str, cx: f32, cy: f32, scale: usize) {
|
||||
for offset in [(-1, 0), (1, 0), (0, -1), (0, 1)] {
|
||||
draw_text_layer(rgba, size, text, cx, cy, scale, offset, TEXT_SHADOW);
|
||||
}
|
||||
draw_text_layer(rgba, size, text, cx, cy, scale, (0, 0), TEXT_FILL);
|
||||
}
|
||||
|
||||
fn text_scale(text: &str) -> usize {
|
||||
match text.len() {
|
||||
0 | 1 => 7,
|
||||
2 => 5,
|
||||
_ => 4,
|
||||
}
|
||||
}
|
||||
|
||||
/// Renders a single large badge with `count`. Returns `None` when there's nothing to show,
|
||||
/// so the caller can clear the overlay icon.
|
||||
fn render_badge_icon(count: u32) -> Option<Image<'static>> {
|
||||
if count == 0 {
|
||||
return None;
|
||||
}
|
||||
|
||||
const SIZE: usize = 64;
|
||||
const RADIUS: f32 = 29.0;
|
||||
let mut rgba = vec![0u8; SIZE * SIZE * 4];
|
||||
let center = SIZE as f32 / 2.0;
|
||||
|
||||
let text = cap_text(count);
|
||||
draw_circle(
|
||||
&mut rgba,
|
||||
SIZE,
|
||||
center,
|
||||
center,
|
||||
RADIUS,
|
||||
BADGE_FILL,
|
||||
BADGE_BORDER,
|
||||
);
|
||||
draw_text(&mut rgba, SIZE, &text, center, center, text_scale(&text));
|
||||
|
||||
Some(Image::new_owned(rgba, SIZE as u32, SIZE as u32))
|
||||
}
|
||||
|
||||
/// Sets the taskbar badge to `ahead + behind + changes` (0 clears it). Windows-only: Windows
|
||||
/// has no native numeric badge API, so this draws and applies a small overlay icon instead.
|
||||
/// No-op on other platforms: non-Windows desktops should use `Window::set_badge_count`
|
||||
/// for a real native badge instead, which this app doesn't currently wire up.
|
||||
#[tauri::command]
|
||||
pub fn set_sync_badge(
|
||||
app: tauri::AppHandle,
|
||||
ahead: u32,
|
||||
behind: u32,
|
||||
changes: u32,
|
||||
) -> Result<(), String> {
|
||||
let count = ahead.saturating_add(behind).saturating_add(changes);
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
let Some(window) = app.get_webview_window("main") else {
|
||||
return Ok(());
|
||||
};
|
||||
let icon = render_badge_icon(count);
|
||||
window
|
||||
.set_overlay_icon(icon)
|
||||
.map_err(|err| format!("Could not set taskbar badge: {err}"))?;
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
{
|
||||
let _ = (app, count);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
+420
-25
@@ -47,6 +47,7 @@ pub struct GitStatus {
|
||||
pub behind: u32,
|
||||
pub files: Vec<GitFileStatus>,
|
||||
pub clean: bool,
|
||||
pub rebase_in_progress: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
|
||||
@@ -56,6 +57,16 @@ pub struct GitBranch {
|
||||
pub remote: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
|
||||
pub struct GitStash {
|
||||
pub selector: String,
|
||||
pub index: u32,
|
||||
pub hash: String,
|
||||
pub branch: Option<String>,
|
||||
pub message: String,
|
||||
pub date: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
|
||||
pub struct GitCommit {
|
||||
pub hash: String,
|
||||
@@ -234,6 +245,7 @@ pub fn open_repository_file(path: String, file: String) -> Result<(), String> {
|
||||
pub struct RepositoryBundle {
|
||||
pub status: GitStatus,
|
||||
pub branches: Vec<GitBranch>,
|
||||
pub stashes: Vec<GitStash>,
|
||||
pub commits: Vec<GitCommit>,
|
||||
pub files: Vec<GitRepositoryFile>,
|
||||
}
|
||||
@@ -252,11 +264,13 @@ pub async fn open_repository_bundle(
|
||||
let repo = resolve_repo(&path)?;
|
||||
let status = status_for_repo(&repo)?;
|
||||
let branches = branches_for_repo(&repo)?;
|
||||
let stashes = stashes_for_repo(&repo)?;
|
||||
let commits = commits_for_repo(&repo, commit_limit)?;
|
||||
let files = repository_files_with_status(&repo, &status)?;
|
||||
Ok(RepositoryBundle {
|
||||
status,
|
||||
branches,
|
||||
stashes,
|
||||
commits,
|
||||
files,
|
||||
})
|
||||
@@ -277,6 +291,12 @@ pub fn list_branches(path: String) -> Result<Vec<GitBranch>, String> {
|
||||
branches_for_repo(&repo)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn list_stashes(path: String) -> Result<Vec<GitStash>, String> {
|
||||
let repo = resolve_repo(&path)?;
|
||||
stashes_for_repo(&repo)
|
||||
}
|
||||
|
||||
fn branches_for_repo(repo: &Path) -> Result<Vec<GitBranch>, String> {
|
||||
let output = run_git(
|
||||
repo,
|
||||
@@ -316,6 +336,129 @@ fn branches_for_repo(repo: &Path) -> Result<Vec<GitBranch>, String> {
|
||||
Ok(branches)
|
||||
}
|
||||
|
||||
fn stashes_for_repo(repo: &Path) -> Result<Vec<GitStash>, String> {
|
||||
let output = run_git(repo, ["stash", "list", "--format=%gd%x00%H%x00%cr%x00%gs"])?;
|
||||
let text = String::from_utf8_lossy(&output);
|
||||
let mut stashes = Vec::new();
|
||||
|
||||
for line in text.lines() {
|
||||
let mut parts = line.splitn(4, '\0');
|
||||
let selector = parts.next().unwrap_or_default().trim();
|
||||
let hash = parts.next().unwrap_or_default().trim();
|
||||
let date = parts.next().unwrap_or_default().trim();
|
||||
let subject = parts.next().unwrap_or_default().trim();
|
||||
if selector.is_empty() {
|
||||
continue;
|
||||
}
|
||||
|
||||
let index = stash_index_from_selector(selector).unwrap_or(stashes.len() as u32);
|
||||
let (branch, message) = parse_stash_subject(subject);
|
||||
stashes.push(GitStash {
|
||||
selector: selector.to_string(),
|
||||
index,
|
||||
hash: hash.to_string(),
|
||||
branch,
|
||||
message,
|
||||
date: date.to_string(),
|
||||
});
|
||||
}
|
||||
|
||||
Ok(stashes)
|
||||
}
|
||||
|
||||
fn stash_index_from_selector(selector: &str) -> Option<u32> {
|
||||
selector
|
||||
.strip_prefix("stash@{")
|
||||
.and_then(|value| value.strip_suffix('}'))
|
||||
.and_then(|value| value.parse::<u32>().ok())
|
||||
}
|
||||
|
||||
fn parse_stash_subject(subject: &str) -> (Option<String>, String) {
|
||||
for prefix in ["WIP on ", "On "] {
|
||||
if let Some(value) = subject.strip_prefix(prefix) {
|
||||
if let Some((branch, rest)) = value.split_once(": ") {
|
||||
let message = if prefix == "WIP on " {
|
||||
rest.split_once(' ').map(|(_, msg)| msg).unwrap_or(rest)
|
||||
} else {
|
||||
rest
|
||||
};
|
||||
return (Some(branch.to_string()), message.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
(None, subject.to_string())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn stash_push(
|
||||
path: String,
|
||||
message: Option<String>,
|
||||
include_untracked: bool,
|
||||
) -> Result<GitStatus, String> {
|
||||
let repo = resolve_repo(&path)?;
|
||||
let trimmed_message = message.unwrap_or_default().trim().to_string();
|
||||
let mut args: Vec<OsString> = vec![OsString::from("stash"), OsString::from("push")];
|
||||
if include_untracked {
|
||||
args.push(OsString::from("--include-untracked"));
|
||||
}
|
||||
if !trimmed_message.is_empty() {
|
||||
args.push(OsString::from("-m"));
|
||||
args.push(OsString::from(trimmed_message));
|
||||
}
|
||||
|
||||
run_git(&repo, args)?;
|
||||
status_for_repo(&repo)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn stash_apply(path: String, selector: String) -> Result<GitStatus, String> {
|
||||
run_stash_update(path, "apply", selector)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn stash_pop(path: String, selector: String) -> Result<GitStatus, String> {
|
||||
run_stash_update(path, "pop", selector)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn stash_drop(path: String, selector: String) -> Result<GitStatus, String> {
|
||||
run_stash_update(path, "drop", selector)
|
||||
}
|
||||
|
||||
fn run_stash_update(path: String, action: &str, selector: String) -> Result<GitStatus, String> {
|
||||
let repo = resolve_repo(&path)?;
|
||||
let selector = validate_stash_selector(&selector)?;
|
||||
let output = git_command()
|
||||
.arg("-C")
|
||||
.arg(&repo)
|
||||
.args(["stash", action, selector.as_str()])
|
||||
.output()
|
||||
.map_err(|err| format!("Could not start Git. Is Git installed? {err}"))?;
|
||||
|
||||
if output.status.success() {
|
||||
return status_for_repo(&repo);
|
||||
}
|
||||
|
||||
let status = status_for_repo(&repo)?;
|
||||
if has_unresolved_conflicts(&status) {
|
||||
return Ok(status);
|
||||
}
|
||||
|
||||
Err(format!(
|
||||
"Git command failed: {}",
|
||||
command_output_details(&output)
|
||||
))
|
||||
}
|
||||
|
||||
fn validate_stash_selector(selector: &str) -> Result<String, String> {
|
||||
let selector = selector.trim();
|
||||
let Some(index) = stash_index_from_selector(selector) else {
|
||||
return Err("Invalid stash selector.".to_string());
|
||||
};
|
||||
Ok(format!("stash@{{{index}}}"))
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn checkout_branch(path: String, branch: String) -> Result<GitStatus, String> {
|
||||
let repo = resolve_repo(&path)?;
|
||||
@@ -387,7 +530,11 @@ pub fn rename_branch(
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn delete_branch(path: String, branch: String) -> Result<GitStatus, String> {
|
||||
pub fn delete_branch(
|
||||
path: String,
|
||||
branch: String,
|
||||
force: Option<bool>,
|
||||
) -> Result<GitStatus, String> {
|
||||
let repo = resolve_repo(&path)?;
|
||||
let branch = validate_existing_local_branch_name(&repo, &branch)?;
|
||||
let status = status_for_repo(&repo)?;
|
||||
@@ -395,7 +542,8 @@ pub fn delete_branch(path: String, branch: String) -> Result<GitStatus, String>
|
||||
return Err("The current branch cannot be deleted.".to_string());
|
||||
}
|
||||
|
||||
run_git(&repo, ["branch", "-d", "--", branch.as_str()])?;
|
||||
let delete_flag = if force.unwrap_or(false) { "-D" } else { "-d" };
|
||||
run_git(&repo, ["branch", delete_flag, "--", branch.as_str()])?;
|
||||
status_for_repo(&repo)
|
||||
}
|
||||
|
||||
@@ -540,6 +688,50 @@ fn staged_diff(repo: &Path) -> Result<String, String> {
|
||||
Ok(format!("Staged files:\n{file_list}\n\n{diff}"))
|
||||
}
|
||||
|
||||
fn staged_diff_local(
|
||||
repo: &Path,
|
||||
profile: commit_ai::LocalGenerationProfile,
|
||||
) -> Result<String, String> {
|
||||
let name_status = run_git(repo, ["diff", "--cached", "--name-status", "-M"])?;
|
||||
let file_list = String::from_utf8_lossy(&name_status).trim().to_string();
|
||||
|
||||
let stat = run_git(repo, ["diff", "--cached", "--stat", "--summary"])?;
|
||||
let stat = String::from_utf8_lossy(&stat).trim().to_string();
|
||||
|
||||
let diff_args = vec![
|
||||
"diff",
|
||||
"--cached",
|
||||
"--no-ext-diff",
|
||||
"--no-textconv",
|
||||
profile.diff_unified_context(),
|
||||
"--",
|
||||
".",
|
||||
":(exclude)*package-lock.json",
|
||||
":(exclude)*pnpm-lock.yaml",
|
||||
":(exclude)*yarn.lock",
|
||||
":(exclude)*bun.lockb",
|
||||
":(exclude)*Cargo.lock",
|
||||
":(exclude)*composer.lock",
|
||||
":(exclude)*Gemfile.lock",
|
||||
":(exclude)*poetry.lock",
|
||||
":(exclude)*go.sum",
|
||||
];
|
||||
let diff = run_git(repo, diff_args)?;
|
||||
let diff = String::from_utf8_lossy(&diff).trim().to_string();
|
||||
|
||||
let mut sections = Vec::new();
|
||||
if !file_list.is_empty() {
|
||||
sections.push(format!("Staged files:\n{file_list}"));
|
||||
}
|
||||
if !stat.is_empty() {
|
||||
sections.push(format!("Diff stat:\n{stat}"));
|
||||
}
|
||||
if !diff.is_empty() {
|
||||
sections.push(format!("Detailed diff:\n{diff}"));
|
||||
}
|
||||
Ok(sections.join("\n\n"))
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn commit_ai_generate(
|
||||
path: String,
|
||||
@@ -548,17 +740,27 @@ pub async fn commit_ai_generate(
|
||||
model: Option<String>,
|
||||
api_key: Option<String>,
|
||||
base_url: Option<String>,
|
||||
local_profile: Option<String>,
|
||||
engine: tauri::State<'_, commit_ai::CommitAiEngine>,
|
||||
) -> Result<String, String> {
|
||||
let repo = resolve_repo(&path)?;
|
||||
let diff = staged_diff(&repo)?;
|
||||
let local_profile = commit_ai::LocalGenerationProfile::from_id(local_profile.as_deref());
|
||||
let diff = if provider == "local" {
|
||||
staged_diff_local(&repo, local_profile)?
|
||||
} else {
|
||||
staged_diff(&repo)?
|
||||
};
|
||||
let notes = notes.as_deref();
|
||||
let model = model.filter(|value| !value.trim().is_empty());
|
||||
let api_key = api_key.filter(|value| !value.trim().is_empty());
|
||||
let base_url = base_url.filter(|value| !value.trim().is_empty());
|
||||
|
||||
match provider.as_str() {
|
||||
"local" => engine.generate_commit_message(&diff, notes).await,
|
||||
"local" => {
|
||||
engine
|
||||
.generate_commit_message(&diff, notes, local_profile)
|
||||
.await
|
||||
}
|
||||
"openai" => {
|
||||
let api_key = api_key.ok_or_else(|| "OpenAI API key is missing.".to_string())?;
|
||||
let model = model.unwrap_or_else(|| "gpt-4o-mini".to_string());
|
||||
@@ -620,9 +822,7 @@ pub fn commit(path: String, message: String) -> Result<GitStatus, String> {
|
||||
|
||||
let current_status = status_for_repo(&repo)?;
|
||||
if has_unresolved_conflicts(¤t_status) {
|
||||
return Err(
|
||||
"Merge conflicts must be resolved before you can commit.".to_string(),
|
||||
);
|
||||
return Err("Merge conflicts must be resolved before you can commit.".to_string());
|
||||
}
|
||||
|
||||
run_git(&repo, ["commit", "-m", message.as_str()])?;
|
||||
@@ -646,9 +846,7 @@ pub fn pull(
|
||||
.arg(&repo)
|
||||
.args(pull_args)
|
||||
.output()
|
||||
.map_err(|err| {
|
||||
format!("Could not start Git. Is Git installed? {err}")
|
||||
})?,
|
||||
.map_err(|err| format!("Could not start Git. Is Git installed? {err}"))?,
|
||||
};
|
||||
|
||||
if output.status.success() {
|
||||
@@ -667,6 +865,41 @@ pub fn pull(
|
||||
Err(format!("Git command failed: {details}"))
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn fetch(
|
||||
path: String,
|
||||
username: Option<String>,
|
||||
password: Option<String>,
|
||||
) -> Result<GitStatus, String> {
|
||||
tauri::async_runtime::spawn_blocking(move || -> Result<GitStatus, String> {
|
||||
let repo = resolve_repo(&path)?;
|
||||
let fetch_args = ["fetch"];
|
||||
let output = match (username.as_deref(), password.as_deref()) {
|
||||
(Some(u), Some(p)) if !u.is_empty() || !p.is_empty() => {
|
||||
run_git_authenticated_output(&repo, fetch_args, u, p)?
|
||||
}
|
||||
_ => git_command()
|
||||
.arg("-C")
|
||||
.arg(&repo)
|
||||
.args(fetch_args)
|
||||
.output()
|
||||
.map_err(|err| format!("Could not start Git. Is Git installed? {err}"))?,
|
||||
};
|
||||
|
||||
if output.status.success() {
|
||||
return status_for_repo(&repo);
|
||||
}
|
||||
|
||||
let details = command_output_details(&output);
|
||||
if is_auth_error(&details) {
|
||||
return Err(format!("AUTH_FAILED:{details}"));
|
||||
}
|
||||
Err(format!("Git command failed: {details}"))
|
||||
})
|
||||
.await
|
||||
.map_err(|err| format!("Could not fetch repository: {err}"))?
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn push(
|
||||
path: String,
|
||||
@@ -703,8 +936,7 @@ fn cred_entry(key: &str) -> Result<keyring::Entry, String> {
|
||||
if key.is_empty() {
|
||||
return Err("No key provided for the credentials.".to_string());
|
||||
}
|
||||
keyring::Entry::new(CRED_SERVICE, key)
|
||||
.map_err(|err| format!("Keychain unavailable: {err}"))
|
||||
keyring::Entry::new(CRED_SERVICE, key).map_err(|err| format!("Keychain unavailable: {err}"))
|
||||
}
|
||||
|
||||
/// Returns the remote URL used for auth key derivation (upstream remote of the
|
||||
@@ -790,9 +1022,8 @@ fn initial_push_remote_name(repo: &Path) -> Result<String, String> {
|
||||
return Ok("origin".to_string());
|
||||
}
|
||||
|
||||
first_remote_name(repo).ok_or_else(|| {
|
||||
"This branch has no upstream and no remote is configured.".to_string()
|
||||
})
|
||||
first_remote_name(repo)
|
||||
.ok_or_else(|| "This branch has no upstream and no remote is configured.".to_string())
|
||||
}
|
||||
|
||||
fn push_args_for_repo(repo: &Path) -> Result<Vec<OsString>, String> {
|
||||
@@ -894,6 +1125,72 @@ pub fn merge_branch(path: String, branch: String) -> Result<GitStatus, String> {
|
||||
Err(format!("Merge failed: {details}"))
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn rebase_branch(path: String, branch: String) -> Result<GitStatus, String> {
|
||||
let repo = resolve_repo(&path)?;
|
||||
let branch = branch.trim();
|
||||
if branch.is_empty() {
|
||||
return Err("Branch name must not be empty.".to_string());
|
||||
}
|
||||
|
||||
let output = git_command()
|
||||
.arg("-C")
|
||||
.arg(&repo)
|
||||
.args(["rebase", branch])
|
||||
.output()
|
||||
.map_err(|err| format!("Could not start Git. Is Git installed? {err}"))?;
|
||||
|
||||
rebase_status_or_error(&repo, output, "Rebase failed", true)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn rebase_continue(path: String) -> Result<GitStatus, String> {
|
||||
let repo = resolve_repo(&path)?;
|
||||
if !rebase_in_progress(&repo) {
|
||||
return Err("No rebase is currently in progress.".to_string());
|
||||
}
|
||||
|
||||
let output = git_command()
|
||||
.arg("-C")
|
||||
.arg(&repo)
|
||||
.args(["rebase", "--continue"])
|
||||
.env("GIT_EDITOR", "true")
|
||||
.output()
|
||||
.map_err(|err| format!("Could not start Git. Is Git installed? {err}"))?;
|
||||
|
||||
rebase_status_or_error(&repo, output, "Rebase continue failed", false)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn rebase_abort(path: String) -> Result<GitStatus, String> {
|
||||
let repo = resolve_repo(&path)?;
|
||||
if !rebase_in_progress(&repo) {
|
||||
return Err("No rebase is currently in progress.".to_string());
|
||||
}
|
||||
|
||||
run_git(&repo, ["rebase", "--abort"])?;
|
||||
status_for_repo(&repo)
|
||||
}
|
||||
|
||||
fn rebase_status_or_error(
|
||||
repo: &Path,
|
||||
output: Output,
|
||||
context: &str,
|
||||
ok_if_rebase_in_progress: bool,
|
||||
) -> Result<GitStatus, String> {
|
||||
if output.status.success() {
|
||||
return status_for_repo(repo);
|
||||
}
|
||||
|
||||
let status = status_for_repo(repo)?;
|
||||
if has_unresolved_conflicts(&status) || (ok_if_rebase_in_progress && status.rebase_in_progress)
|
||||
{
|
||||
return Ok(status);
|
||||
}
|
||||
|
||||
Err(format!("{context}: {}", command_output_details(&output)))
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn list_commits(path: String, limit: Option<u32>) -> Result<Vec<GitCommit>, String> {
|
||||
let repo = resolve_repo(&path)?;
|
||||
@@ -913,6 +1210,8 @@ fn commits_for_repo(repo: &Path, limit: Option<u32>) -> Result<Vec<GitCommit>, S
|
||||
repo,
|
||||
[
|
||||
"log",
|
||||
"--all",
|
||||
"--topo-order",
|
||||
"--decorate=short",
|
||||
"--name-status",
|
||||
"-M",
|
||||
@@ -1254,6 +1553,8 @@ pub fn compare_commits(
|
||||
&repo,
|
||||
[
|
||||
"diff",
|
||||
"--no-ext-diff",
|
||||
"--no-textconv",
|
||||
"-M",
|
||||
FULL_FILE_DIFF_CONTEXT,
|
||||
from_hash.as_str(),
|
||||
@@ -1296,7 +1597,14 @@ pub fn diff_file_against_working_tree(
|
||||
)?;
|
||||
let patch_output = run_git_with_paths(
|
||||
&repo,
|
||||
&["diff", "-M", FULL_FILE_DIFF_CONTEXT, commit_hash.as_str()],
|
||||
&[
|
||||
"diff",
|
||||
"--no-ext-diff",
|
||||
"--no-textconv",
|
||||
"-M",
|
||||
FULL_FILE_DIFF_CONTEXT,
|
||||
commit_hash.as_str(),
|
||||
],
|
||||
std::slice::from_ref(&file),
|
||||
)?;
|
||||
|
||||
@@ -1352,6 +1660,8 @@ pub fn compare_file_to_head(
|
||||
&repo,
|
||||
&[
|
||||
"diff",
|
||||
"--no-ext-diff",
|
||||
"--no-textconv",
|
||||
"-M",
|
||||
FULL_FILE_DIFF_CONTEXT,
|
||||
commit_hash.as_str(),
|
||||
@@ -1424,6 +1734,8 @@ pub fn compare_file_to_parent(
|
||||
&repo,
|
||||
&[
|
||||
"diff",
|
||||
"--no-ext-diff",
|
||||
"--no-textconv",
|
||||
"-M",
|
||||
FULL_FILE_DIFF_CONTEXT,
|
||||
from_hash.as_str(),
|
||||
@@ -1713,9 +2025,30 @@ fn status_for_repo(repo: &Path) -> Result<GitStatus, String> {
|
||||
behind: branch.behind,
|
||||
clean: files.is_empty(),
|
||||
files,
|
||||
rebase_in_progress: rebase_in_progress(repo),
|
||||
})
|
||||
}
|
||||
|
||||
fn rebase_in_progress(repo: &Path) -> bool {
|
||||
git_path_exists(repo, "rebase-merge") || git_path_exists(repo, "rebase-apply")
|
||||
}
|
||||
|
||||
fn git_path_exists(repo: &Path, name: &str) -> bool {
|
||||
let Ok(output) = run_git(repo, ["rev-parse", "--git-path", name]) else {
|
||||
return false;
|
||||
};
|
||||
let value = String::from_utf8_lossy(&output).trim().to_string();
|
||||
if value.is_empty() {
|
||||
return false;
|
||||
}
|
||||
let path = PathBuf::from(value);
|
||||
if path.is_absolute() {
|
||||
path.exists()
|
||||
} else {
|
||||
repo.join(path).exists()
|
||||
}
|
||||
}
|
||||
|
||||
// `git status` only auto-detects renames between HEAD and the index (staged changes).
|
||||
// A file renamed on disk but not yet `git add`ed shows up as a plain delete + untracked
|
||||
// pair instead. We detect that case ourselves by comparing content hashes: if an unstaged
|
||||
@@ -2554,9 +2887,7 @@ fn validate_existing_local_branch_name(repo: &Path, branch: &str) -> Result<Stri
|
||||
|
||||
let normalized = validate_branch_ref_name(branch)?;
|
||||
if !ref_exists(repo, &format!("refs/heads/{normalized}"))? {
|
||||
return Err(format!(
|
||||
"Local branch '{normalized}' was not found."
|
||||
));
|
||||
return Err(format!("Local branch '{normalized}' was not found."));
|
||||
}
|
||||
|
||||
Ok(normalized)
|
||||
@@ -2996,8 +3327,8 @@ where
|
||||
thread::sleep(Duration::from_millis(60));
|
||||
};
|
||||
|
||||
let stdout = std::fs::read(&stdout_path)
|
||||
.map_err(|err| format!("Could not read Git output: {err}"))?;
|
||||
let stdout =
|
||||
std::fs::read(&stdout_path).map_err(|err| format!("Could not read Git output: {err}"))?;
|
||||
let stderr = std::fs::read(&stderr_path)
|
||||
.map_err(|err| format!("Could not read Git error output: {err}"))?;
|
||||
let _ = std::fs::remove_file(&stdout_path);
|
||||
@@ -3775,6 +4106,33 @@ mod tests {
|
||||
assert!(comparison.patch.contains("+original"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn commits_for_repo_includes_all_branch_tips_for_graph() {
|
||||
let repo = init_temp_repo("commits_all_branches");
|
||||
commit_initial_file(&repo.path);
|
||||
let base_branch = git_output_test(&repo.path, ["rev-parse", "--abbrev-ref", "HEAD"]);
|
||||
|
||||
run_git_test(&repo.path, ["checkout", "-q", "-b", "feature/graph"]);
|
||||
fs::write(repo.path.join("feature.txt"), "feature\n")
|
||||
.expect("feature file should be written");
|
||||
run_git_test(&repo.path, ["add", "feature.txt"]);
|
||||
run_git_test(&repo.path, ["commit", "-q", "-m", "feature graph"]);
|
||||
let feature_commit = git_output_test(&repo.path, ["rev-parse", "HEAD"]);
|
||||
|
||||
run_git_test(&repo.path, ["checkout", "-q", base_branch.as_str()]);
|
||||
fs::write(repo.path.join("main.txt"), "main\n").expect("main file should be written");
|
||||
run_git_test(&repo.path, ["add", "main.txt"]);
|
||||
run_git_test(&repo.path, ["commit", "-q", "-m", "main graph"]);
|
||||
let main_commit = git_output_test(&repo.path, ["rev-parse", "HEAD"]);
|
||||
|
||||
let commits = commits_for_repo(&repo.path, Some(10)).expect("commits should load");
|
||||
|
||||
assert!(commits.iter().any(|commit| commit.hash == main_commit));
|
||||
assert!(commits.iter().any(|commit| {
|
||||
commit.hash == feature_commit && commit.refs.iter().any(|r| r.contains("feature/graph"))
|
||||
}));
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg_attr(
|
||||
windows,
|
||||
@@ -4169,8 +4527,12 @@ mod tests {
|
||||
let current = git_output_test(&repo.path, ["rev-parse", "--abbrev-ref", "HEAD"]);
|
||||
run_git_test(&repo.path, ["branch", "stale"]);
|
||||
|
||||
let status =
|
||||
delete_branch(repo.path.to_string_lossy().to_string(), "stale".to_string()).unwrap();
|
||||
let status = delete_branch(
|
||||
repo.path.to_string_lossy().to_string(),
|
||||
"stale".to_string(),
|
||||
None,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(status.current_branch.as_deref(), Some(current.as_str()));
|
||||
assert!(
|
||||
@@ -4178,8 +4540,41 @@ mod tests {
|
||||
"deleted branch should be gone"
|
||||
);
|
||||
|
||||
let err = delete_branch(repo.path.to_string_lossy().to_string(), current).unwrap_err();
|
||||
assert!(err.contains("aktuelle Branch"));
|
||||
let err =
|
||||
delete_branch(repo.path.to_string_lossy().to_string(), current, None).unwrap_err();
|
||||
assert!(err.contains("current branch"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn delete_branch_can_force_delete_unmerged_branch() {
|
||||
let repo = init_temp_repo("delete_branch_force");
|
||||
commit_initial_file(&repo.path);
|
||||
let current = git_output_test(&repo.path, ["rev-parse", "--abbrev-ref", "HEAD"]);
|
||||
run_git_test(&repo.path, ["checkout", "-q", "-b", "feature/unmerged"]);
|
||||
fs::write(repo.path.join("feature.txt"), "feature\n")
|
||||
.expect("feature file should be written");
|
||||
run_git_test(&repo.path, ["add", "feature.txt"]);
|
||||
run_git_test(&repo.path, ["commit", "-q", "-m", "feature"]);
|
||||
run_git_test(&repo.path, ["checkout", "-q", current.as_str()]);
|
||||
|
||||
let err = delete_branch(
|
||||
repo.path.to_string_lossy().to_string(),
|
||||
"feature/unmerged".to_string(),
|
||||
Some(false),
|
||||
)
|
||||
.unwrap_err();
|
||||
assert!(err.contains("not fully merged"));
|
||||
|
||||
delete_branch(
|
||||
repo.path.to_string_lossy().to_string(),
|
||||
"feature/unmerged".to_string(),
|
||||
Some(true),
|
||||
)
|
||||
.unwrap();
|
||||
assert!(
|
||||
!ref_exists(&repo.path, "refs/heads/feature/unmerged").unwrap(),
|
||||
"force-deleted branch should be gone"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
+21
-8
@@ -1,17 +1,20 @@
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||
|
||||
mod badge;
|
||||
mod git;
|
||||
|
||||
use badge::set_sync_badge;
|
||||
use git::{
|
||||
SearchCancellationState, apply_file_patch, cancel_code_search, cancel_file_history,
|
||||
checkout_branch, commit, commit_ai_generate, commit_ai_load, commit_ai_local_models,
|
||||
commit_ai_status, compare_commits, compare_file_to_head, compare_file_to_parent,
|
||||
create_branch, cred_delete, cred_load, cred_save, delete_branch,
|
||||
diff_file_against_working_tree, get_file_patch, get_remote_url, get_status, list_branches,
|
||||
list_commits, list_file_history, list_repository_files, merge_branch, open_repo_in_explorer,
|
||||
open_repository, open_repository_bundle, open_repository_file, pull, push, read_conflict,
|
||||
rename_branch, resolve_conflict, resolve_conflict_side, restore_file_from_commit,
|
||||
restore_files, restore_to_commit, search_code_introductions, stage_files, unstage_files,
|
||||
commit_ai_status, compare_commits, compare_file_to_head, compare_file_to_parent, create_branch,
|
||||
cred_delete, cred_load, cred_save, delete_branch, diff_file_against_working_tree, fetch,
|
||||
get_file_patch, get_remote_url, get_status, list_branches, list_commits, list_file_history,
|
||||
list_repository_files, list_stashes, merge_branch, open_repo_in_explorer, open_repository,
|
||||
open_repository_bundle, open_repository_file, pull, push, read_conflict, rebase_abort,
|
||||
rebase_branch, rebase_continue, rename_branch, resolve_conflict, resolve_conflict_side,
|
||||
restore_file_from_commit, restore_files, restore_to_commit, search_code_introductions,
|
||||
stage_files, stash_apply, stash_drop, stash_pop, stash_push, unstage_files,
|
||||
};
|
||||
|
||||
fn main() {
|
||||
@@ -26,12 +29,17 @@ fn main() {
|
||||
open_repository_file,
|
||||
get_status,
|
||||
list_branches,
|
||||
list_stashes,
|
||||
checkout_branch,
|
||||
create_branch,
|
||||
rename_branch,
|
||||
delete_branch,
|
||||
stage_files,
|
||||
unstage_files,
|
||||
stash_push,
|
||||
stash_apply,
|
||||
stash_pop,
|
||||
stash_drop,
|
||||
restore_files,
|
||||
get_file_patch,
|
||||
apply_file_patch,
|
||||
@@ -42,10 +50,14 @@ fn main() {
|
||||
commit_ai_generate,
|
||||
pull,
|
||||
push,
|
||||
fetch,
|
||||
list_commits,
|
||||
restore_to_commit,
|
||||
restore_file_from_commit,
|
||||
merge_branch,
|
||||
rebase_branch,
|
||||
rebase_continue,
|
||||
rebase_abort,
|
||||
list_repository_files,
|
||||
open_repository_bundle,
|
||||
list_file_history,
|
||||
@@ -62,7 +74,8 @@ fn main() {
|
||||
get_remote_url,
|
||||
cred_load,
|
||||
cred_save,
|
||||
cred_delete
|
||||
cred_delete,
|
||||
set_sync_badge
|
||||
])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://schema.tauri.app/config/2",
|
||||
"productName": "GitLite",
|
||||
"version": "2026.7.6",
|
||||
"version": "2026.7.10",
|
||||
"identifier": "com.git-lite",
|
||||
"build": {
|
||||
"beforeDevCommand": "npm run dev",
|
||||
|
||||
+357
-21
@@ -6,6 +6,7 @@
|
||||
|
||||
import TitleBar from "./lib/TitleBar.svelte";
|
||||
import AiSettingsDialog from "./lib/components/AiSettingsDialog.svelte";
|
||||
import BranchDeleteConfirmDialog from "./lib/components/BranchDeleteConfirmDialog.svelte";
|
||||
import BranchPanel from "./lib/components/BranchPanel.svelte";
|
||||
import CommitPanel from "./lib/components/CommitPanel.svelte";
|
||||
import CompareDialog from "./lib/components/CompareDialog.svelte";
|
||||
@@ -21,6 +22,7 @@
|
||||
import RenameBranchDialog from "./lib/components/RenameBranchDialog.svelte";
|
||||
import RepoLoadingOverlay from "./lib/components/RepoLoadingOverlay.svelte";
|
||||
import ResolveDialog from "./lib/components/ResolveDialog.svelte";
|
||||
import StashPanel from "./lib/components/StashPanel.svelte";
|
||||
import StatusPanel from "./lib/components/StatusPanel.svelte";
|
||||
import UpdateToast from "./lib/components/UpdateToast.svelte";
|
||||
|
||||
@@ -39,8 +41,10 @@
|
||||
deleteBranch,
|
||||
diffFileAgainstWorkingTree,
|
||||
compareFileToParent,
|
||||
fetchRemote,
|
||||
getStatus,
|
||||
listBranches,
|
||||
listStashes,
|
||||
listCommits,
|
||||
listFileHistory,
|
||||
listRepositoryFiles,
|
||||
@@ -51,6 +55,9 @@
|
||||
pull,
|
||||
push,
|
||||
renameBranch,
|
||||
rebaseAbort,
|
||||
rebaseBranch,
|
||||
rebaseContinue,
|
||||
getRemoteUrl,
|
||||
credLoad,
|
||||
credSave,
|
||||
@@ -63,7 +70,12 @@
|
||||
restoreFiles,
|
||||
restoreToCommit,
|
||||
searchCodeIntroductions,
|
||||
setSyncBadge,
|
||||
stageFiles,
|
||||
stashApply,
|
||||
stashDrop,
|
||||
stashPop,
|
||||
stashPush,
|
||||
unstageFiles,
|
||||
} from "./lib/git";
|
||||
|
||||
@@ -81,6 +93,7 @@
|
||||
GitFileStatus,
|
||||
GitRepositoryFile,
|
||||
GitSearchHit,
|
||||
GitStash,
|
||||
GitStatus,
|
||||
LocalModelOption,
|
||||
PatchApplyAction,
|
||||
@@ -115,9 +128,13 @@
|
||||
const RECENT_REPOS_KEY = "gitlite.recentRepos.v1";
|
||||
const AI_SETTINGS_KEY = "gitlite.aiSettings.v1";
|
||||
const COMMIT_PANEL_HEIGHT_KEY = "gitlite.commitPanelHeight.v1";
|
||||
const HISTORY_ASIDE_WIDTH_KEY = "gitlite.historyAsideWidth.v1";
|
||||
const COMMIT_PANEL_DEFAULT_HEIGHT = 220;
|
||||
const COMMIT_PANEL_MIN_HEIGHT = COMMIT_PANEL_DEFAULT_HEIGHT;
|
||||
const COMMIT_PANEL_MAX_HEIGHT = 640;
|
||||
const HISTORY_ASIDE_DEFAULT_WIDTH = 620;
|
||||
const HISTORY_ASIDE_MIN_WIDTH = 560;
|
||||
const HISTORY_ASIDE_MAX_WIDTH = 920;
|
||||
|
||||
// ── State ──────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -129,6 +146,7 @@
|
||||
let repoSearch = "";
|
||||
let status: GitStatus | null = null;
|
||||
let branches: GitBranchInfo[] = [];
|
||||
let stashes: GitStash[] = [];
|
||||
let commits: GitCommit[] = [];
|
||||
let repoFiles: GitRepositoryFile[] = [];
|
||||
let selectedExplorerPath = "";
|
||||
@@ -141,6 +159,7 @@
|
||||
let activeFileHistoryRequestId = "";
|
||||
let lastFileHistoryHeadHash = "";
|
||||
let commitMessage = "";
|
||||
let lastLocalAiGeneratedMessage = "";
|
||||
let commitAiPhase: CommitAiPhase = "idle";
|
||||
let commitAiGenerating = false;
|
||||
let commitAiPollTimer: ReturnType<typeof setInterval> | undefined;
|
||||
@@ -154,6 +173,8 @@
|
||||
let comparison: GitCommitComparison | null = null;
|
||||
let newBranchCommit: GitCommit | null = null;
|
||||
let renameBranchTarget: GitBranchInfo | null = null;
|
||||
let deleteBranchTarget: GitBranchInfo | null = null;
|
||||
let deleteBranchForce = false;
|
||||
let compareSelectOpen = false;
|
||||
let compareDialogOpen = false;
|
||||
let selectedDiffPath = "";
|
||||
@@ -179,12 +200,17 @@
|
||||
let autoRefreshEnabled = true;
|
||||
let autoRefreshInFlight = false;
|
||||
let credDialogOpen = false;
|
||||
let credDialogAction: "push" | "pull" | null = null;
|
||||
let credDialogAction: "push" | "pull" | "fetch" | null = null;
|
||||
let credDialogError = "";
|
||||
let credDialogKey: string | null = null;
|
||||
let lastStatusFingerprint = "";
|
||||
const AUTO_REFRESH_INTERVAL = 4000;
|
||||
let autoRefreshTimer: ReturnType<typeof setInterval> | undefined;
|
||||
const BACKGROUND_FETCH_INTERVAL = 180_000;
|
||||
const BACKGROUND_FETCH_AFTER_SWITCH_GRACE_MS = 30_000;
|
||||
let backgroundFetchTimer: ReturnType<typeof setInterval> | undefined;
|
||||
let backgroundFetchInFlight = false;
|
||||
let lastRepoSwitchAt = 0;
|
||||
let updateToastOpen = false;
|
||||
let updateToastState: UpdateToastState = "available";
|
||||
let pendingUpdate: Update | null = null;
|
||||
@@ -199,6 +225,10 @@
|
||||
let resizingCommitPanel = false;
|
||||
let resizeStartY = 0;
|
||||
let resizeStartHeight = 0;
|
||||
let historyAsideWidth = loadHistoryAsideWidth();
|
||||
let resizingHistoryAside = false;
|
||||
let historyResizeStartX = 0;
|
||||
let historyResizeStartWidth = 0;
|
||||
|
||||
// ── Derived ────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -212,12 +242,16 @@
|
||||
$: unstagedCount = status?.files.filter((f) => f.unstaged !== null).length ?? 0;
|
||||
$: conflictedFiles = changedFiles.filter((f) => f.staged === "conflicted" || f.unstaged === "conflicted");
|
||||
$: hasConflicts = conflictedFiles.length > 0;
|
||||
$: canCommit = hasRepository && stagedCount > 0 && commitMessage.trim().length > 0 && !hasConflicts && !isBusy;
|
||||
$: commitBlockReason = hasConflicts
|
||||
? `${conflictedFiles.length} ${conflictedFiles.length === 1 ? "merge conflict must" : "merge conflicts must"} be resolved before committing.`
|
||||
$: rebaseInProgress = status?.rebase_in_progress ?? false;
|
||||
$: canCommit = hasRepository && stagedCount > 0 && commitMessage.trim().length > 0 && !hasConflicts && !rebaseInProgress && !isBusy;
|
||||
$: commitBlockReason = rebaseInProgress
|
||||
? "A rebase is in progress. Resolve conflicts and use Rebase continue or abort the rebase."
|
||||
: hasConflicts
|
||||
? `${conflictedFiles.length} ${conflictedFiles.length === 1 ? "conflict must" : "conflicts must"} be resolved before committing.`
|
||||
: "";
|
||||
$: canCompare = hasRepository && compareFrom.length > 0 && compareTo.length > 0 && compareFrom !== compareTo && !isBusy;
|
||||
$: localBranches = branches.filter((b) => !b.remote);
|
||||
$: localBranchNames = localBranches.map((b) => b.name);
|
||||
$: remoteBranches = branches.filter((b) => b.remote);
|
||||
$: repoSearchTerm = repoSearch.trim().toLowerCase();
|
||||
$: openRepoRows = repoTabs.filter(repoMatchesSearch);
|
||||
@@ -234,12 +268,14 @@
|
||||
onMount(() => {
|
||||
loadRepoLists();
|
||||
autoRefreshTimer = setInterval(() => { void autoRefreshTick(); }, AUTO_REFRESH_INTERVAL);
|
||||
backgroundFetchTimer = setInterval(() => { void backgroundFetchTick(); }, BACKGROUND_FETCH_INTERVAL);
|
||||
void checkForUpdates();
|
||||
void initCommitAi();
|
||||
});
|
||||
|
||||
onDestroy(() => {
|
||||
if (autoRefreshTimer) clearInterval(autoRefreshTimer);
|
||||
if (backgroundFetchTimer) clearInterval(backgroundFetchTimer);
|
||||
if (commitAiPollTimer) clearInterval(commitAiPollTimer);
|
||||
if (activeFileHistoryRequestId) void cancelFileHistory(activeFileHistoryRequestId);
|
||||
});
|
||||
@@ -250,6 +286,23 @@
|
||||
return JSON.stringify({ branch: value.current_branch, upstream: value.upstream, ahead: value.ahead, behind: value.behind, files: value.files });
|
||||
}
|
||||
|
||||
// Silent background fetch (every 180s): only updates the local remote-tracking ref so
|
||||
// ahead/behind (and the taskbar badge) stay accurate without the user pulling manually.
|
||||
// Errors are swallowed here — auth/network failures surface via the manual Fetch/Pull/
|
||||
// Push buttons instead, not as a background popup.
|
||||
async function backgroundFetchTick() {
|
||||
if (!autoRefreshEnabled || activeView !== "repository" || !activeRepoPath || isBusy || backgroundFetchInFlight) return;
|
||||
if (Date.now() - lastRepoSwitchAt < BACKGROUND_FETCH_AFTER_SWITCH_GRACE_MS) return;
|
||||
backgroundFetchInFlight = true;
|
||||
try {
|
||||
await fetchRemote(activeRepoPath);
|
||||
} catch {
|
||||
// ignore — see comment above
|
||||
} finally {
|
||||
backgroundFetchInFlight = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function autoRefreshTick() {
|
||||
if (!autoRefreshEnabled || activeView !== "repository" || !activeRepoPath || isBusy || autoRefreshInFlight || resolveDialogOpen || compareDialogOpen || compareSelectOpen || newBranchCommit || globalSearchOpen) return;
|
||||
autoRefreshInFlight = true;
|
||||
@@ -262,6 +315,7 @@
|
||||
const bundle = await openRepositoryBundle(activeRepoPath, 100);
|
||||
const previousHeadHash = lastFileHistoryHeadHash;
|
||||
await refreshBranchList(activeRepoPath, bundle.branches);
|
||||
await refreshStashes(activeRepoPath, bundle.stashes);
|
||||
await refreshCommitHistory(activeRepoPath, bundle.commits);
|
||||
await refreshExplorerFiles(activeRepoPath, bundle.files);
|
||||
// File history reflects `git log`, which only changes when HEAD actually moves
|
||||
@@ -322,6 +376,13 @@
|
||||
startCommitAiPolling();
|
||||
}
|
||||
|
||||
function updateCommitMessage(message: string) {
|
||||
commitMessage = message;
|
||||
if (message !== lastLocalAiGeneratedMessage) {
|
||||
lastLocalAiGeneratedMessage = "";
|
||||
}
|
||||
}
|
||||
|
||||
async function generateCommitMessageWithAi() {
|
||||
if (!activeRepoPath || commitAiGenerating) return;
|
||||
if (aiSettings.provider === "local" && commitAiPhase !== "ready") return;
|
||||
@@ -330,7 +391,13 @@
|
||||
try {
|
||||
const notes = commitMessage.trim() || undefined;
|
||||
if (aiSettings.provider === "local") {
|
||||
commitMessage = await commitAiGenerate(activeRepoPath, { provider: "local", notes });
|
||||
const localNotes = notes && notes !== lastLocalAiGeneratedMessage ? notes : undefined;
|
||||
commitMessage = await commitAiGenerate(activeRepoPath, {
|
||||
provider: "local",
|
||||
notes: localNotes,
|
||||
localProfile: aiSettings.localProfile,
|
||||
});
|
||||
lastLocalAiGeneratedMessage = commitMessage;
|
||||
} else if (aiSettings.provider === "openai") {
|
||||
const cred = await credLoad("ai:openai");
|
||||
commitMessage = await commitAiGenerate(activeRepoPath, {
|
||||
@@ -339,6 +406,7 @@
|
||||
model: aiSettings.openaiModel,
|
||||
apiKey: cred?.password,
|
||||
});
|
||||
lastLocalAiGeneratedMessage = "";
|
||||
} else if (aiSettings.provider === "anthropic") {
|
||||
const cred = await credLoad("ai:anthropic");
|
||||
commitMessage = await commitAiGenerate(activeRepoPath, {
|
||||
@@ -347,6 +415,7 @@
|
||||
model: aiSettings.anthropicModel,
|
||||
apiKey: cred?.password,
|
||||
});
|
||||
lastLocalAiGeneratedMessage = "";
|
||||
} else {
|
||||
const cred = await credLoad("ai:custom");
|
||||
commitMessage = await commitAiGenerate(activeRepoPath, {
|
||||
@@ -356,6 +425,7 @@
|
||||
baseUrl: aiSettings.customBaseUrl,
|
||||
apiKey: cred?.password,
|
||||
});
|
||||
lastLocalAiGeneratedMessage = "";
|
||||
}
|
||||
} catch (error) {
|
||||
errorMessage = errorToMessage(error);
|
||||
@@ -526,8 +596,9 @@
|
||||
|
||||
function defaultAiSettings(): AiSettings {
|
||||
return {
|
||||
provider: "local",
|
||||
localModelId: "qwen2.5-1.5b",
|
||||
provider: "openai",
|
||||
localModelId: "qwen2.5-0.5b",
|
||||
localProfile: "fast",
|
||||
openaiModel: "gpt-4o-mini",
|
||||
anthropicModel: "claude-3-5-haiku-latest",
|
||||
customBaseUrl: "",
|
||||
@@ -539,7 +610,11 @@
|
||||
try {
|
||||
const stored = JSON.parse(localStorage.getItem(AI_SETTINGS_KEY) ?? "null") as unknown;
|
||||
if (stored && typeof stored === "object") {
|
||||
return { ...defaultAiSettings(), ...(stored as Partial<AiSettings>) };
|
||||
const merged = { ...defaultAiSettings(), ...(stored as Partial<AiSettings>) };
|
||||
// Local AI is still in development and disabled in the settings UI — migrate any
|
||||
// previously saved selection away from it so nobody gets stuck on a dead option.
|
||||
if (merged.provider === "local") merged.provider = "openai";
|
||||
return merged;
|
||||
}
|
||||
} catch {
|
||||
// Fall through to defaults below.
|
||||
@@ -577,6 +652,28 @@
|
||||
}
|
||||
}
|
||||
|
||||
function clampHistoryAsideWidth(value: number): number {
|
||||
return Math.min(HISTORY_ASIDE_MAX_WIDTH, Math.max(HISTORY_ASIDE_MIN_WIDTH, Math.round(value)));
|
||||
}
|
||||
|
||||
function loadHistoryAsideWidth(): number {
|
||||
try {
|
||||
const stored = Number(localStorage.getItem(HISTORY_ASIDE_WIDTH_KEY));
|
||||
if (Number.isFinite(stored) && stored > 0) return clampHistoryAsideWidth(stored);
|
||||
} catch {
|
||||
// Fall through to the default below.
|
||||
}
|
||||
return HISTORY_ASIDE_DEFAULT_WIDTH;
|
||||
}
|
||||
|
||||
function persistHistoryAsideWidth(value: number) {
|
||||
try {
|
||||
localStorage.setItem(HISTORY_ASIDE_WIDTH_KEY, String(value));
|
||||
} catch {
|
||||
// Local storage is best-effort only; resizing must keep working without it.
|
||||
}
|
||||
}
|
||||
|
||||
function startCommitPanelResize(event: PointerEvent) {
|
||||
event.preventDefault();
|
||||
resizingCommitPanel = true;
|
||||
@@ -605,6 +702,34 @@
|
||||
persistCommitPanelHeight(commitPanelHeight);
|
||||
}
|
||||
|
||||
function startHistoryAsideResize(event: PointerEvent) {
|
||||
event.preventDefault();
|
||||
resizingHistoryAside = true;
|
||||
historyResizeStartX = event.clientX;
|
||||
historyResizeStartWidth = historyAsideWidth;
|
||||
(event.currentTarget as HTMLElement).setPointerCapture(event.pointerId);
|
||||
}
|
||||
|
||||
function onHistoryAsideResizeMove(event: PointerEvent) {
|
||||
if (!resizingHistoryAside) return;
|
||||
historyAsideWidth = clampHistoryAsideWidth(historyResizeStartWidth + (historyResizeStartX - event.clientX));
|
||||
}
|
||||
|
||||
function endHistoryAsideResize(event: PointerEvent) {
|
||||
if (!resizingHistoryAside) return;
|
||||
resizingHistoryAside = false;
|
||||
persistHistoryAsideWidth(historyAsideWidth);
|
||||
const target = event.currentTarget as HTMLElement;
|
||||
if (target.hasPointerCapture(event.pointerId)) target.releasePointerCapture(event.pointerId);
|
||||
}
|
||||
|
||||
function onHistoryAsideResizeKeydown(event: KeyboardEvent) {
|
||||
if (event.key !== "ArrowLeft" && event.key !== "ArrowRight") return;
|
||||
event.preventDefault();
|
||||
historyAsideWidth = clampHistoryAsideWidth(historyAsideWidth + (event.key === "ArrowLeft" ? 24 : -24));
|
||||
persistHistoryAsideWidth(historyAsideWidth);
|
||||
}
|
||||
|
||||
function rememberRecentRepo(path: string) {
|
||||
recentRepoPaths = uniqueRepoPaths([path, ...recentRepoPaths]).slice(0, 40);
|
||||
persistRepoLists();
|
||||
@@ -634,8 +759,10 @@
|
||||
repoPath = "";
|
||||
status = null;
|
||||
lastStatusFingerprint = "";
|
||||
void setSyncBadge(0, 0, 0).catch(() => {});
|
||||
}
|
||||
branches = [];
|
||||
stashes = [];
|
||||
commits = [];
|
||||
lastFileHistoryHeadHash = "";
|
||||
repoFiles = [];
|
||||
@@ -653,6 +780,8 @@
|
||||
pendingRestoreFile = null;
|
||||
newBranchCommit = null;
|
||||
globalSearchResults = [];
|
||||
deleteBranchTarget = null;
|
||||
deleteBranchForce = false;
|
||||
globalSearchOpen = false;
|
||||
globalSearchError = "";
|
||||
resolveDialogOpen = false;
|
||||
@@ -667,6 +796,7 @@
|
||||
repoPath = activeRepoPath;
|
||||
lastStatusFingerprint = statusFingerprint(nextStatus);
|
||||
upsertRepoTab(activeRepoPath, nextStatus);
|
||||
void setSyncBadge(nextStatus.ahead, nextStatus.behind, nextStatus.files.length).catch(() => {});
|
||||
}
|
||||
|
||||
function errorToMessage(error: unknown): string {
|
||||
@@ -687,6 +817,11 @@
|
||||
return (value?.files ?? []).some((file) => file.staged === "conflicted" || file.unstaged === "conflicted");
|
||||
}
|
||||
|
||||
function isBranchNotFullyMergedError(message: string): boolean {
|
||||
const value = message.toLowerCase();
|
||||
return value.includes("not fully merged") || value.includes("run 'git branch -d'");
|
||||
}
|
||||
|
||||
async function runOperation(label: string, task: () => Promise<void>) {
|
||||
if (isBusy) return;
|
||||
operation = label;
|
||||
@@ -726,6 +861,10 @@
|
||||
branches = prefetched ?? (await listBranches(path));
|
||||
}
|
||||
|
||||
async function refreshStashes(path = activeRepoPath, prefetched?: GitStash[]) {
|
||||
stashes = prefetched ?? (await listStashes(path));
|
||||
}
|
||||
|
||||
async function refreshCommitHistory(path = activeRepoPath, prefetched?: GitCommit[]) {
|
||||
commits = prefetched ?? (await listCommits(path, 100));
|
||||
lastFileHistoryHeadHash = commits[0]?.hash ?? "";
|
||||
@@ -820,8 +959,10 @@
|
||||
if (globalSearchBusy) void cancelGlobalSearch();
|
||||
activeView = "repository";
|
||||
await refreshBranchList(activeRepoPath, bundle.branches);
|
||||
await refreshStashes(activeRepoPath, bundle.stashes);
|
||||
await refreshCommitHistory(activeRepoPath, bundle.commits);
|
||||
await refreshExplorerFiles(activeRepoPath, bundle.files);
|
||||
lastRepoSwitchAt = Date.now();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -896,6 +1037,7 @@
|
||||
await runOperation("Refreshing", async () => {
|
||||
applyStatus(await getStatus(activeRepoPath));
|
||||
await refreshBranchList(activeRepoPath);
|
||||
await refreshStashes(activeRepoPath);
|
||||
await refreshCommitHistory(activeRepoPath);
|
||||
await refreshExplorerFiles(activeRepoPath);
|
||||
await refreshFileHistory(activeRepoPath);
|
||||
@@ -952,16 +1094,41 @@
|
||||
return;
|
||||
}
|
||||
|
||||
const confirmed = window.confirm(`Delete local branch "${branch.name}"?\n\nGit will refuse if the branch has unmerged changes.`);
|
||||
if (!confirmed) return;
|
||||
deleteBranchTarget = branch;
|
||||
deleteBranchForce = false;
|
||||
}
|
||||
|
||||
await runOperation(`Deleting ${branch.name}`, async () => {
|
||||
applyStatus(await deleteBranch(activeRepoPath, branch.name));
|
||||
async function confirmDeleteBranch() {
|
||||
const branch = deleteBranchTarget;
|
||||
if (!activeRepoPath || !branch || branch.remote || branch.current || isBusy) return;
|
||||
|
||||
operation = `${deleteBranchForce ? "Force deleting" : "Deleting"} ${branch.name}`;
|
||||
errorMessage = "";
|
||||
try {
|
||||
applyStatus(await deleteBranch(activeRepoPath, branch.name, deleteBranchForce));
|
||||
deleteBranchTarget = null;
|
||||
deleteBranchForce = false;
|
||||
await refreshBranchList(activeRepoPath);
|
||||
await refreshCommitHistory(activeRepoPath);
|
||||
await refreshExplorerFiles(activeRepoPath);
|
||||
await refreshFileHistory(activeRepoPath);
|
||||
});
|
||||
} catch (error) {
|
||||
const message = errorToMessage(error);
|
||||
if (deleteBranchForce || !isBranchNotFullyMergedError(message)) {
|
||||
errorMessage = message;
|
||||
return;
|
||||
}
|
||||
|
||||
deleteBranchForce = true;
|
||||
} finally {
|
||||
operation = "";
|
||||
}
|
||||
}
|
||||
|
||||
function closeDeleteBranchDialog() {
|
||||
if (isBusy) return;
|
||||
deleteBranchTarget = null;
|
||||
deleteBranchForce = false;
|
||||
}
|
||||
|
||||
function openNewBranchDialog(commit: GitCommit) {
|
||||
@@ -994,6 +1161,46 @@
|
||||
});
|
||||
}
|
||||
|
||||
async function rebaseOnto(branch: GitBranchInfo) {
|
||||
if (!activeRepoPath || branch.current || rebaseInProgress) return;
|
||||
await runOperation(`Rebasing onto ${branch.name}`, async () => {
|
||||
applyStatus(await rebaseBranch(activeRepoPath, branch.name));
|
||||
await refreshBranchList(activeRepoPath);
|
||||
await refreshCommitHistory(activeRepoPath);
|
||||
await refreshExplorerFiles(activeRepoPath);
|
||||
await refreshFileHistory(activeRepoPath);
|
||||
});
|
||||
}
|
||||
|
||||
async function continueRebase() {
|
||||
if (!activeRepoPath || !rebaseInProgress || hasConflicts) return;
|
||||
await runOperation("Continuing rebase", async () => {
|
||||
applyStatus(await rebaseContinue(activeRepoPath));
|
||||
await refreshBranchList(activeRepoPath);
|
||||
await refreshCommitHistory(activeRepoPath);
|
||||
await refreshExplorerFiles(activeRepoPath);
|
||||
await refreshFileHistory(activeRepoPath);
|
||||
});
|
||||
}
|
||||
|
||||
async function abortRebase() {
|
||||
if (!activeRepoPath || !rebaseInProgress) return;
|
||||
const confirmed = window.confirm("Abort the current rebase and return to the previous state?");
|
||||
if (!confirmed) return;
|
||||
|
||||
await runOperation("Aborting rebase", async () => {
|
||||
applyStatus(await rebaseAbort(activeRepoPath));
|
||||
preparedResolutions = {};
|
||||
resolveDialogOpen = false;
|
||||
conflict = null;
|
||||
conflictTarget = "";
|
||||
await refreshBranchList(activeRepoPath);
|
||||
await refreshCommitHistory(activeRepoPath);
|
||||
await refreshExplorerFiles(activeRepoPath);
|
||||
await refreshFileHistory(activeRepoPath);
|
||||
});
|
||||
}
|
||||
|
||||
// Resolve the keychain key (host/org) for the active repo's remote.
|
||||
async function currentCredKey(): Promise<string | null> {
|
||||
if (!activeRepoPath) return null;
|
||||
@@ -1014,7 +1221,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function openCredentialDialog(action: "push" | "pull", key?: string | null) {
|
||||
async function openCredentialDialog(action: "push" | "pull" | "fetch", key?: string | null) {
|
||||
if (!activeRepoPath) return;
|
||||
credDialogError = "";
|
||||
credDialogAction = action;
|
||||
@@ -1024,7 +1231,7 @@
|
||||
|
||||
// Post-process a pull/push result: surface errors, and on rejected/expired
|
||||
// credentials drop the stored entry and re-open the login dialog.
|
||||
function handleRemoteResult(action: "push" | "pull", key: string | null, fromStore: boolean) {
|
||||
function handleRemoteResult(action: "push" | "pull" | "fetch", key: string | null, fromStore: boolean) {
|
||||
if (!errorMessage) {
|
||||
credDialogOpen = false;
|
||||
credDialogAction = null;
|
||||
@@ -1068,6 +1275,19 @@
|
||||
handleRemoteResult("pull", key, fromStore);
|
||||
}
|
||||
|
||||
async function doActualFetch(
|
||||
username: string,
|
||||
password: string,
|
||||
key: string | null,
|
||||
fromStore: boolean,
|
||||
) {
|
||||
errorMessage = "";
|
||||
await runOperation("Fetching", async () => {
|
||||
applyStatus(await fetchRemote(activeRepoPath, username, password));
|
||||
});
|
||||
handleRemoteResult("fetch", key, fromStore);
|
||||
}
|
||||
|
||||
async function doActualPush(
|
||||
username: string,
|
||||
password: string,
|
||||
@@ -1137,6 +1357,7 @@
|
||||
const key = credDialogKey;
|
||||
if (credDialogAction === "pull") await doActualPull(username, password, key, false);
|
||||
else if (credDialogAction === "push") await doActualPush(username, password, key, false);
|
||||
else if (credDialogAction === "fetch") await doActualFetch(username, password, key, false);
|
||||
|
||||
// Only persist once the operation actually succeeded (dialog has closed).
|
||||
if (!credDialogOpen && save && key) {
|
||||
@@ -1148,13 +1369,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function startRemoteAction(action: "push" | "pull") {
|
||||
async function startRemoteAction(action: "push" | "pull" | "fetch") {
|
||||
if (!activeRepoPath) return;
|
||||
const key = await currentCredKey();
|
||||
const stored = await loadStoredCredential(key);
|
||||
|
||||
if (stored && !isCredentialExpired(stored)) {
|
||||
if (action === "pull") await doActualPull(stored.username, stored.password, key, true);
|
||||
else if (action === "fetch") await doActualFetch(stored.username, stored.password, key, true);
|
||||
else await doActualPush(stored.username, stored.password, key, true);
|
||||
return;
|
||||
}
|
||||
@@ -1164,6 +1386,10 @@
|
||||
await openCredentialDialog(action, key);
|
||||
}
|
||||
|
||||
async function fetchRepo() {
|
||||
await startRemoteAction("fetch");
|
||||
}
|
||||
|
||||
async function pullRepo() {
|
||||
await startRemoteAction("pull");
|
||||
}
|
||||
@@ -1172,6 +1398,47 @@
|
||||
await startRemoteAction("push");
|
||||
}
|
||||
|
||||
async function saveStash(message: string, includeUntracked: boolean) {
|
||||
if (!activeRepoPath || changedFiles.length === 0) return;
|
||||
await runOperation("Stashing changes", async () => {
|
||||
applyStatus(await stashPush(activeRepoPath, message, includeUntracked));
|
||||
await refreshStashes(activeRepoPath);
|
||||
await refreshExplorerFiles(activeRepoPath);
|
||||
await refreshFileHistory(activeRepoPath);
|
||||
});
|
||||
}
|
||||
|
||||
async function applyStashEntry(stash: GitStash) {
|
||||
if (!activeRepoPath) return;
|
||||
await runOperation(`Applying ${stash.selector}`, async () => {
|
||||
applyStatus(await stashApply(activeRepoPath, stash.selector));
|
||||
await refreshStashes(activeRepoPath);
|
||||
await refreshExplorerFiles(activeRepoPath);
|
||||
await refreshFileHistory(activeRepoPath);
|
||||
});
|
||||
}
|
||||
|
||||
async function popStashEntry(stash: GitStash) {
|
||||
if (!activeRepoPath) return;
|
||||
await runOperation(`Popping ${stash.selector}`, async () => {
|
||||
applyStatus(await stashPop(activeRepoPath, stash.selector));
|
||||
await refreshStashes(activeRepoPath);
|
||||
await refreshExplorerFiles(activeRepoPath);
|
||||
await refreshFileHistory(activeRepoPath);
|
||||
});
|
||||
}
|
||||
|
||||
async function dropStashEntry(stash: GitStash) {
|
||||
if (!activeRepoPath) return;
|
||||
const confirmed = window.confirm(`Delete ${stash.selector}?\n\n"${stash.message || stash.selector}"`);
|
||||
if (!confirmed) return;
|
||||
|
||||
await runOperation(`Dropping ${stash.selector}`, async () => {
|
||||
applyStatus(await stashDrop(activeRepoPath, stash.selector));
|
||||
await refreshStashes(activeRepoPath);
|
||||
});
|
||||
}
|
||||
|
||||
// ── File staging / restore ─────────────────────────────────────────────────
|
||||
|
||||
async function stageFile(file: GitFileStatus) {
|
||||
@@ -1333,12 +1600,17 @@
|
||||
const message = commitMessage.trim();
|
||||
if (!message || !activeRepoPath) return;
|
||||
if (hasConflicts) {
|
||||
errorMessage = "Resolve all merge conflicts before committing.";
|
||||
errorMessage = "Resolve all conflicts before committing.";
|
||||
return;
|
||||
}
|
||||
if (rebaseInProgress) {
|
||||
errorMessage = "A rebase is in progress. Use Rebase continue or abort the rebase.";
|
||||
return;
|
||||
}
|
||||
await runOperation("Committing", async () => {
|
||||
applyStatus(await commit(activeRepoPath, message));
|
||||
commitMessage = "";
|
||||
lastLocalAiGeneratedMessage = "";
|
||||
await refreshBranchList(activeRepoPath);
|
||||
await refreshCommitHistory(activeRepoPath);
|
||||
await refreshExplorerFiles(activeRepoPath);
|
||||
@@ -1644,6 +1916,7 @@
|
||||
else if (event.key === "Escape" && compareDialogOpen) closeCompareDialog();
|
||||
else if (event.key === "Escape" && newBranchCommit) newBranchCommit = null;
|
||||
else if (event.key === "Escape" && renameBranchTarget) renameBranchTarget = null;
|
||||
else if (event.key === "Escape" && deleteBranchTarget) closeDeleteBranchDialog();
|
||||
else if (event.key === "Escape" && compareSelectOpen) compareSelectOpen = false;
|
||||
else if (event.key === "Escape" && globalSearchOpen) closeGlobalSearchDialog();
|
||||
}
|
||||
@@ -1670,6 +1943,7 @@
|
||||
{operation}
|
||||
{autoRefreshEnabled}
|
||||
{autoRefreshInFlight}
|
||||
onFetch={fetchRepo}
|
||||
onPull={pullRepo}
|
||||
onPush={pushRepo}
|
||||
onRefresh={refreshRepo}
|
||||
@@ -1751,14 +2025,33 @@
|
||||
</section>
|
||||
{/if}
|
||||
|
||||
{#if workspaceActive && hasConflicts}
|
||||
{#if workspaceActive && hasConflicts && !rebaseInProgress}
|
||||
<section class="notice conflict" role="alert">
|
||||
<GitMerge size={17} aria-hidden="true" />
|
||||
<span>{conflictedFiles.length} {conflictedFiles.length === 1 ? "file has" : "files have"} merge conflicts.</span>
|
||||
<span>{conflictedFiles.length} {conflictedFiles.length === 1 ? "file has" : "files have"} conflicts.</span>
|
||||
<button type="button" onclick={openResolveDialog} disabled={isBusy}>Resolve conflicts</button>
|
||||
</section>
|
||||
{/if}
|
||||
|
||||
{#if workspaceActive && rebaseInProgress}
|
||||
<section class="notice rebase" role="status">
|
||||
<GitBranch size={17} aria-hidden="true" />
|
||||
<span>
|
||||
Rebase in progress.
|
||||
{#if hasConflicts}
|
||||
Resolve conflicts, then continue.
|
||||
{:else}
|
||||
Continue when the index is ready, or abort to return to the previous state.
|
||||
{/if}
|
||||
</span>
|
||||
{#if hasConflicts}
|
||||
<button type="button" onclick={openResolveDialog} disabled={isBusy}>Resolve conflicts</button>
|
||||
{/if}
|
||||
<button type="button" onclick={continueRebase} disabled={isBusy || hasConflicts}>Continue</button>
|
||||
<button type="button" onclick={abortRebase} disabled={isBusy}>Abort</button>
|
||||
</section>
|
||||
{/if}
|
||||
|
||||
{#if activeView === "management"}
|
||||
<section class="repo-management" aria-label="Repository Management">
|
||||
<div class="repo-management-head">
|
||||
@@ -1873,7 +2166,7 @@
|
||||
</section>
|
||||
{:else}
|
||||
<!-- Workspace -->
|
||||
<section class="workspace" aria-label="Git workspace">
|
||||
<section class="workspace" aria-label="Git workspace" style="--history-aside-width: {historyAsideWidth}px;">
|
||||
|
||||
<!-- Left sidebar: branches + explorer -->
|
||||
<aside class="left-sidebar" aria-label="Repository navigation">
|
||||
@@ -1885,10 +2178,21 @@
|
||||
{isBusy}
|
||||
onCheckout={checkout}
|
||||
onMerge={merge}
|
||||
onRebase={rebaseOnto}
|
||||
onCreateBranch={createNewBranch}
|
||||
onRenameBranch={renameLocalBranch}
|
||||
onDeleteBranch={deleteLocalBranch}
|
||||
/>
|
||||
<StashPanel
|
||||
{stashes}
|
||||
changedCount={changedFiles.length}
|
||||
{hasRepository}
|
||||
{isBusy}
|
||||
onPush={saveStash}
|
||||
onApply={applyStashEntry}
|
||||
onPop={popStashEntry}
|
||||
onDrop={dropStashEntry}
|
||||
/>
|
||||
<ExplorerPanel
|
||||
{repoFiles}
|
||||
{expandedExplorerPaths}
|
||||
@@ -1968,7 +2272,7 @@
|
||||
{commitAiPhase}
|
||||
{commitAiGenerating}
|
||||
onCommit={commitChanges}
|
||||
onCommitMessageChange={(msg) => { commitMessage = msg; }}
|
||||
onCommitMessageChange={updateCommitMessage}
|
||||
onGenerateCommitMessage={generateCommitMessageWithAi}
|
||||
onOpenAiSettings={() => { aiSettingsOpen = true; }}
|
||||
/>
|
||||
@@ -1977,8 +2281,29 @@
|
||||
|
||||
<!-- Right sidebar: commit graph + file history -->
|
||||
<aside class="history-aside" aria-label="Commit history">
|
||||
<!-- svelte-ignore a11y_no_noninteractive_tabindex -->
|
||||
<!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
|
||||
<div
|
||||
class="history-resize-handle"
|
||||
class:resizing={resizingHistoryAside}
|
||||
role="separator"
|
||||
aria-orientation="vertical"
|
||||
aria-label="Resize history panel width"
|
||||
aria-valuenow={historyAsideWidth}
|
||||
aria-valuemin={HISTORY_ASIDE_MIN_WIDTH}
|
||||
aria-valuemax={HISTORY_ASIDE_MAX_WIDTH}
|
||||
tabindex="0"
|
||||
onpointerdown={startHistoryAsideResize}
|
||||
onpointermove={onHistoryAsideResizeMove}
|
||||
onpointerup={endHistoryAsideResize}
|
||||
onpointercancel={endHistoryAsideResize}
|
||||
onkeydown={onHistoryAsideResizeKeydown}
|
||||
></div>
|
||||
<HistoryPanel
|
||||
{commits}
|
||||
{localBranchNames}
|
||||
activeBranch={status?.current_branch ?? ""}
|
||||
repositoryKey={activeRepoPath}
|
||||
{hasRepository}
|
||||
{isBusy}
|
||||
{expandedCommitHashes}
|
||||
@@ -2085,6 +2410,17 @@
|
||||
/>
|
||||
{/if}
|
||||
|
||||
<!-- Delete a local branch from the branch context menu -->
|
||||
{#if deleteBranchTarget}
|
||||
<BranchDeleteConfirmDialog
|
||||
branch={deleteBranchTarget}
|
||||
force={deleteBranchForce}
|
||||
{isBusy}
|
||||
onConfirm={confirmDeleteBranch}
|
||||
onClose={closeDeleteBranchDialog}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
<!-- Choose the AI provider/model used to generate commit messages -->
|
||||
{#if aiSettingsOpen}
|
||||
<AiSettingsDialog
|
||||
|
||||
+756
-27
@@ -187,6 +187,199 @@
|
||||
}
|
||||
.section-head h2 { margin: 1px 0 0; color: var(--color-ink); font-size: 14px; line-height: 1.2; font-weight: 600; }
|
||||
|
||||
.section-head-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex: 0 0 auto;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.graph-branch-dialog-button {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
min-height: 26px;
|
||||
padding: 0 9px;
|
||||
overflow: hidden;
|
||||
border: 1px solid rgba(91,209,138,0.24);
|
||||
border-radius: 999px;
|
||||
color: #b6f1c4;
|
||||
background: rgba(34,68,48,0.28);
|
||||
font-size: 11px;
|
||||
font-weight: 800;
|
||||
white-space: nowrap;
|
||||
transition: border-color 120ms ease, background 120ms ease, color 120ms ease;
|
||||
}
|
||||
|
||||
.graph-branch-dialog-button:hover {
|
||||
border-color: rgba(91,209,138,0.42);
|
||||
background: rgba(34,68,48,0.42);
|
||||
}
|
||||
|
||||
.graph-branch-dialog-button span {
|
||||
padding: 1px 5px;
|
||||
border-radius: 999px;
|
||||
color: #061021;
|
||||
background: #6ce18f;
|
||||
font-size: 10px;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.branch-filter-backdrop {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 80;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
padding: 24px;
|
||||
background: rgba(4,8,18,0.58);
|
||||
backdrop-filter: blur(8px);
|
||||
}
|
||||
|
||||
.branch-filter-dialog {
|
||||
display: grid;
|
||||
grid-template-rows: auto auto minmax(0, 1fr);
|
||||
width: min(520px, 100%);
|
||||
max-height: min(680px, calc(100vh - 48px));
|
||||
overflow: hidden;
|
||||
border: 1px solid rgba(94,110,156,0.24);
|
||||
border-radius: 10px;
|
||||
background:
|
||||
linear-gradient(180deg, rgba(255,255,255,0.045), transparent 70%),
|
||||
var(--color-surface);
|
||||
box-shadow: 0 24px 80px rgba(0,0,0,0.42), inset 0 1px 0 rgba(255,255,255,0.05);
|
||||
}
|
||||
|
||||
.branch-filter-dialog-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
padding: 14px 14px 12px;
|
||||
border-bottom: 1px solid var(--color-border-subtle);
|
||||
background: linear-gradient(90deg, rgba(100,108,255,0.12), rgba(65,209,255,0.04));
|
||||
}
|
||||
|
||||
.branch-filter-dialog-head h3 {
|
||||
margin: 1px 0 0;
|
||||
color: var(--color-ink);
|
||||
font-size: 16px;
|
||||
font-weight: 750;
|
||||
}
|
||||
|
||||
.dialog-icon-button {
|
||||
display: inline-grid;
|
||||
place-items: center;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
padding: 0;
|
||||
border: 1px solid rgba(94,110,156,0.18);
|
||||
border-radius: 7px;
|
||||
color: var(--color-ink-dim);
|
||||
background: rgba(255,255,255,0.035);
|
||||
}
|
||||
|
||||
.dialog-icon-button:hover {
|
||||
color: var(--color-ink);
|
||||
border-color: rgba(65,209,255,0.28);
|
||||
background: rgba(65,209,255,0.08);
|
||||
}
|
||||
|
||||
.branch-filter-summary {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
padding: 10px 14px;
|
||||
border-bottom: 1px solid var(--color-border-subtle);
|
||||
color: var(--color-ink-dim);
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.branch-filter-actions {
|
||||
display: inline-flex;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.branch-filter-actions button {
|
||||
min-height: 24px;
|
||||
padding: 0 8px;
|
||||
border-color: rgba(94,110,156,0.16);
|
||||
border-radius: 999px;
|
||||
color: var(--color-ink-dim);
|
||||
background: rgba(255,255,255,0.035);
|
||||
font-size: 10.5px;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.branch-filter-actions button:hover:not(:disabled) {
|
||||
border-color: rgba(65,209,255,0.28);
|
||||
color: var(--color-ink);
|
||||
background: rgba(65,209,255,0.08);
|
||||
}
|
||||
|
||||
.branch-filter-actions button:disabled {
|
||||
cursor: default;
|
||||
opacity: 0.45;
|
||||
}
|
||||
|
||||
.branch-filter-dialog-list {
|
||||
display: grid;
|
||||
align-content: start;
|
||||
gap: 4px;
|
||||
min-height: 0;
|
||||
padding: 8px;
|
||||
overflow: auto;
|
||||
scrollbar-width: thin;
|
||||
}
|
||||
|
||||
.branch-filter-option {
|
||||
display: grid;
|
||||
grid-template-columns: 16px 16px minmax(0, 1fr);
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-height: 32px;
|
||||
padding: 0 9px;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 7px;
|
||||
color: #a8eeba;
|
||||
background: transparent;
|
||||
cursor: pointer;
|
||||
font-size: 12px;
|
||||
font-weight: 750;
|
||||
}
|
||||
|
||||
.branch-filter-option:hover {
|
||||
border-color: rgba(91,209,138,0.18);
|
||||
background: rgba(34,68,48,0.22);
|
||||
}
|
||||
|
||||
.branch-filter-option.muted {
|
||||
color: var(--color-ink-faint);
|
||||
opacity: 0.72;
|
||||
}
|
||||
|
||||
.branch-filter-option input {
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
accent-color: #6ce18f;
|
||||
}
|
||||
|
||||
.branch-filter-option svg {
|
||||
color: currentColor;
|
||||
}
|
||||
|
||||
.branch-filter-option span {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
font-family: var(--font-mono);
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.eyebrow {
|
||||
display: block;
|
||||
color: var(--color-ink-faint);
|
||||
@@ -669,6 +862,8 @@
|
||||
.notice.error { border-color: rgba(232,96,90,0.3); color: #f09090; background: rgba(232,96,90,0.08); }
|
||||
.notice.busy { border-color: rgba(90,140,248,0.28); color: #8ab0f8; background: rgba(90,140,248,0.07); }
|
||||
.notice.conflict { border-color: rgba(224,160,64,0.3); color: #e8b060; background: rgba(224,160,64,0.07); }
|
||||
.notice.rebase { flex-wrap: wrap; border-color: rgba(186,130,255,0.3); color: #c9a8ff; background: rgba(186,130,255,0.075); }
|
||||
.notice.rebase span { min-width: 0; flex: 1 1 auto; }
|
||||
.notice.conflict button {
|
||||
margin-left: auto;
|
||||
min-height: 26px;
|
||||
@@ -684,6 +879,20 @@
|
||||
border-color: rgba(224,160,64,0.45);
|
||||
color: #f0c070;
|
||||
}
|
||||
.notice.rebase button {
|
||||
min-height: 26px;
|
||||
padding: 0 10px;
|
||||
border-color: rgba(186,130,255,0.28);
|
||||
color: #d5bdff;
|
||||
background: rgba(186,130,255,0.1);
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
}
|
||||
.notice.rebase button:hover:not(:disabled) {
|
||||
background: rgba(186,130,255,0.18);
|
||||
border-color: rgba(186,130,255,0.45);
|
||||
color: #eadfff;
|
||||
}
|
||||
|
||||
/* --- Update toast --- */
|
||||
|
||||
@@ -862,7 +1071,7 @@
|
||||
|
||||
.workspace {
|
||||
display: grid;
|
||||
grid-template-columns: clamp(220px, 18vw, 280px) minmax(0, 1fr) clamp(400px, 40vw, 620px);
|
||||
grid-template-columns: clamp(220px, 18vw, 280px) minmax(0, 1fr) minmax(560px, var(--history-aside-width, 620px));
|
||||
flex: 1 1 0;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
@@ -870,21 +1079,57 @@
|
||||
}
|
||||
|
||||
.history-aside {
|
||||
position: relative;
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
|
||||
grid-template-columns: minmax(0, 1fr) 300px;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.history-resize-handle {
|
||||
position: absolute;
|
||||
z-index: 20;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: -7px;
|
||||
width: 12px;
|
||||
cursor: col-resize;
|
||||
touch-action: none;
|
||||
}
|
||||
.history-resize-handle::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 12px;
|
||||
bottom: 12px;
|
||||
left: 5px;
|
||||
width: 2px;
|
||||
border-radius: 999px;
|
||||
background: transparent;
|
||||
transition: background 120ms ease, box-shadow 120ms ease;
|
||||
}
|
||||
.history-resize-handle:hover::before,
|
||||
.history-resize-handle.resizing::before {
|
||||
background: rgba(65,209,255,0.62);
|
||||
box-shadow: 0 0 14px rgba(65,209,255,0.3);
|
||||
}
|
||||
.history-resize-handle:focus-visible {
|
||||
outline: 2px solid var(--color-primary);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
.left-sidebar {
|
||||
display: grid;
|
||||
grid-template-rows: minmax(200px, 0.9fr) minmax(240px, 1.1fr);
|
||||
grid-template-rows: minmax(170px, 0.75fr) minmax(150px, 0.55fr) minmax(220px, 1fr);
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.left-sidebar:has(.stash-panel.collapsed) {
|
||||
grid-template-rows: minmax(170px, 0.85fr) auto minmax(220px, 1.15fr);
|
||||
}
|
||||
|
||||
/* --- Main panel --- */
|
||||
|
||||
.main-panel {
|
||||
@@ -1044,6 +1289,158 @@
|
||||
background: var(--color-surface-dim);
|
||||
}
|
||||
|
||||
/* --- Stash panel --- */
|
||||
|
||||
.stash-panel {
|
||||
display: grid;
|
||||
grid-template-rows: auto auto minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.stash-panel.collapsed {
|
||||
grid-template-rows: auto;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.stash-head-actions {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.stash-toggle {
|
||||
display: inline-grid;
|
||||
place-items: center;
|
||||
width: 26px;
|
||||
min-width: 26px;
|
||||
min-height: 26px;
|
||||
padding: 0;
|
||||
border-color: rgba(94,110,156,0.18);
|
||||
border-radius: 7px;
|
||||
color: var(--color-ink-dim);
|
||||
background: rgba(255,255,255,0.035);
|
||||
}
|
||||
|
||||
.stash-toggle:hover:not(:disabled) {
|
||||
border-color: rgba(65,209,255,0.28);
|
||||
color: var(--color-ink);
|
||||
background: rgba(65,209,255,0.08);
|
||||
}
|
||||
|
||||
.stash-create {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) auto auto;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 7px;
|
||||
border-bottom: 1px solid var(--color-border-subtle);
|
||||
background: var(--color-surface-dim);
|
||||
}
|
||||
|
||||
.stash-input {
|
||||
min-width: 0;
|
||||
height: 28px;
|
||||
padding: 0 8px;
|
||||
border: 1px solid var(--color-border-subtle);
|
||||
border-radius: 7px;
|
||||
color: var(--color-ink);
|
||||
background: rgba(255,255,255,0.035);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.stash-input:focus {
|
||||
border-color: rgba(65,209,255,0.42);
|
||||
outline: none;
|
||||
box-shadow: 0 0 0 2px rgba(65,209,255,0.1);
|
||||
}
|
||||
|
||||
.stash-check {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
color: var(--color-ink-dim);
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.stash-check input {
|
||||
width: 13px;
|
||||
height: 13px;
|
||||
accent-color: var(--color-accent);
|
||||
}
|
||||
|
||||
.stash-save-button {
|
||||
border-color: rgba(65,209,255,0.18);
|
||||
color: var(--color-ink);
|
||||
background: rgba(65,209,255,0.075);
|
||||
}
|
||||
|
||||
.stash-list {
|
||||
display: grid;
|
||||
align-content: start;
|
||||
gap: 6px;
|
||||
min-height: 0;
|
||||
padding: 7px;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.stash-empty {
|
||||
min-height: 48px;
|
||||
}
|
||||
|
||||
.stash-row {
|
||||
display: grid;
|
||||
gap: 7px;
|
||||
padding: 8px;
|
||||
border: 1px solid var(--color-border-subtle);
|
||||
border-radius: 8px;
|
||||
background: var(--color-surface-raised);
|
||||
}
|
||||
|
||||
.stash-row-main {
|
||||
display: grid;
|
||||
gap: 2px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.stash-row-main strong,
|
||||
.stash-row-main span {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.stash-row-main strong {
|
||||
color: var(--color-ink);
|
||||
font-size: 12px;
|
||||
font-weight: 750;
|
||||
}
|
||||
|
||||
.stash-row-main span {
|
||||
color: var(--color-ink-faint);
|
||||
font-family: var(--font-mono);
|
||||
font-size: 10.5px;
|
||||
}
|
||||
|
||||
.stash-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 5px;
|
||||
}
|
||||
|
||||
.btn-sm.danger {
|
||||
border-color: rgba(232,96,96,0.2);
|
||||
color: #ef9b9b;
|
||||
background: rgba(232,96,96,0.08);
|
||||
}
|
||||
|
||||
.btn-sm.danger:hover:not(:disabled) {
|
||||
border-color: rgba(232,96,96,0.38);
|
||||
color: #ffd2d2;
|
||||
background: rgba(232,96,96,0.14);
|
||||
}
|
||||
|
||||
/* --- Branch list --- */
|
||||
|
||||
.branch-head-actions {
|
||||
@@ -1238,7 +1635,8 @@
|
||||
.branch-info strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--color-ink); }
|
||||
.branch-info span { display: block; margin-top: 2px; color: var(--color-ink-dim); font-size: 11px; }
|
||||
|
||||
.branch-actions { display: flex; align-items: center; justify-content: flex-end; gap: 5px; }
|
||||
.branch-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 5px; }
|
||||
.branch-actions .btn-sm { min-height: 24px; padding: 0 6px; font-size: 11px; }
|
||||
|
||||
.branch-context-menu,
|
||||
.explorer-context-menu {
|
||||
@@ -1281,6 +1679,12 @@
|
||||
color: var(--color-ink);
|
||||
}
|
||||
|
||||
.branch-context-menu .menu-separator {
|
||||
height: 1px;
|
||||
margin: 4px 3px;
|
||||
background: var(--color-border-subtle);
|
||||
}
|
||||
|
||||
.branch-context-menu button.danger {
|
||||
color: #ff9aa8;
|
||||
}
|
||||
@@ -1427,19 +1831,190 @@
|
||||
.commit-line strong { display: block; overflow: hidden; color: var(--color-ink); font-size: 13px; line-height: 1.3; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.commit-line span { display: block; overflow: hidden; margin-top: 3px; color: var(--color-ink-dim); font-family: var(--font-mono); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
|
||||
|
||||
.ref-list { display: flex; flex-wrap: wrap; gap: 4px; }
|
||||
.ref-list span { max-width: 100%; overflow: hidden; padding: 2px 7px; border-radius: 999px; color: var(--color-accent); background: rgba(106,154,255,0.13); border: 1px solid rgba(106,154,255,0.22); font-size: 10.5px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.commit-card-head {
|
||||
display: grid;
|
||||
grid-template-columns: auto minmax(0, 1fr);
|
||||
align-items: center;
|
||||
gap: 7px;
|
||||
min-width: 0;
|
||||
}
|
||||
.commit-avatar {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
border: 1px solid rgba(122,172,255,0.18);
|
||||
border-radius: 999px;
|
||||
color: #b8c5df;
|
||||
background: rgba(18, 22, 38, 0.72);
|
||||
font-size: 9px;
|
||||
font-weight: 800;
|
||||
}
|
||||
.commit-card-main { display: grid; gap: 2px; min-width: 0; }
|
||||
.commit-title-row {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) auto;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
}
|
||||
.commit-summary {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
color: #edf2ff;
|
||||
font-size: 12.5px;
|
||||
font-weight: 700;
|
||||
line-height: 1.2;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.commit-kind {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 3px;
|
||||
min-width: 0;
|
||||
padding: 1px 5px;
|
||||
border: 1px solid rgba(94,110,156,0.18);
|
||||
border-radius: 999px;
|
||||
color: var(--color-ink-dim);
|
||||
background: rgba(255,255,255,0.025);
|
||||
font-size: 9px;
|
||||
font-weight: 800;
|
||||
line-height: 1.3;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.commit-kind.merge { color: #dca6da; border-color: rgba(208,96,192,0.24); background: rgba(208,96,192,0.07); }
|
||||
.commit-kind.root { color: #d7b66b; border-color: rgba(224,180,92,0.22); background: rgba(224,180,92,0.07); }
|
||||
.commit-meta-line {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
color: var(--color-ink-faint);
|
||||
font-size: 10.5px;
|
||||
}
|
||||
.commit-meta-line > * { min-width: 0; }
|
||||
.commit-hash {
|
||||
flex: 0 0 auto;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
color: #8db8ff;
|
||||
background: transparent;
|
||||
font-family: var(--font-mono);
|
||||
font-size: 10.5px;
|
||||
font-weight: 700;
|
||||
}
|
||||
.commit-local-branches {
|
||||
display: inline-flex;
|
||||
flex: 0 1 auto;
|
||||
flex-wrap: wrap;
|
||||
gap: 3px;
|
||||
min-width: 0;
|
||||
max-width: min(100%, 260px);
|
||||
}
|
||||
.commit-branch-chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 3px;
|
||||
min-width: 0;
|
||||
max-width: 100%;
|
||||
height: 17px;
|
||||
padding: 0 6px 0 5px;
|
||||
overflow: hidden;
|
||||
border: 1px solid rgba(91,209,138,0.22);
|
||||
border-radius: 999px;
|
||||
color: #a8eeba;
|
||||
background: rgba(34,68,48,0.42);
|
||||
font-family: var(--font-mono);
|
||||
font-size: 9.5px;
|
||||
font-weight: 750;
|
||||
line-height: 1;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.commit-branch-chip svg {
|
||||
flex: 0 0 auto;
|
||||
color: #76d995;
|
||||
}
|
||||
.commit-author {
|
||||
flex: 1 1 80px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.commit-files { display: grid; gap: 5px; }
|
||||
.commit-files-toggle { justify-content: flex-start; gap: 5px; min-height: 24px; padding: 0 7px; border-color: transparent; background: transparent; color: var(--color-ink-dim); font-size: 11.5px; font-weight: 700; }
|
||||
.ref-list { display: flex; flex-wrap: wrap; gap: 3px; }
|
||||
.ref-list .ref-chip {
|
||||
max-width: 100%;
|
||||
overflow: hidden;
|
||||
padding: 1px 6px;
|
||||
border-radius: 999px;
|
||||
color: var(--color-accent);
|
||||
background: rgba(106,154,255,0.09);
|
||||
border: 1px solid rgba(106,154,255,0.16);
|
||||
font-size: 9.5px;
|
||||
font-weight: 700;
|
||||
line-height: 1.25;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.ref-list .ref-chip.head {
|
||||
color: #061021;
|
||||
border-color: rgba(65,209,255,0.48);
|
||||
background: linear-gradient(135deg, #41d1ff, #7c6cff);
|
||||
box-shadow: 0 0 14px rgba(65,209,255,0.2);
|
||||
}
|
||||
.ref-list .ref-chip.branch { color: #7ddf9c; background: rgba(78,202,118,0.08); border-color: rgba(78,202,118,0.18); }
|
||||
.ref-list .ref-chip.remote { color: #aeb6ff; background: rgba(124,108,255,0.08); border-color: rgba(124,108,255,0.18); }
|
||||
.ref-list .ref-chip.tag { color: #dbc078; background: rgba(224,180,92,0.08); border-color: rgba(224,180,92,0.2); }
|
||||
|
||||
.commit-files {
|
||||
display: grid;
|
||||
gap: 5px;
|
||||
padding: 6px;
|
||||
border: 1px solid rgba(94,110,156,0.14);
|
||||
border-radius: 8px;
|
||||
background: rgba(7,8,16,0.16);
|
||||
}
|
||||
.commit-files-toggle {
|
||||
justify-content: flex-start;
|
||||
gap: 6px;
|
||||
min-height: 26px;
|
||||
padding: 0 8px;
|
||||
border-color: transparent;
|
||||
background: transparent;
|
||||
color: var(--color-ink-dim);
|
||||
font-size: 11.5px;
|
||||
font-weight: 800;
|
||||
}
|
||||
.commit-files-toggle:hover:not(:disabled) { border-color: var(--color-border-subtle); background: var(--color-surface-hover); color: var(--color-ink); }
|
||||
|
||||
.commit-file-list { display: grid; gap: 4px; }
|
||||
.commit-file-button { display: grid; grid-template-columns: auto minmax(0, 1fr); justify-content: stretch; width: 100%; min-height: 28px; padding: 4px 7px; text-align: left; border-color: var(--color-border-subtle); background: rgba(255,255,255,0.025); }
|
||||
.commit-file-button {
|
||||
display: grid;
|
||||
grid-template-columns: auto minmax(0, 1fr);
|
||||
justify-content: stretch;
|
||||
width: 100%;
|
||||
min-height: 30px;
|
||||
padding: 4px 7px;
|
||||
text-align: left;
|
||||
border-color: rgba(94,110,156,0.16);
|
||||
background: rgba(255,255,255,0.03);
|
||||
}
|
||||
.commit-file-button:hover:not(:disabled) { border-color: rgba(65,209,255,0.22); background: rgba(65,209,255,0.055); }
|
||||
.commit-file-button strong { overflow: hidden; color: var(--color-ink-muted); font-family: var(--font-mono); font-size: 11.5px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
|
||||
|
||||
.commit-actions { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 8px; }
|
||||
.commit-actions time { min-width: 0; overflow: hidden; color: var(--color-ink-faint); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.commit-actions time,
|
||||
.commit-time {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
color: var(--color-ink-faint);
|
||||
font-size: 11px;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.commit-action-buttons { display: flex; flex: 0 0 auto; align-items: center; gap: 5px; }
|
||||
.commit-action-buttons button { flex: 0 0 auto; white-space: nowrap; }
|
||||
.file-history-head { align-items: flex-start; }
|
||||
@@ -1551,29 +2126,131 @@
|
||||
|
||||
/* --- Git graph --- */
|
||||
|
||||
.graph-list { padding: 0; }
|
||||
.graph-list {
|
||||
padding: 0;
|
||||
background: var(--color-surface-dim);
|
||||
}
|
||||
|
||||
.graph-row { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0; margin: 0; padding: 0; border: none; border-radius: 0; background: none; }
|
||||
.graph-row {
|
||||
display: grid;
|
||||
grid-template-columns: auto minmax(0, 1fr);
|
||||
gap: 0;
|
||||
min-height: 58px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: none;
|
||||
border-radius: 0;
|
||||
background: none;
|
||||
}
|
||||
.graph-row + .graph-row { margin-top: 0; }
|
||||
|
||||
.graph-gutter { position: relative; align-self: stretch; background: var(--color-surface); }
|
||||
.graph-gutter {
|
||||
position: relative;
|
||||
align-self: stretch;
|
||||
min-width: 42px;
|
||||
border-right: 1px solid rgba(94,110,156,0.12);
|
||||
background: rgba(7,8,16,0.2);
|
||||
}
|
||||
.graph-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
|
||||
.graph-svg path {
|
||||
fill: none;
|
||||
stroke-linecap: round;
|
||||
stroke-linejoin: round;
|
||||
opacity: 0.76;
|
||||
transition: opacity 120ms ease, stroke-width 120ms ease;
|
||||
}
|
||||
.graph-svg path.hidden-branch {
|
||||
opacity: 0.08;
|
||||
}
|
||||
.graph-dot {
|
||||
position: absolute;
|
||||
z-index: 2;
|
||||
top: 50%;
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
border-radius: 999px;
|
||||
background: var(--dot-color, #5a8cf8);
|
||||
border: 2px solid var(--color-surface);
|
||||
box-shadow: 0 0 0 1px var(--dot-color, #5a8cf8);
|
||||
border: 2px solid #111321;
|
||||
box-shadow: 0 0 0 1px rgba(255,255,255,0.07);
|
||||
transform: translate(-50%, -50%);
|
||||
transition: transform 120ms ease, box-shadow 120ms ease;
|
||||
}
|
||||
.graph-dot.hidden-branch {
|
||||
opacity: 0.16;
|
||||
box-shadow: none;
|
||||
}
|
||||
.graph-dot.tip { width: 14px; height: 14px; box-shadow: 0 0 0 1px var(--dot-color, #5a8cf8); }
|
||||
.graph-dot.merge {
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
background: var(--color-surface-alt);
|
||||
border-color: var(--dot-color, #5a8cf8);
|
||||
box-shadow: 0 0 0 1px rgba(255,255,255,0.08);
|
||||
}
|
||||
.graph-hover-branches {
|
||||
position: absolute;
|
||||
z-index: 5;
|
||||
top: 50%;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 3px;
|
||||
max-width: 190px;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
transform: translateY(-50%) translateX(-4px);
|
||||
transition: opacity 120ms ease, transform 120ms ease;
|
||||
}
|
||||
.graph-gutter:hover .graph-hover-branches,
|
||||
.graph-row:hover .graph-hover-branches {
|
||||
opacity: 1;
|
||||
transform: translateY(-50%) translateX(0);
|
||||
}
|
||||
.graph-hover-branches span {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 3px;
|
||||
max-width: 180px;
|
||||
height: 18px;
|
||||
padding: 0 6px 0 5px;
|
||||
overflow: hidden;
|
||||
border: 1px solid rgba(91,209,138,0.28);
|
||||
border-radius: 999px;
|
||||
color: #b2f0c2;
|
||||
background: rgba(20,35,29,0.94);
|
||||
box-shadow: 0 8px 22px rgba(0,0,0,0.3);
|
||||
font-family: var(--font-mono);
|
||||
font-size: 9.5px;
|
||||
font-weight: 750;
|
||||
line-height: 1;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.graph-hover-branches svg {
|
||||
flex: 0 0 auto;
|
||||
color: #76d995;
|
||||
}
|
||||
.commit-body {
|
||||
display: grid;
|
||||
gap: 5px;
|
||||
min-width: 0;
|
||||
padding: 8px 10px;
|
||||
background: rgba(28,29,48,0.34);
|
||||
transition: background 120ms ease;
|
||||
}
|
||||
.graph-row + .graph-row .commit-body { border-top: 1px solid rgba(94,110,156,0.1); }
|
||||
.graph-row:hover .commit-body { background: rgba(37,40,62,0.54); }
|
||||
.graph-row:hover .graph-svg path { opacity: 1; stroke-width: 2.65; }
|
||||
.graph-row:hover .graph-svg path.hidden-branch { opacity: 0.12; stroke-width: 2.2; }
|
||||
.graph-row:hover .graph-dot { transform: translate(-50%, -50%) scale(1.12); }
|
||||
.graph-row:hover .graph-dot.hidden-branch { transform: translate(-50%, -50%) scale(1); }
|
||||
.graph-row.merge-row .commit-body {
|
||||
background: rgba(36,31,54,0.46);
|
||||
}
|
||||
.graph-row.tip-row .commit-body {
|
||||
background:
|
||||
linear-gradient(90deg, rgba(105,167,255,0.055), transparent 32%),
|
||||
rgba(28,29,48,0.38);
|
||||
}
|
||||
.graph-dot.merge { width: 12px; height: 12px; background: var(--color-surface); border-color: var(--dot-color, #5a8cf8); }
|
||||
|
||||
.commit-body { display: grid; gap: 7px; min-width: 0; padding: 10px 12px; }
|
||||
.graph-row + .graph-row .commit-body { border-top: 1px solid var(--color-border-subtle); }
|
||||
.graph-row:hover .commit-body { background: var(--color-surface-hover); }
|
||||
|
||||
/* --- Compare panel --- */
|
||||
|
||||
@@ -1721,6 +2398,44 @@
|
||||
color: #f5f7ff;
|
||||
background: linear-gradient(180deg, rgba(100,108,255,0.22), rgba(65,209,255,0.1));
|
||||
}
|
||||
.ai-provider-option-local {
|
||||
flex-wrap: wrap;
|
||||
row-gap: 2px;
|
||||
}
|
||||
.ai-provider-badge {
|
||||
flex-basis: 100%;
|
||||
text-align: center;
|
||||
font-size: 9.5px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.04em;
|
||||
text-transform: uppercase;
|
||||
color: var(--color-ink-faint);
|
||||
}
|
||||
.ai-local-profile-options {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 8px;
|
||||
}
|
||||
.ai-local-profile-option {
|
||||
min-width: 0;
|
||||
min-height: 34px;
|
||||
padding: 0 8px;
|
||||
border-color: var(--color-border-subtle);
|
||||
background: rgba(255,255,255,0.03);
|
||||
color: var(--color-ink-dim);
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
}
|
||||
.ai-local-profile-option:hover:not(:disabled) {
|
||||
border-color: var(--color-border);
|
||||
color: var(--color-ink);
|
||||
background: var(--color-surface-hover);
|
||||
}
|
||||
.ai-local-profile-option.active {
|
||||
border-color: rgba(65,209,255,0.48);
|
||||
color: #f5f7ff;
|
||||
background: linear-gradient(180deg, rgba(65,209,255,0.16), rgba(100,108,255,0.12));
|
||||
}
|
||||
.new-branch-form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -1936,6 +2651,12 @@
|
||||
gap: 14px;
|
||||
padding: 18px 16px 16px;
|
||||
}
|
||||
.branch-delete-body {
|
||||
display: grid;
|
||||
grid-template-columns: auto minmax(0, 1fr);
|
||||
gap: 14px;
|
||||
padding: 18px 16px 16px;
|
||||
}
|
||||
.discard-warning-icon {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
@@ -1970,6 +2691,11 @@
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
}
|
||||
.branch-delete-body .discard-target {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
.discard-warning-text {
|
||||
color: #ffb8bf;
|
||||
font-weight: 650;
|
||||
@@ -3009,16 +3735,16 @@
|
||||
/* --- Responsive breakpoints --- */
|
||||
|
||||
@media (min-width: 1800px) {
|
||||
.workspace { grid-template-columns: 320px minmax(0, 1fr) 680px; }
|
||||
.workspace { grid-template-columns: 320px minmax(0, 1fr) minmax(560px, var(--history-aside-width, 680px)); }
|
||||
}
|
||||
|
||||
@media (max-width: 1400px) {
|
||||
.workspace { grid-template-columns: clamp(200px, 17vw, 265px) minmax(0, 1fr) clamp(400px, 40vw, 580px); }
|
||||
.workspace { grid-template-columns: clamp(200px, 17vw, 265px) minmax(0, 1fr) minmax(540px, var(--history-aside-width, 580px)); }
|
||||
}
|
||||
|
||||
/* Stack CommitPanel below StatusPanel; history panels stay side by side */
|
||||
@media (max-width: 1100px) {
|
||||
.workspace { grid-template-columns: clamp(185px, 16vw, 220px) minmax(0, 1fr) clamp(380px, 38vw, 500px); }
|
||||
.workspace { grid-template-columns: clamp(185px, 16vw, 220px) minmax(0, 1fr) minmax(500px, var(--history-aside-width, 560px)); }
|
||||
.top-section { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) 14px var(--commit-panel-height, 190px); }
|
||||
}
|
||||
|
||||
@@ -3026,8 +3752,10 @@
|
||||
@media (max-width: 960px) {
|
||||
.workspace { grid-template-columns: 180px minmax(0, 1fr) 300px; gap: 6px; }
|
||||
.history-aside { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1.3fr) minmax(0, 0.7fr); }
|
||||
.history-resize-handle { display: none; }
|
||||
.shell-body { gap: 6px; }
|
||||
.left-sidebar { gap: 6px; grid-template-rows: minmax(180px, 0.8fr) minmax(200px, 1.2fr); }
|
||||
.left-sidebar { gap: 6px; grid-template-rows: minmax(150px, 0.7fr) minmax(145px, 0.55fr) minmax(190px, 1fr); }
|
||||
.left-sidebar:has(.stash-panel.collapsed) { grid-template-rows: minmax(150px, 0.8fr) auto minmax(190px, 1.1fr); }
|
||||
.section-head { min-height: 40px; padding: 6px 10px; }
|
||||
.repo-summary { height: 40px; padding: 0 10px; }
|
||||
.repo-branch { max-width: 160px; }
|
||||
@@ -3044,7 +3772,8 @@
|
||||
.shell-body { min-height: 100%; gap: 6px; }
|
||||
.workspace { grid-template-columns: 1fr; gap: 6px; }
|
||||
.history-aside { grid-template-columns: 1fr; grid-template-rows: minmax(200px, 1fr) minmax(150px, 0.5fr); min-height: 380px; }
|
||||
.left-sidebar { grid-template-rows: minmax(200px, 1fr) minmax(240px, 1.2fr); min-height: 440px; }
|
||||
.left-sidebar { grid-template-rows: minmax(180px, 0.9fr) minmax(150px, 0.55fr) minmax(220px, 1fr); min-height: 560px; }
|
||||
.left-sidebar:has(.stash-panel.collapsed) { grid-template-rows: minmax(180px, 1fr) auto minmax(220px, 1.1fr); }
|
||||
.top-section { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) 14px var(--commit-panel-height, 190px); }
|
||||
.repo-form { grid-template-columns: 1fr; }
|
||||
.repo-tabbar { grid-template-columns: minmax(0, 1fr) auto; }
|
||||
|
||||
+17
-1
@@ -2,7 +2,7 @@
|
||||
import { onDestroy, onMount } from "svelte";
|
||||
import { getVersion } from "@tauri-apps/api/app";
|
||||
import { getCurrentWindow } from "@tauri-apps/api/window";
|
||||
import { Download, FolderOpen, GitBranch, GitCompare, LoaderCircle, Minus, RefreshCw, Search, Upload, X } from "@lucide/svelte";
|
||||
import { CloudDownload, Download, FolderOpen, GitBranch, GitCompare, LoaderCircle, Minus, RefreshCw, Search, Upload, X } from "@lucide/svelte";
|
||||
|
||||
export let branch: string = "";
|
||||
export let ahead: number = 0;
|
||||
@@ -13,6 +13,7 @@
|
||||
export let operation: string = "";
|
||||
export let autoRefreshEnabled: boolean = true;
|
||||
export let autoRefreshInFlight: boolean = false;
|
||||
export let onFetch: () => void = () => {};
|
||||
export let onPull: () => void = () => {};
|
||||
export let onPush: () => void = () => {};
|
||||
export let onRefresh: () => void = () => {};
|
||||
@@ -122,6 +123,21 @@
|
||||
<span class="tb-action-label">Compare</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
class="tb-action"
|
||||
onclick={onFetch}
|
||||
disabled={!hasRepository || isBusy}
|
||||
title="Fetch"
|
||||
aria-label="Fetch"
|
||||
>
|
||||
{#if operation === "Fetching"}
|
||||
<LoaderCircle class="spin" size={14} aria-hidden="true" />
|
||||
{:else}
|
||||
<CloudDownload size={14} aria-hidden="true" />
|
||||
{/if}
|
||||
<span class="tb-action-label">Fetch</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
class="tb-action"
|
||||
onclick={onPull}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from "svelte";
|
||||
import { AlertCircle, Bot, Check, Cpu, Eye, EyeOff, Globe, Key, LoaderCircle, X } from "@lucide/svelte";
|
||||
import { AlertCircle, Bot, Check, Cpu, Eye, EyeOff, Gauge, Globe, Key, LoaderCircle, Sparkles, X, Zap } from "@lucide/svelte";
|
||||
import { credDelete, credLoad, credSave } from "../git";
|
||||
import type { AiSettings, CommitAiProvider, LocalModelOption } from "../types";
|
||||
import type { AiSettings, CommitAiLocalProfile, CommitAiProvider, LocalModelOption } from "../types";
|
||||
|
||||
interface Props {
|
||||
settings: AiSettings;
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
let provider = $state<CommitAiProvider>("local");
|
||||
let localModelId = $state("");
|
||||
let localProfile = $state<CommitAiLocalProfile>("fast");
|
||||
let openaiModel = $state("");
|
||||
let anthropicModel = $state("");
|
||||
let customBaseUrl = $state("");
|
||||
@@ -39,6 +40,7 @@
|
||||
$effect(() => {
|
||||
provider = settings.provider;
|
||||
localModelId = settings.localModelId;
|
||||
localProfile = settings.localProfile ?? "fast";
|
||||
openaiModel = settings.openaiModel;
|
||||
anthropicModel = settings.anthropicModel;
|
||||
customBaseUrl = settings.customBaseUrl;
|
||||
@@ -86,6 +88,7 @@
|
||||
onSave({
|
||||
provider,
|
||||
localModelId,
|
||||
localProfile,
|
||||
openaiModel: openaiModel.trim() || "gpt-4o-mini",
|
||||
anthropicModel: anthropicModel.trim() || "claude-3-5-haiku-latest",
|
||||
customBaseUrl: customBaseUrl.trim(),
|
||||
@@ -102,6 +105,21 @@
|
||||
return mb >= 1000 ? `${(mb / 1000).toFixed(1)} GB` : `${mb} MB`;
|
||||
}
|
||||
|
||||
function recommendedModelForProfile(profile: CommitAiLocalProfile): string {
|
||||
if (profile === "balanced") return "qwen2.5-1.5b";
|
||||
if (profile === "detailed") return "qwen2.5-3b";
|
||||
return "qwen2.5-0.5b";
|
||||
}
|
||||
|
||||
function selectLocalProfile(profile: CommitAiLocalProfile) {
|
||||
const previousRecommended = recommendedModelForProfile(localProfile);
|
||||
localProfile = profile;
|
||||
const nextRecommended = recommendedModelForProfile(profile);
|
||||
if (!localModelId || localModelId === previousRecommended) {
|
||||
localModelId = nextRecommended;
|
||||
}
|
||||
}
|
||||
|
||||
let selectedLocalModel = $derived(localModels.find((option) => option.id === localModelId));
|
||||
</script>
|
||||
|
||||
@@ -123,9 +141,16 @@
|
||||
|
||||
<form class="ai-settings-form" onsubmit={(e) => { e.preventDefault(); void handleSave(); }}>
|
||||
<div class="ai-provider-options" role="radiogroup" aria-label="AI provider">
|
||||
<button type="button" class="ai-provider-option" class:active={provider === "local"} onclick={() => { provider = "local"; }}>
|
||||
<button
|
||||
type="button"
|
||||
class="ai-provider-option ai-provider-option-local"
|
||||
class:active={provider === "local"}
|
||||
disabled
|
||||
title="Local AI is still in development and not yet available"
|
||||
>
|
||||
<Cpu size={16} aria-hidden="true" />
|
||||
Local AI
|
||||
<span class="ai-provider-badge">In development</span>
|
||||
</button>
|
||||
<button type="button" class="ai-provider-option" class:active={provider === "openai"} onclick={() => { provider = "openai"; }}>
|
||||
<Bot size={16} aria-hidden="true" />
|
||||
@@ -142,6 +167,23 @@
|
||||
</div>
|
||||
|
||||
{#if provider === "local"}
|
||||
<div class="cred-field">
|
||||
<span class="cred-field-label">Local speed</span>
|
||||
<div class="ai-local-profile-options" role="radiogroup" aria-label="Local AI speed">
|
||||
<button type="button" class="ai-local-profile-option" class:active={localProfile === "fast"} onclick={() => selectLocalProfile("fast")}>
|
||||
<Zap size={15} aria-hidden="true" />
|
||||
Fast
|
||||
</button>
|
||||
<button type="button" class="ai-local-profile-option" class:active={localProfile === "balanced"} onclick={() => selectLocalProfile("balanced")}>
|
||||
<Gauge size={15} aria-hidden="true" />
|
||||
Balanced
|
||||
</button>
|
||||
<button type="button" class="ai-local-profile-option" class:active={localProfile === "detailed"} onclick={() => selectLocalProfile("detailed")}>
|
||||
<Sparkles size={15} aria-hidden="true" />
|
||||
Detailed
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<label class="cred-field">
|
||||
<span class="cred-field-label">Model</span>
|
||||
<select bind:value={localModelId}>
|
||||
@@ -156,6 +198,7 @@
|
||||
Switching downloads the model{selectedLocalModel ? ` (${formatSize(selectedLocalModel.approx_size_mb)})` : ""}
|
||||
in the background — depending on your internet connection this can take several minutes.
|
||||
After that it stays cached locally and loads instantly on the next start.
|
||||
The speed setting only changes Local AI; API providers keep their existing prompt.
|
||||
</span>
|
||||
</div>
|
||||
{:else if provider === "openai"}
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
<script lang="ts">
|
||||
import { AlertTriangle, GitBranch, LoaderCircle, Trash2, X } from "@lucide/svelte";
|
||||
import type { GitBranch as GitBranchInfo } from "../types";
|
||||
|
||||
interface Props {
|
||||
branch: GitBranchInfo;
|
||||
force: boolean;
|
||||
isBusy: boolean;
|
||||
onConfirm: () => void | Promise<void>;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
let {
|
||||
branch,
|
||||
force = false,
|
||||
isBusy = false,
|
||||
onConfirm = () => {},
|
||||
onClose = () => {},
|
||||
}: Props = $props();
|
||||
|
||||
let title = $derived(force ? "Force delete branch?" : "Delete branch?");
|
||||
|
||||
function closeFromBackdrop(event: MouseEvent) {
|
||||
if (isBusy || event.target !== event.currentTarget) return;
|
||||
onClose();
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="dialog-backdrop" role="presentation" onclick={closeFromBackdrop}>
|
||||
<div class="dialog branch-delete-dialog" role="dialog" aria-modal="true" aria-label={title}>
|
||||
<header class="dialog-header">
|
||||
<div>
|
||||
<span class="eyebrow">{force ? "Force delete" : "Delete branch"}</span>
|
||||
<p class="dialog-title">{title}</p>
|
||||
</div>
|
||||
<button class="btn-sm dialog-close" type="button" onclick={onClose} disabled={isBusy} aria-label="Close">
|
||||
<X size={16} aria-hidden="true" />
|
||||
</button>
|
||||
</header>
|
||||
|
||||
<div class="branch-delete-body">
|
||||
<div class="discard-warning-icon" aria-hidden="true">
|
||||
<AlertTriangle size={22} />
|
||||
</div>
|
||||
|
||||
<div class="discard-confirm-copy">
|
||||
<p>
|
||||
{#if force}
|
||||
This branch is not fully merged. Force deleting removes the branch pointer even if some commits are only reachable from this branch.
|
||||
{:else}
|
||||
Delete this local branch from the repository?
|
||||
{/if}
|
||||
</p>
|
||||
<code class="discard-target" title={branch.name}>
|
||||
<GitBranch size={13} aria-hidden="true" />
|
||||
{branch.name}
|
||||
</code>
|
||||
<p class="discard-warning-text">
|
||||
{#if force}
|
||||
Make sure you no longer need the unique commits on this branch.
|
||||
{:else}
|
||||
Git will refuse if the branch is not fully merged.
|
||||
{/if}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer class="discard-confirm-actions">
|
||||
<button class="btn-secondary" type="button" onclick={onClose} disabled={isBusy}>Cancel</button>
|
||||
<button class="btn-danger" type="button" onclick={onConfirm} disabled={isBusy}>
|
||||
{#if isBusy}
|
||||
<LoaderCircle class="spin" size={15} aria-hidden="true" />
|
||||
{:else}
|
||||
<Trash2 size={15} aria-hidden="true" />
|
||||
{/if}
|
||||
{force ? "Force delete" : "Delete"}
|
||||
</button>
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
@@ -49,6 +49,7 @@
|
||||
isBusy: boolean;
|
||||
onCheckout: (branch: GitBranchInfo) => void;
|
||||
onMerge: (branch: GitBranchInfo) => void;
|
||||
onRebase: (branch: GitBranchInfo) => void;
|
||||
onCreateBranch: (branchName: string) => void | Promise<void>;
|
||||
onRenameBranch: (branch: GitBranchInfo) => void | Promise<void>;
|
||||
onDeleteBranch: (branch: GitBranchInfo) => void | Promise<void>;
|
||||
@@ -62,6 +63,7 @@
|
||||
isBusy = false,
|
||||
onCheckout = () => {},
|
||||
onMerge = () => {},
|
||||
onRebase = () => {},
|
||||
onCreateBranch = () => {},
|
||||
onRenameBranch = () => {},
|
||||
onDeleteBranch = () => {},
|
||||
@@ -216,13 +218,13 @@
|
||||
function openBranchContextMenu(event: MouseEvent, branch: GitBranchInfo) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
if (isBusy || branch.remote) return;
|
||||
if (isBusy) return;
|
||||
|
||||
const rect = panelElement?.getBoundingClientRect();
|
||||
const rawX = rect ? event.clientX - rect.left : event.offsetX;
|
||||
const rawY = rect ? event.clientY - rect.top : event.offsetY;
|
||||
const maxX = Math.max(8, (rect?.width ?? window.innerWidth) - 192);
|
||||
const maxY = Math.max(8, (rect?.height ?? window.innerHeight) - 92);
|
||||
const maxY = Math.max(8, (rect?.height ?? window.innerHeight) - 190);
|
||||
|
||||
contextBranch = branch;
|
||||
contextMenuX = Math.max(8, Math.min(rawX, maxX));
|
||||
@@ -242,11 +244,32 @@
|
||||
|
||||
async function deleteContextBranch() {
|
||||
const branch = contextBranch;
|
||||
if (!branch || branch.current || isBusy) return;
|
||||
if (!branch || branch.current || branch.remote || isBusy) return;
|
||||
closeBranchContextMenu();
|
||||
await onDeleteBranch(branch);
|
||||
}
|
||||
|
||||
async function checkoutContextBranch() {
|
||||
const branch = contextBranch;
|
||||
if (!branch || branch.current || isBusy) return;
|
||||
closeBranchContextMenu();
|
||||
await onCheckout(branch);
|
||||
}
|
||||
|
||||
async function mergeContextBranch() {
|
||||
const branch = contextBranch;
|
||||
if (!branch || branch.current || isBusy) return;
|
||||
closeBranchContextMenu();
|
||||
await onMerge(branch);
|
||||
}
|
||||
|
||||
async function rebaseContextBranch() {
|
||||
const branch = contextBranch;
|
||||
if (!branch || branch.current || isBusy) return;
|
||||
closeBranchContextMenu();
|
||||
await onRebase(branch);
|
||||
}
|
||||
|
||||
function handleWindowKeydown(event: KeyboardEvent) {
|
||||
if (event.key === "Escape") closeBranchContextMenu();
|
||||
}
|
||||
@@ -361,16 +384,6 @@
|
||||
</div>
|
||||
{#if row.branch.current}
|
||||
<span class="pill pill-active">Current</span>
|
||||
{:else}
|
||||
<div class="branch-actions">
|
||||
<button class="btn-sm" type="button" onclick={() => onCheckout(row.branch)} disabled={isBusy}>
|
||||
Checkout
|
||||
</button>
|
||||
<button class="btn-sm" type="button" onclick={() => onMerge(row.branch)} disabled={isBusy} title="Merge into current">
|
||||
<GitMerge size={15} aria-hidden="true" />
|
||||
Merge
|
||||
</button>
|
||||
</div>
|
||||
{/if}
|
||||
</article>
|
||||
{/if}
|
||||
@@ -426,6 +439,7 @@
|
||||
class:current={row.branch.current}
|
||||
style={`--branch-indent: ${row.depth * 16}px;`}
|
||||
ondblclick={(event) => checkoutOnDoubleClick(event, row.branch)}
|
||||
oncontextmenu={(event) => openBranchContextMenu(event, row.branch)}
|
||||
title={row.branch.current ? "Current branch" : row.branch.name}
|
||||
>
|
||||
<div class="branch-info">
|
||||
@@ -437,16 +451,6 @@
|
||||
</div>
|
||||
{#if row.branch.current}
|
||||
<span class="pill pill-active">Current</span>
|
||||
{:else}
|
||||
<div class="branch-actions">
|
||||
<button class="btn-sm" type="button" onclick={() => onCheckout(row.branch)} disabled={isBusy}>
|
||||
Checkout
|
||||
</button>
|
||||
<button class="btn-sm" type="button" onclick={() => onMerge(row.branch)} disabled={isBusy} title="Merge into current">
|
||||
<GitMerge size={15} aria-hidden="true" />
|
||||
Merge
|
||||
</button>
|
||||
</div>
|
||||
{/if}
|
||||
</article>
|
||||
{/if}
|
||||
@@ -465,7 +469,20 @@
|
||||
tabindex="-1"
|
||||
aria-label={`Actions for ${contextBranch.name}`}
|
||||
>
|
||||
<button type="button" role="menuitem" onclick={renameContextBranch} disabled={isBusy}>
|
||||
<button type="button" role="menuitem" onclick={checkoutContextBranch} disabled={isBusy || contextBranch.current}>
|
||||
<GitBranch size={14} aria-hidden="true" />
|
||||
Checkout
|
||||
</button>
|
||||
<button type="button" role="menuitem" onclick={mergeContextBranch} disabled={isBusy || contextBranch.current}>
|
||||
<GitMerge size={14} aria-hidden="true" />
|
||||
Merge into current
|
||||
</button>
|
||||
<button type="button" role="menuitem" onclick={rebaseContextBranch} disabled={isBusy || contextBranch.current}>
|
||||
<GitBranch size={14} aria-hidden="true" />
|
||||
Rebase current onto this
|
||||
</button>
|
||||
<div class="menu-separator" role="separator"></div>
|
||||
<button type="button" role="menuitem" onclick={renameContextBranch} disabled={isBusy || contextBranch.remote}>
|
||||
<Pencil size={14} aria-hidden="true" />
|
||||
Rename
|
||||
</button>
|
||||
@@ -474,8 +491,8 @@
|
||||
type="button"
|
||||
role="menuitem"
|
||||
onclick={deleteContextBranch}
|
||||
disabled={isBusy || contextBranch.current}
|
||||
title={contextBranch.current ? "Current branch cannot be deleted" : "Delete local branch"}
|
||||
disabled={isBusy || contextBranch.current || contextBranch.remote}
|
||||
title={contextBranch.current ? "Current branch cannot be deleted" : contextBranch.remote ? "Remote branch cannot be deleted here" : "Delete local branch"}
|
||||
>
|
||||
<Trash2 size={14} aria-hidden="true" />
|
||||
Delete
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
} from "@lucide/svelte";
|
||||
|
||||
interface Props {
|
||||
action: "push" | "pull";
|
||||
action: "push" | "pull" | "fetch";
|
||||
error: string;
|
||||
isBusy: boolean;
|
||||
onSubmit: (username: string, password: string, save: boolean, expiresAt: string | null) => void;
|
||||
@@ -43,8 +43,10 @@
|
||||
password.trim().length > 0 &&
|
||||
(mode === "token" || username.trim().length > 0),
|
||||
);
|
||||
let actionLabel = $derived(action === "push" ? "Push" : "Pull");
|
||||
let actionTitle = $derived(action === "push" ? "Authenticate push" : "Authenticate pull");
|
||||
let actionLabel = $derived(action === "push" ? "Push" : action === "fetch" ? "Fetch" : "Pull");
|
||||
let actionTitle = $derived(
|
||||
action === "push" ? "Authenticate push" : action === "fetch" ? "Authenticate fetch" : "Authenticate pull",
|
||||
);
|
||||
let actionHint = $derived(action === "push"
|
||||
? "The remote needs write access. Use a password or a token with the appropriate repository permissions."
|
||||
: "The remote needs access to the repository. Use your Git credentials or a personal access token.");
|
||||
|
||||
@@ -1,28 +1,38 @@
|
||||
<script lang="ts">
|
||||
import { ChevronDown, ChevronRight, GitBranch, RotateCcw } from "@lucide/svelte";
|
||||
import { ChevronDown, ChevronRight, GitBranch, GitMerge, RotateCcw, X } from "@lucide/svelte";
|
||||
import type { FileStatusKind, GitCommit, GitCommitFile } from "../types";
|
||||
|
||||
interface GraphSegment {
|
||||
fromCol: number;
|
||||
toCol: number;
|
||||
color: string;
|
||||
branches: string[];
|
||||
}
|
||||
|
||||
interface GraphRow {
|
||||
dotCol: number;
|
||||
dotColor: string;
|
||||
branchLabels: string[];
|
||||
top: GraphSegment[];
|
||||
bottom: GraphSegment[];
|
||||
}
|
||||
|
||||
interface VisibleCommitEntry {
|
||||
commit: GitCommit;
|
||||
graphCommit: GitCommit;
|
||||
}
|
||||
|
||||
const GRAPH_COLORS = [
|
||||
"#2f6fb0", "#4aa777", "#c9851f", "#a05bd0",
|
||||
"#cc4b6e", "#1f9ab0", "#7a8a1f", "#b0631f",
|
||||
"#69a7ff", "#5bd18a", "#d8a74a", "#ba82ff",
|
||||
"#ff7c9f", "#48c7d8", "#c5cf54", "#e18c55",
|
||||
];
|
||||
const GRAPH_LANE = 16;
|
||||
const GRAPH_LANE = 18;
|
||||
|
||||
interface Props {
|
||||
commits: GitCommit[];
|
||||
localBranchNames: string[];
|
||||
activeBranch: string;
|
||||
repositoryKey: string;
|
||||
hasRepository: boolean;
|
||||
isBusy: boolean;
|
||||
expandedCommitHashes: Set<string>;
|
||||
@@ -34,6 +44,9 @@
|
||||
|
||||
let {
|
||||
commits = [],
|
||||
localBranchNames = [],
|
||||
activeBranch = "",
|
||||
repositoryKey = "",
|
||||
hasRepository = false,
|
||||
isBusy = false,
|
||||
expandedCommitHashes = new Set(),
|
||||
@@ -43,6 +56,11 @@
|
||||
onCreateBranchFromCommit = () => {},
|
||||
}: Props = $props();
|
||||
|
||||
let hiddenGraphBranches = $state<Set<string>>(new Set());
|
||||
let branchDialogOpen = $state(false);
|
||||
let userAdjustedBranchFilter = $state(false);
|
||||
let lastDefaultFilterKey = $state("");
|
||||
|
||||
function laneColor(col: number): string {
|
||||
return GRAPH_COLORS[((col % GRAPH_COLORS.length) + GRAPH_COLORS.length) % GRAPH_COLORS.length];
|
||||
}
|
||||
@@ -51,13 +69,23 @@
|
||||
return col * GRAPH_LANE + GRAPH_LANE / 2;
|
||||
}
|
||||
|
||||
function computeGraph(items: GitCommit[]): { rows: GraphRow[]; columns: number } {
|
||||
function graphPath(seg: GraphSegment, fromY: number, toY: number): string {
|
||||
const x1 = graphColX(seg.fromCol);
|
||||
const x2 = graphColX(seg.toCol);
|
||||
if (x1 === x2) return `M ${x1} ${fromY} L ${x2} ${toY}`;
|
||||
const midY = (fromY + toY) / 2;
|
||||
return `M ${x1} ${fromY} C ${x1} ${midY}, ${x2} ${midY}, ${x2} ${toY}`;
|
||||
}
|
||||
|
||||
function computeGraph(items: GitCommit[], branchMembership = new Map<string, string[]>()): { rows: GraphRow[]; columns: number } {
|
||||
const rows: GraphRow[] = [];
|
||||
let lanes: (string | null)[] = [];
|
||||
let laneBranches: string[][] = [];
|
||||
let maxColumns = 1;
|
||||
|
||||
for (const commit of items) {
|
||||
const before = lanes.slice();
|
||||
const beforeBranches = laneBranches.map((branches) => branches.slice());
|
||||
|
||||
let col = before.indexOf(commit.hash);
|
||||
if (col === -1) {
|
||||
@@ -67,18 +95,27 @@
|
||||
|
||||
const after = before.slice();
|
||||
while (after.length <= col) after.push(null);
|
||||
const afterBranches = beforeBranches.map((branches) => branches.slice());
|
||||
while (afterBranches.length <= col) afterBranches.push([]);
|
||||
|
||||
for (let k = 0; k < after.length; k++) {
|
||||
if (after[k] === commit.hash) after[k] = null;
|
||||
if (after[k] === commit.hash) {
|
||||
after[k] = null;
|
||||
afterBranches[k] = [];
|
||||
}
|
||||
}
|
||||
|
||||
const currentBranches = branchMembership.get(commit.hash) ?? localBranchRefs(commit);
|
||||
const commitBranches = uniqueStrings([...(beforeBranches[col] ?? []), ...currentBranches]);
|
||||
after[col] = commit.parents.length > 0 ? commit.parents[0] : null;
|
||||
afterBranches[col] = after[col] ? commitBranches.slice() : [];
|
||||
|
||||
const fromCommit = new Set<number>([col]);
|
||||
for (let p = 1; p < commit.parents.length; p++) {
|
||||
let slot = after.indexOf(null);
|
||||
if (slot === -1) { slot = after.length; after.push(null); }
|
||||
if (slot === -1) { slot = after.length; after.push(null); afterBranches.push([]); }
|
||||
after[slot] = commit.parents[p];
|
||||
afterBranches[slot] = [];
|
||||
fromCommit.add(slot);
|
||||
}
|
||||
|
||||
@@ -86,19 +123,28 @@
|
||||
for (let k = 0; k < before.length; k++) {
|
||||
const target = before[k];
|
||||
if (target == null) continue;
|
||||
top.push({ fromCol: k, toCol: target === commit.hash ? col : k, color: laneColor(k) });
|
||||
top.push({ fromCol: k, toCol: target === commit.hash ? col : k, color: laneColor(k), branches: beforeBranches[k] ?? [] });
|
||||
}
|
||||
|
||||
const bottom: GraphSegment[] = [];
|
||||
for (let k = 0; k < after.length; k++) {
|
||||
if (after[k] == null) continue;
|
||||
bottom.push({ fromCol: fromCommit.has(k) ? col : k, toCol: k, color: laneColor(k) });
|
||||
bottom.push({
|
||||
fromCol: fromCommit.has(k) ? col : k,
|
||||
toCol: k,
|
||||
color: laneColor(k),
|
||||
branches: fromCommit.has(k) ? commitBranches : afterBranches[k] ?? [],
|
||||
});
|
||||
}
|
||||
|
||||
rows.push({ dotCol: col, dotColor: laneColor(col), top, bottom });
|
||||
rows.push({ dotCol: col, dotColor: laneColor(col), branchLabels: currentBranches, top, bottom });
|
||||
|
||||
lanes = after.slice();
|
||||
while (lanes.length > 0 && lanes[lanes.length - 1] == null) lanes.pop();
|
||||
laneBranches = afterBranches.map((branches) => branches.slice());
|
||||
while (lanes.length > 0 && lanes[lanes.length - 1] == null) {
|
||||
lanes.pop();
|
||||
laneBranches.pop();
|
||||
}
|
||||
maxColumns = Math.max(maxColumns, before.length, after.length, col + 1);
|
||||
}
|
||||
|
||||
@@ -113,73 +159,356 @@
|
||||
return file.old_path ? `${file.old_path} -> ${file.path}` : file.path;
|
||||
}
|
||||
|
||||
function baseName(path: string): string {
|
||||
return path.split(/[\\/]/).filter(Boolean).pop() ?? path;
|
||||
}
|
||||
|
||||
function commitFileName(file: GitCommitFile): string {
|
||||
return file.old_path
|
||||
? `${baseName(file.old_path)} -> ${baseName(file.path)}`
|
||||
: baseName(file.path);
|
||||
}
|
||||
|
||||
function authorInitials(name: string): string {
|
||||
const parts = name.trim().split(/\s+/).filter(Boolean);
|
||||
if (parts.length === 0) return "?";
|
||||
if (parts.length === 1) return parts[0].slice(0, 2).toUpperCase();
|
||||
return `${parts[0][0]}${parts[parts.length - 1][0]}`.toUpperCase();
|
||||
}
|
||||
|
||||
function commitKind(commit: GitCommit): "merge" | "root" | "commit" {
|
||||
if (commit.parents.length > 1) return "merge";
|
||||
if (commit.parents.length === 0) return "root";
|
||||
return "commit";
|
||||
}
|
||||
|
||||
function commitKindLabel(commit: GitCommit): string {
|
||||
const kind = commitKind(commit);
|
||||
if (kind === "merge") return "merge";
|
||||
if (kind === "root") return "root";
|
||||
return "commit";
|
||||
}
|
||||
|
||||
let localBranchNameSet = $derived(new Set(localBranchNames));
|
||||
|
||||
function uniqueStrings(values: string[]): string[] {
|
||||
return [...new Set(values.filter(Boolean))];
|
||||
}
|
||||
|
||||
function branchIsVisible(branch: string): boolean {
|
||||
return !hiddenGraphBranches.has(branch);
|
||||
}
|
||||
|
||||
function visibleBranchLabels(labels: string[]): string[] {
|
||||
return labels.filter(branchIsVisible);
|
||||
}
|
||||
|
||||
function segmentIsVisible(segment: GraphSegment): boolean {
|
||||
return segment.branches.length === 0 || segment.branches.some(branchIsVisible);
|
||||
}
|
||||
|
||||
function branchesAreVisible(branches: string[]): boolean {
|
||||
if (localBranchNames.length === 0) return true;
|
||||
return branches.some(branchIsVisible);
|
||||
}
|
||||
|
||||
function rowGraphIsVisible(row: GraphRow | undefined): boolean {
|
||||
return branchesAreVisible(row?.branchLabels ?? []);
|
||||
}
|
||||
|
||||
function nearestVisibleGraphParents(
|
||||
hash: string,
|
||||
visibleHashes: Set<string>,
|
||||
commitByHash: Map<string, GitCommit>,
|
||||
seen: Set<string>,
|
||||
): string[] {
|
||||
if (visibleHashes.has(hash)) return [hash];
|
||||
if (seen.has(hash)) return [];
|
||||
seen.add(hash);
|
||||
|
||||
const commit = commitByHash.get(hash);
|
||||
if (!commit) return [];
|
||||
return uniqueStrings(
|
||||
commit.parents.flatMap((parentHash) => (
|
||||
nearestVisibleGraphParents(parentHash, visibleHashes, commitByHash, new Set(seen))
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
function branchMembershipByHash(items: GitCommit[]): Map<string, string[]> {
|
||||
const commitByHash = new Map(items.map((commit) => [commit.hash, commit]));
|
||||
const membership = new Map<string, Set<string>>();
|
||||
|
||||
for (const commit of items) {
|
||||
for (const branch of localBranchRefs(commit)) {
|
||||
const stack = [commit.hash];
|
||||
const seen = new Set<string>();
|
||||
|
||||
while (stack.length > 0) {
|
||||
const hash = stack.pop();
|
||||
if (!hash || seen.has(hash)) continue;
|
||||
seen.add(hash);
|
||||
|
||||
let branches = membership.get(hash);
|
||||
if (!branches) {
|
||||
branches = new Set<string>();
|
||||
membership.set(hash, branches);
|
||||
}
|
||||
branches.add(branch);
|
||||
|
||||
const parentCommit = commitByHash.get(hash);
|
||||
if (parentCommit) stack.push(...parentCommit.parents);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new Map(
|
||||
items.map((commit) => [
|
||||
commit.hash,
|
||||
localBranchNames.filter((branch) => membership.get(commit.hash)?.has(branch)),
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
function visibleCommitEntriesForGraph(items: GitCommit[], branchMembership: Map<string, string[]>): VisibleCommitEntry[] {
|
||||
const visibleItems = items.filter((commit) => branchesAreVisible(branchMembership.get(commit.hash) ?? []));
|
||||
const visibleHashes = new Set(visibleItems.map((commit) => commit.hash));
|
||||
const commitByHash = new Map(items.map((commit) => [commit.hash, commit]));
|
||||
|
||||
return visibleItems.map((commit) => {
|
||||
const parents = uniqueStrings(
|
||||
commit.parents.flatMap((parentHash) => (
|
||||
nearestVisibleGraphParents(parentHash, visibleHashes, commitByHash, new Set())
|
||||
)),
|
||||
);
|
||||
return { commit, graphCommit: { ...commit, parents } };
|
||||
});
|
||||
}
|
||||
|
||||
function toggleGraphBranch(branch: string) {
|
||||
const next = new Set(hiddenGraphBranches);
|
||||
if (next.has(branch)) next.delete(branch); else next.add(branch);
|
||||
hiddenGraphBranches = next;
|
||||
userAdjustedBranchFilter = true;
|
||||
}
|
||||
|
||||
function showAllGraphBranches() {
|
||||
hiddenGraphBranches = new Set();
|
||||
userAdjustedBranchFilter = true;
|
||||
}
|
||||
|
||||
function hideAllGraphBranches() {
|
||||
hiddenGraphBranches = new Set(localBranchNames);
|
||||
userAdjustedBranchFilter = true;
|
||||
}
|
||||
|
||||
function openBranchDialog() {
|
||||
branchDialogOpen = true;
|
||||
}
|
||||
|
||||
function closeBranchDialog() {
|
||||
branchDialogOpen = false;
|
||||
}
|
||||
|
||||
function handleBranchDialogKeydown(event: KeyboardEvent) {
|
||||
if (branchDialogOpen && event.key === "Escape") {
|
||||
closeBranchDialog();
|
||||
}
|
||||
}
|
||||
|
||||
function handleBranchDialogBackdropClick(event: MouseEvent) {
|
||||
if (event.target === event.currentTarget) {
|
||||
closeBranchDialog();
|
||||
}
|
||||
}
|
||||
|
||||
function localBranchRefs(commit: GitCommit): string[] {
|
||||
const seen = new Set<string>();
|
||||
const labels: string[] = [];
|
||||
for (const ref of commit.refs) {
|
||||
const label = refLabel(ref);
|
||||
if (!localBranchNameSet.has(label) || seen.has(label)) continue;
|
||||
seen.add(label);
|
||||
labels.push(label);
|
||||
}
|
||||
return labels;
|
||||
}
|
||||
|
||||
function visibleRefs(commit: GitCommit): string[] {
|
||||
return commit.refs.filter((ref) => !localBranchNameSet.has(refLabel(ref)));
|
||||
}
|
||||
|
||||
function refClass(ref: string): string {
|
||||
if (ref.startsWith("HEAD")) return "head";
|
||||
if (ref.startsWith("tag:")) return "tag";
|
||||
if (localBranchNameSet.has(refLabel(ref))) return "branch";
|
||||
if (ref.includes("/")) return "remote";
|
||||
return "branch";
|
||||
}
|
||||
|
||||
function refLabel(ref: string): string {
|
||||
return ref.replace(/^HEAD ->\s*/, "").replace(/^tag:\s*/, "");
|
||||
}
|
||||
|
||||
function formatCommitDate(value: string): string {
|
||||
const date = new Date(value);
|
||||
if (Number.isNaN(date.getTime())) return value;
|
||||
return new Intl.DateTimeFormat(undefined, { dateStyle: "medium", timeStyle: "short" }).format(date);
|
||||
}
|
||||
|
||||
let graph = $derived(computeGraph(commits));
|
||||
$effect(() => {
|
||||
const available = new Set(localBranchNames);
|
||||
const nextHidden = new Set([...hiddenGraphBranches].filter((branch) => available.has(branch)));
|
||||
if (nextHidden.size !== hiddenGraphBranches.size) {
|
||||
hiddenGraphBranches = nextHidden;
|
||||
}
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
const defaultBranch = activeBranch && localBranchNames.includes(activeBranch)
|
||||
? activeBranch
|
||||
: (localBranchNames[0] ?? "");
|
||||
const defaultFilterKey = `${repositoryKey}::${defaultBranch}`;
|
||||
|
||||
if (!defaultBranch) {
|
||||
if (lastDefaultFilterKey !== defaultFilterKey) {
|
||||
hiddenGraphBranches = new Set();
|
||||
userAdjustedBranchFilter = false;
|
||||
lastDefaultFilterKey = defaultFilterKey;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (lastDefaultFilterKey !== defaultFilterKey) {
|
||||
userAdjustedBranchFilter = false;
|
||||
lastDefaultFilterKey = defaultFilterKey;
|
||||
}
|
||||
|
||||
if (!userAdjustedBranchFilter) {
|
||||
hiddenGraphBranches = new Set(localBranchNames.filter((branch) => branch !== defaultBranch));
|
||||
}
|
||||
});
|
||||
|
||||
let branchMembership = $derived(branchMembershipByHash(commits));
|
||||
let visibleCommitEntries = $derived(visibleCommitEntriesForGraph(commits, branchMembership));
|
||||
let visibleCommits = $derived(visibleCommitEntries.map((entry) => entry.commit));
|
||||
let graphCommits = $derived(visibleCommitEntries.map((entry) => entry.graphCommit));
|
||||
let visibleBranchCount = $derived(localBranchNames.filter(branchIsVisible).length);
|
||||
let graph = $derived(computeGraph(graphCommits, branchMembership));
|
||||
let graphRows = $derived(graph.rows);
|
||||
let graphWidth = $derived(Math.max(graph.columns, 1) * GRAPH_LANE);
|
||||
let graphWidth = $derived(Math.max(Math.max(graph.columns, 1) * GRAPH_LANE + 18, 42));
|
||||
</script>
|
||||
|
||||
<svelte:window onkeydown={handleBranchDialogKeydown} />
|
||||
|
||||
<section class="panel grid grid-rows-[auto_1fr] overflow-hidden" aria-label="Commit history">
|
||||
<div class="section-head">
|
||||
<div>
|
||||
<span class="eyebrow">History</span>
|
||||
<h2 class="mt-0.5 text-ink text-base font-bold leading-tight">Commits</h2>
|
||||
</div>
|
||||
<span class="pill pill-count">{commits.length}</span>
|
||||
<div class="section-head-actions">
|
||||
{#if localBranchNames.length > 0}
|
||||
<button
|
||||
class="graph-branch-dialog-button"
|
||||
type="button"
|
||||
onclick={openBranchDialog}
|
||||
title="Select branches shown in the graph"
|
||||
>
|
||||
<GitBranch size={13} aria-hidden="true" />
|
||||
Branches
|
||||
<span>{visibleBranchCount}/{localBranchNames.length}</span>
|
||||
</button>
|
||||
{/if}
|
||||
<span class="pill pill-count" title={visibleCommits.length === commits.length ? "Commits" : `${visibleCommits.length} of ${commits.length} commits shown`}>
|
||||
{visibleCommits.length}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{#if !hasRepository}
|
||||
<div class="blank-state">No repository loaded.</div>
|
||||
{:else if commits.length === 0}
|
||||
<div class="blank-state">No commits returned.</div>
|
||||
{:else if visibleCommits.length === 0}
|
||||
<div class="blank-state">No commits match the selected branches.</div>
|
||||
{:else}
|
||||
<div class="history-list graph-list overflow-auto">
|
||||
{#each commits as item, rowIndex (item.hash)}
|
||||
{#each visibleCommitEntries as entry, rowIndex (entry.commit.hash)}
|
||||
{@const item = entry.commit}
|
||||
{@const row = graphRows[rowIndex]}
|
||||
<article class="commit-row graph-row">
|
||||
{@const hoverBranchRefs = visibleBranchLabels(row?.branchLabels ?? [])}
|
||||
{@const otherRefs = visibleRefs(item)}
|
||||
<article class="commit-row graph-row" class:merge-row={item.parents.length > 1} class:root-row={item.parents.length === 0} class:tip-row={item.refs.length > 0}>
|
||||
<div class="graph-gutter" style={`width:${graphWidth}px`} aria-hidden="true">
|
||||
{#if row}
|
||||
<svg class="graph-svg" viewBox={`0 0 ${graphWidth} 100`} preserveAspectRatio="none">
|
||||
{#each row.top as seg}
|
||||
<line
|
||||
x1={graphColX(seg.fromCol)} y1="0"
|
||||
x2={graphColX(seg.toCol)} y2="50"
|
||||
stroke={seg.color} stroke-width="2" vector-effect="non-scaling-stroke"
|
||||
<path
|
||||
class:hidden-branch={!segmentIsVisible(seg)}
|
||||
d={graphPath(seg, 0, 50)}
|
||||
stroke={seg.color}
|
||||
stroke-width="2.2"
|
||||
vector-effect="non-scaling-stroke"
|
||||
/>
|
||||
{/each}
|
||||
{#each row.bottom as seg}
|
||||
<line
|
||||
x1={graphColX(seg.fromCol)} y1="50"
|
||||
x2={graphColX(seg.toCol)} y2="100"
|
||||
stroke={seg.color} stroke-width="2" vector-effect="non-scaling-stroke"
|
||||
<path
|
||||
class:hidden-branch={!segmentIsVisible(seg)}
|
||||
d={graphPath(seg, 50, 100)}
|
||||
stroke={seg.color}
|
||||
stroke-width="2.2"
|
||||
vector-effect="non-scaling-stroke"
|
||||
/>
|
||||
{/each}
|
||||
</svg>
|
||||
<span
|
||||
class="graph-dot"
|
||||
class:merge={item.parents.length > 1}
|
||||
class:tip={item.refs.length > 0}
|
||||
class:hidden-branch={!rowGraphIsVisible(row)}
|
||||
title={hoverBranchRefs.length > 0 ? `Contained in: ${hoverBranchRefs.join(", ")}` : item.short_hash}
|
||||
style={`left:${graphColX(row.dotCol)}px; --dot-color:${row.dotColor}`}
|
||||
></span>
|
||||
{#if hoverBranchRefs.length > 0}
|
||||
<div class="graph-hover-branches" style={`left:${graphColX(row.dotCol) + 13}px`}>
|
||||
{#each hoverBranchRefs as branch}
|
||||
<span title={branch}>
|
||||
<GitBranch size={10} aria-hidden="true" />
|
||||
{branch}
|
||||
</span>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div class="commit-body">
|
||||
<div class="commit-line">
|
||||
<div>
|
||||
<strong title={item.summary}>{item.summary}</strong>
|
||||
<span>{item.short_hash} - {item.author_name}</span>
|
||||
<div class="commit-card-head">
|
||||
<span class="commit-avatar">
|
||||
{authorInitials(item.author_name)}
|
||||
</span>
|
||||
<div class="commit-card-main">
|
||||
<div class="commit-title-row">
|
||||
<strong class="commit-summary" title={item.summary}>{item.summary}</strong>
|
||||
<span class={`commit-kind ${commitKind(item)}`}>
|
||||
{#if item.parents.length > 1}
|
||||
<GitMerge size={12} aria-hidden="true" />
|
||||
{/if}
|
||||
{commitKindLabel(item)}
|
||||
</span>
|
||||
</div>
|
||||
<div class="commit-meta-line">
|
||||
<span class="commit-hash">{item.short_hash}</span>
|
||||
<span class="commit-author" title={item.author_email}>{item.author_name}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{#if item.refs.length > 0}
|
||||
{#if otherRefs.length > 0}
|
||||
<div class="ref-list" aria-label="Commit refs">
|
||||
{#each item.refs as ref}
|
||||
<span>{ref}</span>
|
||||
{#each otherRefs as ref}
|
||||
<span class={`ref-chip ${refClass(ref)}`}>{refLabel(ref)}</span>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
@@ -208,10 +537,10 @@
|
||||
type="button"
|
||||
onclick={() => onPreviewCommitFile(item, file)}
|
||||
disabled={isBusy}
|
||||
title="Show differences before restoring"
|
||||
title={`Show differences before restoring - ${displayCommitFile(file)}`}
|
||||
>
|
||||
<span class={`status-badge ${file.status}`}>{statusLabel(file.status)}</span>
|
||||
<strong>{displayCommitFile(file)}</strong>
|
||||
<strong>{commitFileName(file)}</strong>
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
@@ -220,7 +549,7 @@
|
||||
{/if}
|
||||
|
||||
<div class="commit-actions">
|
||||
<time datetime={item.date}>{formatCommitDate(item.date)}</time>
|
||||
<time class="commit-time" datetime={item.date}>{formatCommitDate(item.date)}</time>
|
||||
<div class="commit-action-buttons">
|
||||
<button class="btn-sm" type="button" onclick={() => onCreateBranchFromCommit(item)} disabled={isBusy} title="Create a new branch from this commit">
|
||||
<GitBranch size={15} aria-hidden="true" />
|
||||
@@ -238,3 +567,46 @@
|
||||
</div>
|
||||
{/if}
|
||||
</section>
|
||||
|
||||
{#if branchDialogOpen}
|
||||
<div class="branch-filter-backdrop" role="presentation" onclick={handleBranchDialogBackdropClick}>
|
||||
<div
|
||||
class="branch-filter-dialog"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-label="Select visible branches"
|
||||
>
|
||||
<header class="branch-filter-dialog-head">
|
||||
<div>
|
||||
<span class="eyebrow">Git graph</span>
|
||||
<h3>Visible branches</h3>
|
||||
</div>
|
||||
<button class="dialog-icon-button" type="button" onclick={closeBranchDialog} aria-label="Close branch selection">
|
||||
<X size={16} aria-hidden="true" />
|
||||
</button>
|
||||
</header>
|
||||
|
||||
<div class="branch-filter-summary">
|
||||
<span>{visibleBranchCount} of {localBranchNames.length} branches selected</span>
|
||||
<div class="branch-filter-actions">
|
||||
<button type="button" onclick={showAllGraphBranches} disabled={visibleBranchCount === localBranchNames.length}>Show all</button>
|
||||
<button type="button" onclick={hideAllGraphBranches} disabled={visibleBranchCount === 0}>Hide all</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="branch-filter-dialog-list">
|
||||
{#each localBranchNames as branch}
|
||||
<label class:muted={!branchIsVisible(branch)} class="branch-filter-option" title={branch}>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={branchIsVisible(branch)}
|
||||
onchange={() => toggleGraphBranch(branch)}
|
||||
/>
|
||||
<GitBranch size={14} aria-hidden="true" />
|
||||
<span>{branch}</span>
|
||||
</label>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
@@ -261,13 +261,13 @@
|
||||
style="grid-template-rows: auto minmax(0,1fr) auto;"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-label="Resolve merge conflicts"
|
||||
aria-label="Resolve conflicts"
|
||||
tabindex="-1"
|
||||
>
|
||||
<header class="dialog-header">
|
||||
<div>
|
||||
<span class="eyebrow">Resolve</span>
|
||||
<h2 class="dialog-title">Merge conflicts</h2>
|
||||
<h2 class="dialog-title">Conflicts</h2>
|
||||
</div>
|
||||
<button class="dialog-close" type="button" onclick={onClose} title="Close">
|
||||
<X size={18} aria-hidden="true" />
|
||||
@@ -275,7 +275,7 @@
|
||||
</header>
|
||||
|
||||
{#if conflictedFiles.length === 0}
|
||||
<div class="blank-state">All conflicts resolved. You can commit the merge now.</div>
|
||||
<div class="blank-state">All conflicts resolved. Continue the current operation when ready.</div>
|
||||
{:else}
|
||||
<div class="dialog-body">
|
||||
<aside class="dialog-files" aria-label="Conflicted files">
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
<script lang="ts">
|
||||
import { Archive, ChevronDown, ChevronRight, Download, Trash2, Upload } from "@lucide/svelte";
|
||||
import type { GitStash } from "../types";
|
||||
|
||||
interface Props {
|
||||
stashes: GitStash[];
|
||||
changedCount: number;
|
||||
hasRepository: boolean;
|
||||
isBusy: boolean;
|
||||
onPush: (message: string, includeUntracked: boolean) => void;
|
||||
onApply: (stash: GitStash) => void;
|
||||
onPop: (stash: GitStash) => void;
|
||||
onDrop: (stash: GitStash) => void;
|
||||
}
|
||||
|
||||
let {
|
||||
stashes = [],
|
||||
changedCount = 0,
|
||||
hasRepository = false,
|
||||
isBusy = false,
|
||||
onPush = () => {},
|
||||
onApply = () => {},
|
||||
onPop = () => {},
|
||||
onDrop = () => {},
|
||||
}: Props = $props();
|
||||
|
||||
let message = $state("");
|
||||
let includeUntracked = $state(true);
|
||||
let open = $state(false);
|
||||
|
||||
function submitPush() {
|
||||
onPush(message, includeUntracked);
|
||||
message = "";
|
||||
}
|
||||
|
||||
function stashTitle(stash: GitStash): string {
|
||||
return stash.message || stash.selector;
|
||||
}
|
||||
</script>
|
||||
|
||||
<section class="panel stash-panel overflow-hidden" class:collapsed={!open} aria-label="Git stash">
|
||||
<div class="section-head">
|
||||
<div>
|
||||
<span class="eyebrow">Stash</span>
|
||||
<h2 class="mt-0.5 text-ink text-base font-bold leading-tight">Shelved changes</h2>
|
||||
</div>
|
||||
<div class="stash-head-actions">
|
||||
<button
|
||||
class="stash-toggle"
|
||||
type="button"
|
||||
onclick={() => { open = !open; }}
|
||||
aria-expanded={open}
|
||||
title={open ? "Collapse stash panel" : "Expand stash panel"}
|
||||
>
|
||||
{#if open}
|
||||
<ChevronDown size={14} aria-hidden="true" />
|
||||
{:else}
|
||||
<ChevronRight size={14} aria-hidden="true" />
|
||||
{/if}
|
||||
</button>
|
||||
<span class="pill pill-count">{stashes.length}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{#if !open}
|
||||
<!-- collapsed -->
|
||||
{:else if !hasRepository}
|
||||
<div class="blank-state">No repository loaded.</div>
|
||||
{:else}
|
||||
<div class="stash-create">
|
||||
<input
|
||||
class="stash-input"
|
||||
type="text"
|
||||
bind:value={message}
|
||||
placeholder="Optional message"
|
||||
disabled={isBusy || changedCount === 0}
|
||||
onkeydown={(event) => {
|
||||
if (event.key === "Enter" && changedCount > 0 && !isBusy) submitPush();
|
||||
}}
|
||||
/>
|
||||
<label class="stash-check">
|
||||
<input type="checkbox" bind:checked={includeUntracked} disabled={isBusy || changedCount === 0} />
|
||||
Untracked
|
||||
</label>
|
||||
<button
|
||||
class="btn-sm stash-save-button"
|
||||
type="button"
|
||||
onclick={submitPush}
|
||||
disabled={isBusy || changedCount === 0}
|
||||
title="Save current working tree changes to a stash"
|
||||
>
|
||||
<Archive size={14} aria-hidden="true" />
|
||||
Stash
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{#if stashes.length === 0}
|
||||
<div class="blank-state stash-empty">No stashes saved.</div>
|
||||
{:else}
|
||||
<div class="stash-list">
|
||||
{#each stashes as stash (stash.selector)}
|
||||
<article class="stash-row">
|
||||
<div class="stash-row-main">
|
||||
<strong title={stashTitle(stash)}>{stashTitle(stash)}</strong>
|
||||
<span>
|
||||
{stash.selector}
|
||||
{#if stash.branch}
|
||||
on {stash.branch}
|
||||
{/if}
|
||||
{#if stash.date}
|
||||
- {stash.date}
|
||||
{/if}
|
||||
</span>
|
||||
</div>
|
||||
<div class="stash-actions">
|
||||
<button class="btn-sm" type="button" onclick={() => onApply(stash)} disabled={isBusy} title="Apply stash and keep it">
|
||||
<Download size={13} aria-hidden="true" />
|
||||
Apply
|
||||
</button>
|
||||
<button class="btn-sm" type="button" onclick={() => onPop(stash)} disabled={isBusy} title="Apply stash and remove it if successful">
|
||||
<Upload size={13} aria-hidden="true" />
|
||||
Pop
|
||||
</button>
|
||||
<button class="btn-sm danger" type="button" onclick={() => onDrop(stash)} disabled={isBusy} title="Delete stash">
|
||||
<Trash2 size={13} aria-hidden="true" />
|
||||
Drop
|
||||
</button>
|
||||
</div>
|
||||
</article>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
</section>
|
||||
+56
-2
@@ -1,6 +1,7 @@
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
|
||||
import type {
|
||||
CommitAiLocalProfile,
|
||||
CommitAiProvider,
|
||||
CommitAiStatus,
|
||||
ConflictFile,
|
||||
@@ -9,6 +10,7 @@ import type {
|
||||
GitCommitComparison,
|
||||
GitRepositoryFile,
|
||||
GitSearchHit,
|
||||
GitStash,
|
||||
GitStatus,
|
||||
LocalModelOption,
|
||||
PatchApplyAction,
|
||||
@@ -36,10 +38,20 @@ export function getStatus(path: string): Promise<GitStatus> {
|
||||
return invoke<GitStatus>("get_status", { path });
|
||||
}
|
||||
|
||||
// Sets the taskbar icon badge to ahead + behind + changed status files (0 clears it). Windows only — a no-op on
|
||||
// other platforms, since Windows has no native numeric badge to fall back to.
|
||||
export function setSyncBadge(ahead: number, behind: number, changes: number): Promise<void> {
|
||||
return invoke<void>("set_sync_badge", { ahead, behind, changes });
|
||||
}
|
||||
|
||||
export function listBranches(path: string): Promise<GitBranch[]> {
|
||||
return invoke<GitBranch[]>("list_branches", { path });
|
||||
}
|
||||
|
||||
export function listStashes(path: string): Promise<GitStash[]> {
|
||||
return invoke<GitStash[]>("list_stashes", { path });
|
||||
}
|
||||
|
||||
export function checkoutBranch(path: string, branch: string): Promise<GitStatus> {
|
||||
return invoke<GitStatus>("checkout_branch", { path, branch });
|
||||
}
|
||||
@@ -60,8 +72,8 @@ export function renameBranch(
|
||||
return invoke<GitStatus>("rename_branch", { path, oldBranch, newBranch });
|
||||
}
|
||||
|
||||
export function deleteBranch(path: string, branch: string): Promise<GitStatus> {
|
||||
return invoke<GitStatus>("delete_branch", { path, branch });
|
||||
export function deleteBranch(path: string, branch: string, force = false): Promise<GitStatus> {
|
||||
return invoke<GitStatus>("delete_branch", { path, branch, force });
|
||||
}
|
||||
|
||||
export function stageFiles(path: string, files: string[]): Promise<GitStatus> {
|
||||
@@ -97,6 +109,30 @@ export function commit(path: string, message: string): Promise<GitStatus> {
|
||||
return invoke<GitStatus>("commit", { path, message });
|
||||
}
|
||||
|
||||
export function stashPush(
|
||||
path: string,
|
||||
message?: string,
|
||||
includeUntracked = true,
|
||||
): Promise<GitStatus> {
|
||||
return invoke<GitStatus>("stash_push", {
|
||||
path,
|
||||
message: message?.trim() ? message.trim() : null,
|
||||
includeUntracked,
|
||||
});
|
||||
}
|
||||
|
||||
export function stashApply(path: string, selector: string): Promise<GitStatus> {
|
||||
return invoke<GitStatus>("stash_apply", { path, selector });
|
||||
}
|
||||
|
||||
export function stashPop(path: string, selector: string): Promise<GitStatus> {
|
||||
return invoke<GitStatus>("stash_pop", { path, selector });
|
||||
}
|
||||
|
||||
export function stashDrop(path: string, selector: string): Promise<GitStatus> {
|
||||
return invoke<GitStatus>("stash_drop", { path, selector });
|
||||
}
|
||||
|
||||
export function commitAiStatus(): Promise<CommitAiStatus> {
|
||||
return invoke<CommitAiStatus>("commit_ai_status");
|
||||
}
|
||||
@@ -112,6 +148,7 @@ export function commitAiLocalModels(): Promise<LocalModelOption[]> {
|
||||
export interface CommitAiGenerateOptions {
|
||||
notes?: string;
|
||||
provider: CommitAiProvider;
|
||||
localProfile?: CommitAiLocalProfile;
|
||||
model?: string;
|
||||
apiKey?: string;
|
||||
baseUrl?: string;
|
||||
@@ -122,6 +159,7 @@ export function commitAiGenerate(path: string, options: CommitAiGenerateOptions)
|
||||
path,
|
||||
notes: options.notes,
|
||||
provider: options.provider,
|
||||
localProfile: options.localProfile,
|
||||
model: options.model,
|
||||
apiKey: options.apiKey,
|
||||
baseUrl: options.baseUrl,
|
||||
@@ -132,6 +170,10 @@ export function pull(path: string, username?: string, password?: string): Promis
|
||||
return invoke<GitStatus>("pull", { path, username: username ?? null, password: password ?? null });
|
||||
}
|
||||
|
||||
export function fetchRemote(path: string, username?: string, password?: string): Promise<GitStatus> {
|
||||
return invoke<GitStatus>("fetch", { path, username: username ?? null, password: password ?? null });
|
||||
}
|
||||
|
||||
export function push(path: string, username?: string, password?: string): Promise<GitStatus> {
|
||||
return invoke<GitStatus>("push", { path, username: username ?? null, password: password ?? null });
|
||||
}
|
||||
@@ -177,6 +219,18 @@ export function mergeBranch(path: string, branch: string): Promise<GitStatus> {
|
||||
return invoke<GitStatus>("merge_branch", { path, branch });
|
||||
}
|
||||
|
||||
export function rebaseBranch(path: string, branch: string): Promise<GitStatus> {
|
||||
return invoke<GitStatus>("rebase_branch", { path, branch });
|
||||
}
|
||||
|
||||
export function rebaseContinue(path: string): Promise<GitStatus> {
|
||||
return invoke<GitStatus>("rebase_continue", { path });
|
||||
}
|
||||
|
||||
export function rebaseAbort(path: string): Promise<GitStatus> {
|
||||
return invoke<GitStatus>("rebase_abort", { path });
|
||||
}
|
||||
|
||||
export function listRepositoryFiles(path: string): Promise<GitRepositoryFile[]> {
|
||||
return invoke<GitRepositoryFile[]>("list_repository_files", { path });
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ export type FileStatusKind =
|
||||
|
||||
export type CommitAiPhase = "idle" | "loading" | "ready" | "error";
|
||||
export type CommitAiProvider = "local" | "openai" | "anthropic" | "custom";
|
||||
export type CommitAiLocalProfile = "fast" | "balanced" | "detailed";
|
||||
|
||||
export interface CommitAiStatus {
|
||||
phase: CommitAiPhase;
|
||||
@@ -25,6 +26,7 @@ export interface LocalModelOption {
|
||||
export interface AiSettings {
|
||||
provider: CommitAiProvider;
|
||||
localModelId: string;
|
||||
localProfile: CommitAiLocalProfile;
|
||||
openaiModel: string;
|
||||
anthropicModel: string;
|
||||
customBaseUrl: string;
|
||||
@@ -39,6 +41,7 @@ export interface GitStatus {
|
||||
behind: number;
|
||||
files: GitFileStatus[];
|
||||
clean: boolean;
|
||||
rebase_in_progress: boolean;
|
||||
}
|
||||
|
||||
export interface GitFileStatus {
|
||||
@@ -56,6 +59,15 @@ export interface GitBranch {
|
||||
remote: boolean;
|
||||
}
|
||||
|
||||
export interface GitStash {
|
||||
selector: string;
|
||||
index: number;
|
||||
hash: string;
|
||||
branch: string | null;
|
||||
message: string;
|
||||
date: string;
|
||||
}
|
||||
|
||||
export interface GitCommit {
|
||||
hash: string;
|
||||
short_hash: string;
|
||||
@@ -83,6 +95,7 @@ export interface GitRepositoryFile {
|
||||
export interface RepositoryBundle {
|
||||
status: GitStatus;
|
||||
branches: GitBranch[];
|
||||
stashes: GitStash[];
|
||||
commits: GitCommit[];
|
||||
files: GitRepositoryFile[];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user