Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
106cc98afb | ||
|
|
add98f962e | ||
|
|
90df347e4a | ||
|
|
4c58b14691 | ||
|
|
8bec7dfc9a | ||
|
|
7950edb145 | ||
|
|
e3af6653cd | ||
|
|
b752c0804b | ||
|
|
8f98e79df9 | ||
|
|
f0a1d89152 | ||
|
|
c3762ae7a3 | ||
|
|
4db6f30461 |
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "gitty",
|
||||
"version": "2026.8.8",
|
||||
"version": "2026.8.10",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "gitty",
|
||||
"version": "2026.8.8",
|
||||
"version": "2026.8.10",
|
||||
"dependencies": {
|
||||
"@lucide/svelte": "^1.21.0",
|
||||
"@tailwindcss/vite": "^4.3.1",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "gitty",
|
||||
"version": "2026.8.8",
|
||||
"version": "2026.8.10",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
||||
Generated
+38
-3229
File diff suppressed because it is too large
Load Diff
@@ -20,10 +20,11 @@ tauri-plugin-dialog = "=2.7.0"
|
||||
tauri-plugin-aptabase = "1.0"
|
||||
keyring = { version = "3", features = ["apple-native", "windows-native", "async-secret-service", "crypto-rust", "async-io"] }
|
||||
commit_ai = { path = "crates/commit_ai" }
|
||||
tokio = "1.52.3"
|
||||
tokio = { version = "1.52.3", features = ["macros", "rt-multi-thread"] }
|
||||
log = "0.4"
|
||||
reqwest = { version = "0.12", default-features = false, features = ["blocking", "json", "rustls-tls"] }
|
||||
sysinfo = { version = "=0.38.3", default-features = false, features = ["system"] }
|
||||
shlex = "2"
|
||||
|
||||
[build-dependencies]
|
||||
tauri-build = { version = "2", features = [] }
|
||||
|
||||
@@ -5,8 +5,6 @@ version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
mistralrs = "0.8"
|
||||
tokio = { version = "1", features = ["sync"] }
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls"] }
|
||||
|
||||
@@ -5,318 +5,8 @@ pub use cloud::{
|
||||
review_openai, split_anthropic, split_custom, split_openai,
|
||||
};
|
||||
|
||||
use std::{
|
||||
collections::hash_map::DefaultHasher,
|
||||
hash::{Hash, Hasher},
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
use mistralrs::{GgufModelBuilder, Model, RequestBuilder, TextMessageRole};
|
||||
use tokio::sync::RwLock;
|
||||
|
||||
/// One selectable local (on-device) model. Larger models produce better commit messages
|
||||
/// but take longer to download (first run only, then cached) and run slower on CPU.
|
||||
#[derive(Debug, Clone, serde::Serialize)]
|
||||
pub struct LocalModelOption {
|
||||
pub id: &'static str,
|
||||
pub label: &'static str,
|
||||
pub approx_size_mb: u32,
|
||||
repo: &'static str,
|
||||
file: &'static str,
|
||||
tokenizer_repo: &'static str,
|
||||
}
|
||||
|
||||
pub const DEFAULT_LOCAL_MODEL_ID: &str = "qwen2.5-0.5b";
|
||||
|
||||
pub const LOCAL_MODELS: &[LocalModelOption] = &[
|
||||
LocalModelOption {
|
||||
id: "qwen2.5-0.5b",
|
||||
label: "Qwen2.5 0.5B Instruct — fast, lower quality",
|
||||
approx_size_mb: 490,
|
||||
repo: "Qwen/Qwen2.5-0.5B-Instruct-GGUF",
|
||||
file: "qwen2.5-0.5b-instruct-q4_k_m.gguf",
|
||||
tokenizer_repo: "Qwen/Qwen2.5-0.5B-Instruct",
|
||||
},
|
||||
LocalModelOption {
|
||||
id: "qwen2.5-1.5b",
|
||||
label: "Qwen2.5 1.5B Instruct — recommended",
|
||||
approx_size_mb: 1050,
|
||||
repo: "Qwen/Qwen2.5-1.5B-Instruct-GGUF",
|
||||
file: "qwen2.5-1.5b-instruct-q4_k_m.gguf",
|
||||
tokenizer_repo: "Qwen/Qwen2.5-1.5B-Instruct",
|
||||
},
|
||||
LocalModelOption {
|
||||
id: "qwen2.5-3b",
|
||||
label: "Qwen2.5 3B Instruct — best quality, slower",
|
||||
approx_size_mb: 2100,
|
||||
repo: "Qwen/Qwen2.5-3B-Instruct-GGUF",
|
||||
file: "qwen2.5-3b-instruct-q4_k_m.gguf",
|
||||
tokenizer_repo: "Qwen/Qwen2.5-3B-Instruct",
|
||||
},
|
||||
];
|
||||
|
||||
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 {
|
||||
/// Nothing has been requested yet.
|
||||
Idle,
|
||||
/// Downloading (first run only, then cached by hf-hub) and/or loading into memory.
|
||||
Loading,
|
||||
Ready,
|
||||
Error,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize)]
|
||||
pub struct CommitAiStatus {
|
||||
pub phase: CommitAiPhase,
|
||||
pub model_id: Option<String>,
|
||||
pub error: Option<String>,
|
||||
}
|
||||
|
||||
struct Inner {
|
||||
phase: CommitAiPhase,
|
||||
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
|
||||
/// (see [`cloud`]) and don't need this — there's nothing to download or keep loaded.
|
||||
#[derive(Clone)]
|
||||
pub struct CommitAiEngine {
|
||||
inner: Arc<RwLock<Inner>>,
|
||||
}
|
||||
|
||||
impl Default for CommitAiEngine {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
inner: Arc::new(RwLock::new(Inner {
|
||||
phase: CommitAiPhase::Idle,
|
||||
model_id: None,
|
||||
error: None,
|
||||
model: None,
|
||||
cache: None,
|
||||
})),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CommitAiEngine {
|
||||
pub fn new() -> Self {
|
||||
Self::default()
|
||||
}
|
||||
|
||||
pub async fn status(&self) -> CommitAiStatus {
|
||||
let guard = self.inner.read().await;
|
||||
CommitAiStatus {
|
||||
phase: guard.phase,
|
||||
model_id: guard.model_id.clone(),
|
||||
error: guard.error.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Downloads (first run only; hf-hub caches the files afterwards) and loads the given
|
||||
/// local model. Safe to call repeatedly — a call for the model that's already
|
||||
/// ready/loading is a no-op; a call for a *different* model switches to it (the
|
||||
/// previous one is dropped once no generation is still using it).
|
||||
pub async fn ensure_loaded(&self, model_id: &str) {
|
||||
{
|
||||
let guard = self.inner.read().await;
|
||||
let same_model = guard.model_id.as_deref() == Some(model_id);
|
||||
if same_model && matches!(guard.phase, CommitAiPhase::Ready | CommitAiPhase::Loading) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
let Some(option) = find_local_model(model_id) else {
|
||||
let mut guard = self.inner.write().await;
|
||||
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;
|
||||
};
|
||||
|
||||
{
|
||||
let mut guard = self.inner.write().await;
|
||||
guard.phase = CommitAiPhase::Loading;
|
||||
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])
|
||||
.with_tok_model_id(option.tokenizer_repo)
|
||||
.with_logging()
|
||||
.build()
|
||||
.await;
|
||||
|
||||
let mut guard = self.inner.write().await;
|
||||
// If the user switched to yet another model while this one was loading, drop this
|
||||
// (now stale) result instead of overwriting the newer request's state.
|
||||
if guard.model_id.as_deref() != Some(model_id) {
|
||||
return;
|
||||
}
|
||||
match result {
|
||||
Ok(model) => {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn generate_commit_message(
|
||||
&self,
|
||||
diff: &str,
|
||||
notes: Option<&str>,
|
||||
profile: LocalGenerationProfile,
|
||||
) -> Result<String, String> {
|
||||
let (model, cache_key) = {
|
||||
let guard = self.inner.read().await;
|
||||
match (guard.phase, &guard.model) {
|
||||
(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_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(request)
|
||||
.await
|
||||
.map_err(|err| err.to_string())?;
|
||||
|
||||
let content = response
|
||||
.choices
|
||||
.first()
|
||||
.and_then(|choice| choice.message.content.clone())
|
||||
.ok_or_else(|| "The model did not return a response.".to_string())?;
|
||||
|
||||
let message = sanitize_message(&content);
|
||||
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.
|
||||
/// Strip a wrapping code fence and wrapping quotes so the result can go straight into
|
||||
/// the commit-message box.
|
||||
pub(crate) fn sanitize_message(raw: &str) -> String {
|
||||
let mut text = raw.trim().to_string();
|
||||
if text.starts_with("```") {
|
||||
@@ -333,9 +23,9 @@ 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.
|
||||
/// Some models echo the prompt's diff sections 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")
|
||||
@@ -358,55 +48,12 @@ fn truncate_at_char_boundary(input: &str, max_chars: usize) -> String {
|
||||
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());
|
||||
}
|
||||
|
||||
// Rough token estimate — small models often have an 8-32k context window.
|
||||
// Rough token estimate to keep requests within common context windows.
|
||||
const MAX_CHARS: usize = 24_000;
|
||||
let diff = truncate_at_char_boundary(diff, MAX_CHARS);
|
||||
|
||||
|
||||
+537
-110
@@ -578,6 +578,25 @@ fn repository_bundle_for_repo(
|
||||
// branches -> tags -> stashes -> commits -> files waterfall down to the
|
||||
// duration of its slowest member.
|
||||
let status = status_for_repo(repo)?;
|
||||
|
||||
// A freshly initialized or cloned empty repository has a symbolic HEAD,
|
||||
// but it does not resolve to a commit yet (an "unborn" HEAD). Some Git
|
||||
// commands and Git extensions treat that as a hard revision error. Keep
|
||||
// the repository usable and still report any untracked working-tree files
|
||||
// without starting commit-dependent workers.
|
||||
if verify_commit(repo, "HEAD").is_err() {
|
||||
let files = repository_files_with_status(repo, &status)?;
|
||||
return Ok(RepositoryBundle {
|
||||
status,
|
||||
branches: Vec::new(),
|
||||
tags: Vec::new(),
|
||||
stashes: Vec::new(),
|
||||
commits: Vec::new(),
|
||||
files,
|
||||
warning: None,
|
||||
});
|
||||
}
|
||||
|
||||
let (branches, tags, stashes, commits, files) = thread::scope(|scope| -> Result<_, String> {
|
||||
let branches = scope.spawn(|| branches_for_repo(repo));
|
||||
let tags = scope.spawn(|| tags_for_repo(repo));
|
||||
@@ -613,8 +632,24 @@ pub async fn clone_repository(
|
||||
username: Option<String>,
|
||||
password: Option<String>,
|
||||
commit_limit: Option<u32>,
|
||||
branch: Option<String>,
|
||||
blobless: Option<bool>,
|
||||
custom_flags: Option<String>,
|
||||
shallow_depth: Option<u32>,
|
||||
shallow_since: Option<String>,
|
||||
sparse: Option<bool>,
|
||||
sparse_paths: Option<Vec<String>>,
|
||||
) -> Result<RepositoryBundle, String> {
|
||||
tauri::async_runtime::spawn_blocking(move || {
|
||||
let clone_options = CloneRunOptions {
|
||||
branch,
|
||||
blobless: blobless.unwrap_or(false),
|
||||
custom_flags: custom_flags.unwrap_or_default(),
|
||||
shallow_depth,
|
||||
shallow_since,
|
||||
sparse: sparse.unwrap_or(false),
|
||||
sparse_paths: sparse_paths.unwrap_or_default(),
|
||||
};
|
||||
clone_repository_core(
|
||||
&remote_url,
|
||||
&parent_path,
|
||||
@@ -622,6 +657,7 @@ pub async fn clone_repository(
|
||||
username.as_deref(),
|
||||
password.as_deref(),
|
||||
commit_limit,
|
||||
&clone_options,
|
||||
)
|
||||
})
|
||||
.await
|
||||
@@ -2117,28 +2153,6 @@ pub fn get_file_patch(path: String, file: String, staged: bool) -> Result<String
|
||||
Ok(String::from_utf8_lossy(&output).to_string())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn commit_ai_local_models() -> Vec<commit_ai::LocalModelOption> {
|
||||
commit_ai::LOCAL_MODELS.to_vec()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn commit_ai_status(
|
||||
engine: tauri::State<'_, commit_ai::CommitAiEngine>,
|
||||
) -> Result<commit_ai::CommitAiStatus, String> {
|
||||
Ok(engine.status().await)
|
||||
}
|
||||
|
||||
/// Kicks off the (first-run-only) download and model load in the background and returns
|
||||
/// immediately; the frontend polls `commit_ai_status` to know when it's ready.
|
||||
#[tauri::command]
|
||||
pub fn commit_ai_load(model_id: String, engine: tauri::State<'_, commit_ai::CommitAiEngine>) {
|
||||
let engine = engine.inner().clone();
|
||||
tauri::async_runtime::spawn(async move {
|
||||
engine.ensure_loaded(&model_id).await;
|
||||
});
|
||||
}
|
||||
|
||||
// The prompt is built from `git diff --cached` only, i.e. exactly the staged changes —
|
||||
// unstaged edits and untracked files never influence the generated message.
|
||||
fn staged_diff(repo: &Path) -> Result<String, String> {
|
||||
@@ -2147,8 +2161,8 @@ fn staged_diff(repo: &Path) -> 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();
|
||||
|
||||
// Generated lockfiles say nothing useful about intent but easily blow the small
|
||||
// context window of local models, so keep them out of the detailed diff.
|
||||
// Generated lockfiles say little about intent and can easily dominate the context,
|
||||
// so keep them out of the detailed diff.
|
||||
let diff = run_git(
|
||||
repo,
|
||||
[
|
||||
@@ -2178,50 +2192,6 @@ 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,
|
||||
@@ -2230,27 +2200,15 @@ 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 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 diff = 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, 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());
|
||||
@@ -2420,7 +2378,6 @@ pub async fn commit_ai_split(
|
||||
)
|
||||
.await?
|
||||
}
|
||||
"local" => return Err("Commit splitting currently requires an API provider.".to_string()),
|
||||
other => return Err(format!("Unknown AI provider: {other}")),
|
||||
};
|
||||
parse_ai_commit_plan(&raw, &staged_files)
|
||||
@@ -2522,7 +2479,6 @@ pub async fn commit_ai_review(
|
||||
let model = model.ok_or_else(|| "Model name is missing.".to_string())?;
|
||||
commit_ai::review_custom(&base_url, api_key.as_deref(), &model, &diff).await?
|
||||
}
|
||||
"local" => return Err("Pre-commit review currently requires an API provider.".to_string()),
|
||||
other => return Err(format!("Unknown AI provider: {other}")),
|
||||
};
|
||||
parse_ai_review(&raw)
|
||||
@@ -2654,32 +2610,23 @@ pub async fn pull(
|
||||
strategy: Option<String>,
|
||||
remote: Option<String>,
|
||||
branch: Option<String>,
|
||||
allow_unrelated_histories: Option<bool>,
|
||||
) -> Result<GitStatus, String> {
|
||||
tauri::async_runtime::spawn_blocking(move || -> Result<GitStatus, String> {
|
||||
let repo = resolve_repo(&path)?;
|
||||
let strategy = strategy.as_deref().unwrap_or("merge");
|
||||
let remote = remote
|
||||
.map(|value| value.trim().to_string())
|
||||
.filter(|value| !value.is_empty());
|
||||
let mut pull_args = vec![OsString::from("pull")];
|
||||
match strategy {
|
||||
"merge" => {
|
||||
pull_args.extend([OsString::from("--no-rebase"), OsString::from("--no-edit")])
|
||||
}
|
||||
"rebase" => pull_args.push(OsString::from("--rebase")),
|
||||
"ff-only" => pull_args.push(OsString::from("--ff-only")),
|
||||
_ => return Err("Unknown pull strategy.".to_string()),
|
||||
}
|
||||
if let Some(remote_name) = remote.as_deref() {
|
||||
validate_remote_name(&repo, remote_name, true)?;
|
||||
pull_args.push(remote_name.into());
|
||||
if let Some(branch) = branch
|
||||
.map(|v| v.trim().to_string())
|
||||
.filter(|v| !v.is_empty())
|
||||
{
|
||||
pull_args.push(branch.into());
|
||||
}
|
||||
}
|
||||
let branch = branch
|
||||
.map(|value| value.trim().to_string())
|
||||
.filter(|value| !value.is_empty());
|
||||
let pull_args = pull_args_for_repo(
|
||||
&repo,
|
||||
strategy.as_deref().unwrap_or("merge"),
|
||||
remote.as_deref(),
|
||||
branch.as_deref(),
|
||||
allow_unrelated_histories.unwrap_or(false),
|
||||
)?;
|
||||
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, pull_args.clone(), u, p)?
|
||||
@@ -2718,6 +2665,39 @@ pub async fn pull(
|
||||
.map_err(|err| format!("Could not pull: {err}"))?
|
||||
}
|
||||
|
||||
fn pull_args_for_repo(
|
||||
repo: &Path,
|
||||
strategy: &str,
|
||||
remote: Option<&str>,
|
||||
branch: Option<&str>,
|
||||
allow_unrelated_histories: bool,
|
||||
) -> Result<Vec<OsString>, String> {
|
||||
let mut pull_args = vec![OsString::from("pull")];
|
||||
match strategy {
|
||||
"merge" => {
|
||||
pull_args.extend([OsString::from("--no-rebase"), OsString::from("--no-edit")]);
|
||||
if allow_unrelated_histories {
|
||||
pull_args.push(OsString::from("--allow-unrelated-histories"));
|
||||
}
|
||||
}
|
||||
"rebase" => pull_args.push(OsString::from("--rebase")),
|
||||
"ff-only" => pull_args.push(OsString::from("--ff-only")),
|
||||
_ => return Err("Unknown pull strategy.".to_string()),
|
||||
}
|
||||
if let Some(remote_name) = remote.map(str::trim).filter(|value| !value.is_empty()) {
|
||||
validate_remote_name(repo, remote_name, true)?;
|
||||
pull_args.push(remote_name.into());
|
||||
let branch = branch
|
||||
.map(str::trim)
|
||||
.filter(|value| !value.is_empty())
|
||||
.map(ToString::to_string)
|
||||
.map(Ok)
|
||||
.unwrap_or_else(|| current_branch_name(repo))?;
|
||||
pull_args.push(branch.into());
|
||||
}
|
||||
Ok(pull_args)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn fetch(
|
||||
path: String,
|
||||
@@ -3010,7 +2990,9 @@ fn first_remote_name(repo: &Path) -> Option<String> {
|
||||
}
|
||||
|
||||
fn current_branch_name(repo: &Path) -> Result<String, String> {
|
||||
let branch = run_git(repo, ["rev-parse", "--abbrev-ref", "HEAD"])?;
|
||||
// `symbolic-ref` also works before the first commit, while
|
||||
// `rev-parse --abbrev-ref HEAD` fails for an unborn HEAD.
|
||||
let branch = run_git(repo, ["symbolic-ref", "--quiet", "--short", "HEAD"])?;
|
||||
let branch = String::from_utf8_lossy(&branch).trim().to_string();
|
||||
if branch.is_empty() || branch == "HEAD" {
|
||||
return Err("Could not determine current branch.".to_string());
|
||||
@@ -5440,8 +5422,20 @@ fn repository_files_with_status(
|
||||
) -> Result<Vec<GitRepositoryFile>, String> {
|
||||
let mut files = BTreeMap::<String, GitRepositoryFile>::new();
|
||||
|
||||
let tracked_output = run_git(repo, ["ls-files", "-z", "--cached", "--deleted"])?;
|
||||
for path in parse_nul_paths(&tracked_output) {
|
||||
let tracked_output = run_git(repo, ["ls-files", "-z", "-t", "--cached", "--deleted"])?;
|
||||
for entry in tracked_output
|
||||
.split(|byte| *byte == 0)
|
||||
.filter(|entry| !entry.is_empty())
|
||||
{
|
||||
let (tag, path_bytes) = if entry.len() >= 2 && entry[1] == b' ' {
|
||||
(entry[0], &entry[2..])
|
||||
} else {
|
||||
(b'H', entry)
|
||||
};
|
||||
if tag == b'S' {
|
||||
continue;
|
||||
}
|
||||
let path = String::from_utf8_lossy(path_bytes).into_owned();
|
||||
let status = status_for_file(&status.files, &path);
|
||||
files.insert(
|
||||
path.clone(),
|
||||
@@ -5469,6 +5463,17 @@ fn repository_files_with_status(
|
||||
Ok(files.into_values().collect())
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
struct CloneRunOptions {
|
||||
branch: Option<String>,
|
||||
blobless: bool,
|
||||
custom_flags: String,
|
||||
shallow_depth: Option<u32>,
|
||||
shallow_since: Option<String>,
|
||||
sparse: bool,
|
||||
sparse_paths: Vec<String>,
|
||||
}
|
||||
|
||||
fn clone_repository_core(
|
||||
remote_url: &str,
|
||||
parent_path: &str,
|
||||
@@ -5476,12 +5481,20 @@ fn clone_repository_core(
|
||||
username: Option<&str>,
|
||||
password: Option<&str>,
|
||||
commit_limit: Option<u32>,
|
||||
clone_options: &CloneRunOptions,
|
||||
) -> Result<RepositoryBundle, String> {
|
||||
let target = clone_target_path(remote_url, parent_path, directory_name)?;
|
||||
run_git_clone(remote_url.trim(), &target, username, password)?;
|
||||
run_git_clone(
|
||||
remote_url.trim(),
|
||||
&target,
|
||||
username,
|
||||
password,
|
||||
clone_options,
|
||||
)?;
|
||||
|
||||
let repo = resolve_repo(&target.to_string_lossy())?;
|
||||
let lfs_warning = sync_git_lfs_objects_if_needed(
|
||||
let lfs_warning = if verify_commit(&repo, "HEAD").is_ok() {
|
||||
sync_git_lfs_objects_if_needed(
|
||||
&repo,
|
||||
Some("origin"),
|
||||
username,
|
||||
@@ -5493,7 +5506,13 @@ fn clone_repository_core(
|
||||
format!(
|
||||
"Repository cloned, but Git LFS objects could not be downloaded automatically: {error}"
|
||||
)
|
||||
});
|
||||
})
|
||||
} else {
|
||||
// There cannot be LFS pointers to download before the first commit.
|
||||
// In particular, avoid Git LFS implementations that try to resolve
|
||||
// HEAD themselves and fail on an empty repository.
|
||||
None
|
||||
};
|
||||
|
||||
let mut bundle = repository_bundle_for_repo(&repo, commit_limit)?;
|
||||
bundle.warning = lfs_warning;
|
||||
@@ -5592,7 +5611,21 @@ fn run_git_clone(
|
||||
target: &Path,
|
||||
username: Option<&str>,
|
||||
password: Option<&str>,
|
||||
clone_options: &CloneRunOptions,
|
||||
) -> Result<(), String> {
|
||||
if matches!(clone_options.shallow_depth, Some(0)) {
|
||||
return Err("Shallow clone depth must be at least 1.".to_string());
|
||||
}
|
||||
if clone_options.shallow_depth.is_some() && clone_options.shallow_since.is_some() {
|
||||
return Err(
|
||||
"Choose either shallow clone depth or shallow clone date, not both.".to_string(),
|
||||
);
|
||||
}
|
||||
let branch = validate_clone_branch(clone_options.branch.as_deref())?;
|
||||
let shallow_since = validate_shallow_since(clone_options.shallow_since.as_deref())?;
|
||||
let custom_flags = parse_custom_clone_flags(&clone_options.custom_flags)?;
|
||||
let sparse_paths = validate_sparse_checkout_paths(&clone_options.sparse_paths)?;
|
||||
let sparse_enabled = clone_options.sparse || !sparse_paths.is_empty();
|
||||
let mut command = git_command();
|
||||
let has_explicit_credentials = matches!(
|
||||
(username, password),
|
||||
@@ -5601,8 +5634,24 @@ fn run_git_clone(
|
||||
if has_explicit_credentials {
|
||||
command.arg("-c").arg("credential.helper=");
|
||||
}
|
||||
command.arg("clone");
|
||||
if let Some(branch) = branch {
|
||||
command.arg("--branch").arg(branch);
|
||||
}
|
||||
if let Some(depth) = clone_options.shallow_depth {
|
||||
command.arg("--depth").arg(depth.to_string());
|
||||
}
|
||||
if let Some(since) = shallow_since {
|
||||
command.arg("--shallow-since").arg(since);
|
||||
}
|
||||
if clone_options.blobless {
|
||||
command.arg("--filter=blob:none");
|
||||
}
|
||||
if sparse_enabled {
|
||||
command.arg("--sparse");
|
||||
}
|
||||
command.args(custom_flags);
|
||||
command
|
||||
.arg("clone")
|
||||
.arg("--")
|
||||
.arg(remote_url)
|
||||
.arg(target)
|
||||
@@ -5629,6 +5678,9 @@ fn run_git_clone(
|
||||
let output = output?;
|
||||
|
||||
if output.status.success() {
|
||||
if !sparse_paths.is_empty() {
|
||||
configure_sparse_checkout(target, &sparse_paths)?;
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
@@ -5640,6 +5692,104 @@ fn run_git_clone(
|
||||
Err(format!("Git clone failed: {}", details))
|
||||
}
|
||||
|
||||
fn validate_clone_branch(branch: Option<&str>) -> Result<Option<String>, String> {
|
||||
let Some(branch) = branch.map(str::trim).filter(|value| !value.is_empty()) else {
|
||||
return Ok(None);
|
||||
};
|
||||
if branch.starts_with('-') || branch.chars().any(|character| character.is_control()) {
|
||||
return Err("Branch to clone contains invalid characters.".to_string());
|
||||
}
|
||||
Ok(Some(branch.to_string()))
|
||||
}
|
||||
|
||||
fn validate_shallow_since(since: Option<&str>) -> Result<Option<String>, String> {
|
||||
let Some(since) = since.map(str::trim).filter(|value| !value.is_empty()) else {
|
||||
return Ok(None);
|
||||
};
|
||||
if since.starts_with('-') || since.chars().any(|character| character.is_control()) {
|
||||
return Err("Shallow clone date contains invalid characters.".to_string());
|
||||
}
|
||||
Ok(Some(since.to_string()))
|
||||
}
|
||||
|
||||
fn parse_custom_clone_flags(input: &str) -> Result<Vec<String>, String> {
|
||||
let input = input.trim();
|
||||
if input.is_empty() {
|
||||
return Ok(Vec::new());
|
||||
}
|
||||
let flags = shlex::split(input).ok_or_else(|| {
|
||||
"Custom clone flags contain an unclosed quote or invalid escape.".to_string()
|
||||
})?;
|
||||
const BLOCKED_LONG_FLAGS: &[&str] = &[
|
||||
"--bare",
|
||||
"--branch",
|
||||
"--config",
|
||||
"--depth",
|
||||
"--filter",
|
||||
"--mirror",
|
||||
"--no-checkout",
|
||||
"--reference",
|
||||
"--reference-if-able",
|
||||
"--separate-git-dir",
|
||||
"--shallow-exclude",
|
||||
"--shallow-since",
|
||||
"--sparse",
|
||||
"--template",
|
||||
"--upload-pack",
|
||||
];
|
||||
for flag in &flags {
|
||||
let name = flag.split_once('=').map_or(flag.as_str(), |(name, _)| name);
|
||||
if flag == "--"
|
||||
|| BLOCKED_LONG_FLAGS.contains(&name)
|
||||
|| matches!(name, "-b" | "-c" | "-n" | "-u")
|
||||
{
|
||||
return Err(format!(
|
||||
"Custom clone flag '{name}' is managed by Gitty or is not allowed."
|
||||
));
|
||||
}
|
||||
}
|
||||
Ok(flags)
|
||||
}
|
||||
|
||||
fn validate_sparse_checkout_paths(paths: &[String]) -> Result<Vec<String>, String> {
|
||||
let mut unique = BTreeSet::new();
|
||||
for raw_path in paths {
|
||||
let path = raw_path.trim();
|
||||
if path.is_empty() {
|
||||
continue;
|
||||
}
|
||||
if path.chars().any(|character| character.is_control()) {
|
||||
return Err("Sparse checkout paths contain invalid control characters.".to_string());
|
||||
}
|
||||
if Path::new(path).is_absolute()
|
||||
|| path == ".."
|
||||
|| path.starts_with("../")
|
||||
|| path.starts_with("..\\")
|
||||
{
|
||||
return Err("Sparse checkout paths must be relative to the repository.".to_string());
|
||||
}
|
||||
unique.insert(path.to_string());
|
||||
}
|
||||
if paths.len() > 0 && unique.is_empty() {
|
||||
return Err("Enter at least one sparse checkout path.".to_string());
|
||||
}
|
||||
Ok(unique.into_iter().collect())
|
||||
}
|
||||
|
||||
fn configure_sparse_checkout(target: &Path, paths: &[String]) -> Result<(), String> {
|
||||
let mut stdin = paths.join("\n");
|
||||
stdin.push('\n');
|
||||
run_git_with_stdin(
|
||||
target,
|
||||
["sparse-checkout", "set", "--no-cone", "--stdin"],
|
||||
stdin.as_bytes(),
|
||||
)
|
||||
.map(|_| ())
|
||||
.map_err(|error| {
|
||||
format!("Repository cloned, but sparse checkout could not be configured: {error}")
|
||||
})
|
||||
}
|
||||
|
||||
fn is_repository_folder_path(repo: &Path, path: &str) -> Result<bool, String> {
|
||||
let normalized = normalize_git_path(path);
|
||||
if repo.join(path).is_dir() {
|
||||
@@ -7823,6 +7973,7 @@ mod tests {
|
||||
None,
|
||||
None,
|
||||
Some(100),
|
||||
&CloneRunOptions::default(),
|
||||
)
|
||||
.expect("repository should clone");
|
||||
|
||||
@@ -7840,6 +7991,178 @@ mod tests {
|
||||
assert!(bundle.warning.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg_attr(windows, ignore = "file:// clone URL differs on Windows")]
|
||||
fn clone_repository_core_supports_shallow_and_sparse_options() {
|
||||
let source = init_temp_repo("clone_options_source");
|
||||
commit_initial_file(&source.path);
|
||||
fs::create_dir_all(source.path.join("src")).expect("src directory should be created");
|
||||
fs::create_dir_all(source.path.join("docs")).expect("docs directory should be created");
|
||||
fs::write(source.path.join("src/included.txt"), b"included\n")
|
||||
.expect("included fixture should be written");
|
||||
fs::write(source.path.join("docs/excluded.txt"), b"excluded\n")
|
||||
.expect("excluded fixture should be written");
|
||||
run_git_test(
|
||||
&source.path,
|
||||
["add", "src/included.txt", "docs/excluded.txt"],
|
||||
);
|
||||
run_git_test(&source.path, ["commit", "-q", "-m", "add sparse fixtures"]);
|
||||
fs::write(source.path.join("src/included.txt"), b"latest\n")
|
||||
.expect("latest fixture should be written");
|
||||
run_git_test(&source.path, ["add", "src/included.txt"]);
|
||||
run_git_test(
|
||||
&source.path,
|
||||
["commit", "-q", "-m", "update included fixture"],
|
||||
);
|
||||
|
||||
let parent = temp_dir("clone_options_parent");
|
||||
let remote_url = format!("file://{}", source.path.display());
|
||||
let branch = git_output_test(&source.path, ["branch", "--show-current"]);
|
||||
let clone_options = CloneRunOptions {
|
||||
branch: Some(branch),
|
||||
blobless: true,
|
||||
custom_flags: "--single-branch".to_string(),
|
||||
shallow_depth: Some(1),
|
||||
shallow_since: None,
|
||||
sparse: true,
|
||||
sparse_paths: vec!["src/".to_string()],
|
||||
};
|
||||
let bundle = clone_repository_core(
|
||||
&remote_url,
|
||||
parent.path.to_str().expect("parent path should be UTF-8"),
|
||||
Some("local-copy"),
|
||||
None,
|
||||
None,
|
||||
Some(100),
|
||||
&clone_options,
|
||||
)
|
||||
.expect("repository should clone shallow and sparse");
|
||||
|
||||
let cloned_repo = parent.path.join("local-copy");
|
||||
assert!(cloned_repo.join(".git/shallow").exists());
|
||||
assert!(cloned_repo.join("src/included.txt").exists());
|
||||
assert!(!cloned_repo.join("docs/excluded.txt").exists());
|
||||
assert_eq!(bundle.commits.len(), 1);
|
||||
assert!(
|
||||
bundle
|
||||
.files
|
||||
.iter()
|
||||
.any(|file| file.path == "src/included.txt")
|
||||
);
|
||||
assert!(
|
||||
!bundle
|
||||
.files
|
||||
.iter()
|
||||
.any(|file| file.path == "docs/excluded.txt")
|
||||
);
|
||||
|
||||
let root_only_parent = temp_dir("clone_sparse_root_parent");
|
||||
let root_only_bundle = clone_repository_core(
|
||||
&remote_url,
|
||||
root_only_parent
|
||||
.path
|
||||
.to_str()
|
||||
.expect("root-only parent path should be UTF-8"),
|
||||
Some("local-copy"),
|
||||
None,
|
||||
None,
|
||||
Some(100),
|
||||
&CloneRunOptions {
|
||||
sparse: true,
|
||||
..CloneRunOptions::default()
|
||||
},
|
||||
)
|
||||
.expect("repository should clone sparse with root files only");
|
||||
let root_only_repo = root_only_parent.path.join("local-copy");
|
||||
assert!(root_only_repo.join("old.txt").exists());
|
||||
assert!(!root_only_repo.join("src/included.txt").exists());
|
||||
assert!(!root_only_repo.join("docs/excluded.txt").exists());
|
||||
assert!(
|
||||
root_only_bundle
|
||||
.files
|
||||
.iter()
|
||||
.any(|file| file.path == "old.txt")
|
||||
);
|
||||
assert!(
|
||||
!root_only_bundle
|
||||
.files
|
||||
.iter()
|
||||
.any(|file| file.path == "src/included.txt")
|
||||
);
|
||||
|
||||
let since_parent = temp_dir("clone_since_parent");
|
||||
let since_options = CloneRunOptions {
|
||||
branch: clone_options.branch.clone(),
|
||||
shallow_since: Some("2000-01-01".to_string()),
|
||||
..CloneRunOptions::default()
|
||||
};
|
||||
let since_bundle = clone_repository_core(
|
||||
&remote_url,
|
||||
since_parent
|
||||
.path
|
||||
.to_str()
|
||||
.expect("since parent path should be UTF-8"),
|
||||
Some("local-copy"),
|
||||
None,
|
||||
None,
|
||||
Some(100),
|
||||
&since_options,
|
||||
)
|
||||
.expect("repository should clone with a shallow-since date");
|
||||
assert_eq!(since_bundle.status.current_branch, clone_options.branch);
|
||||
assert!(
|
||||
since_parent
|
||||
.path
|
||||
.join("local-copy/src/included.txt")
|
||||
.exists()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn custom_clone_flags_are_parsed_without_a_shell_and_managed_flags_are_rejected() {
|
||||
assert_eq!(
|
||||
parse_custom_clone_flags("--recurse-submodules --origin 'team remote'")
|
||||
.expect("custom flags should parse"),
|
||||
vec!["--recurse-submodules", "--origin", "team remote"]
|
||||
);
|
||||
assert!(parse_custom_clone_flags("--depth 5").is_err());
|
||||
assert!(parse_custom_clone_flags("--upload-pack=/tmp/helper").is_err());
|
||||
assert!(parse_custom_clone_flags("--config core.hooksPath=/tmp/hooks").is_err());
|
||||
assert!(parse_custom_clone_flags("--recurse-submodules '").is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn clone_repository_core_supports_empty_repository() {
|
||||
let source = init_bare_temp_repo("empty_clone_source");
|
||||
let parent = temp_dir("empty_clone_parent");
|
||||
|
||||
let bundle = clone_repository_core(
|
||||
source.path.to_str().expect("source path should be UTF-8"),
|
||||
parent.path.to_str().expect("parent path should be UTF-8"),
|
||||
Some("local-copy"),
|
||||
None,
|
||||
None,
|
||||
Some(100),
|
||||
&CloneRunOptions::default(),
|
||||
)
|
||||
.expect("empty repository should clone");
|
||||
|
||||
let cloned_repo = parent.path.join("local-copy");
|
||||
assert_eq!(
|
||||
PathBuf::from(bundle.status.repo_path),
|
||||
cloned_repo
|
||||
.canonicalize()
|
||||
.expect("clone path should resolve")
|
||||
);
|
||||
assert!(bundle.status.clean);
|
||||
assert!(bundle.commits.is_empty());
|
||||
assert!(bundle.branches.is_empty());
|
||||
assert!(bundle.tags.is_empty());
|
||||
assert!(bundle.stashes.is_empty());
|
||||
assert!(bundle.files.is_empty());
|
||||
assert!(bundle.warning.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg_attr(
|
||||
windows,
|
||||
@@ -7879,6 +8202,7 @@ mod tests {
|
||||
None,
|
||||
None,
|
||||
Some(100),
|
||||
&CloneRunOptions::default(),
|
||||
)
|
||||
.expect("LFS repository should clone");
|
||||
let cloned_repo = parent.path.join("local-copy");
|
||||
@@ -8538,6 +8862,108 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pull_with_selected_remote_infers_current_branch() {
|
||||
let repo = init_temp_repo("pull_selected_remote");
|
||||
let branch = git_output_test(&repo.path, ["symbolic-ref", "--short", "HEAD"]);
|
||||
run_git_test(&repo.path, ["remote", "add", "origin", "."]);
|
||||
|
||||
let args = pull_args_for_repo(&repo.path, "merge", Some("origin"), None, false)
|
||||
.expect("pull arguments should be created");
|
||||
|
||||
assert_eq!(
|
||||
args,
|
||||
vec![
|
||||
OsString::from("pull"),
|
||||
OsString::from("--no-rebase"),
|
||||
OsString::from("--no-edit"),
|
||||
OsString::from("origin"),
|
||||
OsString::from(branch),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pull_can_explicitly_allow_unrelated_histories_for_merge() {
|
||||
let repo = init_temp_repo("pull_unrelated_histories");
|
||||
let branch = git_output_test(&repo.path, ["symbolic-ref", "--short", "HEAD"]);
|
||||
run_git_test(&repo.path, ["remote", "add", "origin", "."]);
|
||||
|
||||
let args = pull_args_for_repo(&repo.path, "merge", Some("origin"), None, true)
|
||||
.expect("pull arguments should be created");
|
||||
|
||||
assert_eq!(
|
||||
args,
|
||||
vec![
|
||||
OsString::from("pull"),
|
||||
OsString::from("--no-rebase"),
|
||||
OsString::from("--no-edit"),
|
||||
OsString::from("--allow-unrelated-histories"),
|
||||
OsString::from("origin"),
|
||||
OsString::from(branch),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[cfg_attr(
|
||||
windows,
|
||||
ignore = "Git for Windows can fail local pull tests with a sh signal pipe error"
|
||||
)]
|
||||
async fn pull_retries_unrelated_histories_only_after_explicit_opt_in() {
|
||||
let remote = init_temp_repo("pull_unrelated_remote");
|
||||
fs::write(remote.path.join("remote.txt"), "remote history\n")
|
||||
.expect("remote file should be written");
|
||||
run_git_test(&remote.path, ["add", "remote.txt"]);
|
||||
run_git_test(&remote.path, ["commit", "-q", "-m", "remote init"]);
|
||||
let remote_branch = git_output_test(&remote.path, ["branch", "--show-current"]);
|
||||
|
||||
let local = init_temp_repo("pull_unrelated_local");
|
||||
fs::write(local.path.join("local.txt"), "local history\n")
|
||||
.expect("local file should be written");
|
||||
run_git_test(&local.path, ["add", "local.txt"]);
|
||||
run_git_test(&local.path, ["commit", "-q", "-m", "local init"]);
|
||||
run_git_test(
|
||||
&local.path,
|
||||
["remote", "add", "origin", remote.path.to_str().unwrap()],
|
||||
);
|
||||
|
||||
let error = pull(
|
||||
local.path.to_string_lossy().to_string(),
|
||||
None,
|
||||
None,
|
||||
Some("merge".to_string()),
|
||||
Some("origin".to_string()),
|
||||
Some(remote_branch.clone()),
|
||||
Some(false),
|
||||
)
|
||||
.await
|
||||
.expect_err("unrelated histories should require explicit opt-in");
|
||||
assert!(error.contains("refusing to merge unrelated histories"));
|
||||
|
||||
let status = pull(
|
||||
local.path.to_string_lossy().to_string(),
|
||||
None,
|
||||
None,
|
||||
Some("merge".to_string()),
|
||||
Some("origin".to_string()),
|
||||
Some(remote_branch),
|
||||
Some(true),
|
||||
)
|
||||
.await
|
||||
.expect("explicitly allowed histories should merge");
|
||||
|
||||
assert!(status.clean, "{:?}", status.files);
|
||||
assert!(local.path.join("local.txt").exists());
|
||||
assert!(local.path.join("remote.txt").exists());
|
||||
let parent_count =
|
||||
git_output_test(&local.path, ["rev-list", "--parents", "-n", "1", "HEAD"])
|
||||
.split_whitespace()
|
||||
.count()
|
||||
- 1;
|
||||
assert_eq!(parent_count, 2);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[cfg_attr(
|
||||
windows,
|
||||
@@ -8580,6 +9006,7 @@ mod tests {
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
+17
-22
@@ -14,24 +14,23 @@ use git::{
|
||||
SearchCancellationState, add_remote, add_to_gitignore, add_worktree, amend_commit,
|
||||
apply_file_patch, cancel_code_search, cancel_file_history, checkout_branch, cherry_pick_abort,
|
||||
cherry_pick_commit, cherry_pick_continue, clone_repository, commit, commit_ai_generate,
|
||||
commit_ai_load, commit_ai_local_models, commit_ai_review, commit_ai_split, commit_ai_status,
|
||||
compare_commits, compare_file_to_head, compare_file_to_parent, create_branch, create_tag,
|
||||
cred_delete, cred_load, cred_save, delete_branch, delete_commit_note, delete_remote_branch,
|
||||
delete_remote_branches, delete_tag, diff_file_against_working_tree, fetch, fetch_commit_notes,
|
||||
get_commit_note, get_file_blame, get_file_patch, get_remote_url, get_status, git_lfs_install,
|
||||
git_lfs_prune, git_lfs_pull, git_lfs_status, git_lfs_track, git_lfs_untrack, init_repository,
|
||||
last_commit_message, list_branches, list_commits, list_file_history,
|
||||
list_interactive_rebase_commits, list_reflog, list_remotes, list_repository_files,
|
||||
list_stashes, list_tags, list_worktrees, lock_worktree, merge_abort, merge_branch,
|
||||
merge_continue, move_worktree, open_repo_in_explorer, open_repository, open_repository_bundle,
|
||||
open_repository_file, prune_worktrees, pull, push, push_commit_notes, push_tag, read_conflict,
|
||||
rebase_abort, rebase_branch, rebase_continue, remove_remote, remove_worktree, rename_branch,
|
||||
rename_remote_branch, repair_worktree, resolve_conflict, resolve_conflict_side,
|
||||
restore_file_from_commit, restore_files, restore_reflog_entry, restore_to_commit,
|
||||
revert_commit, run_sequence_editor_if_requested, search_code_introductions,
|
||||
set_branch_upstream, set_commit_note, stage_files, start_interactive_rebase, stash_apply,
|
||||
stash_drop, stash_pop, stash_push, undo_last_commit, unlock_worktree, unstage_files,
|
||||
untrack_paths, update_remote,
|
||||
commit_ai_review, commit_ai_split, compare_commits, compare_file_to_head,
|
||||
compare_file_to_parent, create_branch, create_tag, cred_delete, cred_load, cred_save,
|
||||
delete_branch, delete_commit_note, delete_remote_branch, delete_remote_branches, delete_tag,
|
||||
diff_file_against_working_tree, fetch, fetch_commit_notes, get_commit_note, get_file_blame,
|
||||
get_file_patch, get_remote_url, get_status, git_lfs_install, git_lfs_prune, git_lfs_pull,
|
||||
git_lfs_status, git_lfs_track, git_lfs_untrack, init_repository, last_commit_message,
|
||||
list_branches, list_commits, list_file_history, list_interactive_rebase_commits, list_reflog,
|
||||
list_remotes, list_repository_files, list_stashes, list_tags, list_worktrees, lock_worktree,
|
||||
merge_abort, merge_branch, merge_continue, move_worktree, open_repo_in_explorer,
|
||||
open_repository, open_repository_bundle, open_repository_file, prune_worktrees, pull, push,
|
||||
push_commit_notes, push_tag, read_conflict, rebase_abort, rebase_branch, rebase_continue,
|
||||
remove_remote, remove_worktree, rename_branch, rename_remote_branch, repair_worktree,
|
||||
resolve_conflict, resolve_conflict_side, restore_file_from_commit, restore_files,
|
||||
restore_reflog_entry, restore_to_commit, revert_commit, run_sequence_editor_if_requested,
|
||||
search_code_introductions, set_branch_upstream, set_commit_note, stage_files,
|
||||
start_interactive_rebase, stash_apply, stash_drop, stash_pop, stash_push, undo_last_commit,
|
||||
unlock_worktree, unstage_files, untrack_paths, update_remote,
|
||||
};
|
||||
use integrations::list_integration_repositories;
|
||||
use std::path::{Path, PathBuf};
|
||||
@@ -317,7 +316,6 @@ async fn main() {
|
||||
.manage(StartupRepository(Mutex::new(startup_repository)))
|
||||
.manage(StartupClone(Mutex::new(startup_clone)))
|
||||
.manage(SearchCancellationState::default())
|
||||
.manage(commit_ai::CommitAiEngine::new())
|
||||
.plugin(tauri_plugin_dialog::init());
|
||||
|
||||
// Linux installs are expected to come from the system package manager (see the
|
||||
@@ -388,9 +386,6 @@ async fn main() {
|
||||
amend_commit,
|
||||
undo_last_commit,
|
||||
last_commit_message,
|
||||
commit_ai_status,
|
||||
commit_ai_load,
|
||||
commit_ai_local_models,
|
||||
commit_ai_generate,
|
||||
commit_ai_review,
|
||||
commit_ai_split,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://schema.tauri.app/config/2",
|
||||
"productName": "Gitty",
|
||||
"version": "2026.8.8",
|
||||
"version": "2026.8.10",
|
||||
"identifier": "com.gitty",
|
||||
"build": {
|
||||
"beforeDevCommand": "npm run prepare:lfs && npm run dev",
|
||||
|
||||
+121
-106
@@ -26,6 +26,8 @@
|
||||
import DiscardConfirmDialog from "./lib/components/DiscardConfirmDialog.svelte";
|
||||
import ExplorerPanel from "./lib/components/ExplorerPanel.svelte";
|
||||
import HistoryPanel from "./lib/components/HistoryPanel.svelte";
|
||||
import InitRepositoryDialog from "./lib/components/InitRepositoryDialog.svelte";
|
||||
import MergeBranchDialog from "./lib/components/MergeBranchDialog.svelte";
|
||||
import NewBranchDialog from "./lib/components/NewBranchDialog.svelte";
|
||||
import RenameBranchDialog from "./lib/components/RenameBranchDialog.svelte";
|
||||
import ReflogDialog from "./lib/components/ReflogDialog.svelte";
|
||||
@@ -49,9 +51,6 @@
|
||||
commitAiGenerate,
|
||||
commitAiReview,
|
||||
commitAiSplit,
|
||||
commitAiLoad,
|
||||
commitAiLocalModels,
|
||||
commitAiStatus,
|
||||
compareCommits,
|
||||
cancelCodeSearch,
|
||||
cancelFileHistory,
|
||||
@@ -151,7 +150,7 @@
|
||||
AppLanguage,
|
||||
AppTheme,
|
||||
AnalyticsSettings,
|
||||
CommitAiPhase,
|
||||
CloneOptions,
|
||||
CustomThemeColors,
|
||||
ConflictFile,
|
||||
DetectedExternalTool,
|
||||
@@ -171,6 +170,7 @@
|
||||
GitFileStatus,
|
||||
GitIgnoreKind,
|
||||
GitLfsStatus,
|
||||
MergeStrategy,
|
||||
GitRepositoryFile,
|
||||
GitRemote,
|
||||
PullStrategy,
|
||||
@@ -179,7 +179,6 @@
|
||||
GitStatus,
|
||||
GitTag,
|
||||
GitWorktree,
|
||||
LocalModelOption,
|
||||
PatchApplyAction,
|
||||
PreparedResolution,
|
||||
RebaseCommit,
|
||||
@@ -238,6 +237,7 @@
|
||||
remoteUrl: string;
|
||||
parentPath: string;
|
||||
directoryName: string;
|
||||
cloneOptions?: CloneOptions;
|
||||
}
|
||||
|
||||
interface ErrorAutoHideState {
|
||||
@@ -316,6 +316,7 @@
|
||||
let repoStatusCache: Record<string, RepoTab> = {};
|
||||
let repoSearch = "";
|
||||
let cloneDialogOpen = false;
|
||||
let initRepositoryDialogOpen = false;
|
||||
let pullStrategy: PullStrategy = (localStorage.getItem("gitlite.pullStrategy") as PullStrategy) || "merge";
|
||||
let selectedRemote = localStorage.getItem("gitlite.selectedRemote") || "";
|
||||
let remoteActionForceWithLease = false;
|
||||
@@ -360,8 +361,6 @@
|
||||
let commitMessage = "";
|
||||
let amendMode = false;
|
||||
let preAmendDraftMessage = "";
|
||||
let lastLocalAiGeneratedMessage = "";
|
||||
let commitAiPhase: CommitAiPhase = "idle";
|
||||
let commitAiGenerating = false;
|
||||
let commitAiReviewing = false;
|
||||
let commitAiSplitting = false;
|
||||
@@ -369,7 +368,6 @@
|
||||
let aiCommitSplitOpen = false;
|
||||
let aiReviewResult: AiReviewResult | null = null;
|
||||
let aiReviewOpen = false;
|
||||
let commitAiPollTimer: ReturnType<typeof setInterval> | undefined;
|
||||
let aiSettings: AiSettings = defaultAiSettings();
|
||||
let aiSettingsOpen = false;
|
||||
let appSettingsOpen = false;
|
||||
@@ -387,7 +385,6 @@
|
||||
let detectedExternalTools: DetectedExternalTool[] = [];
|
||||
let externalToolsDetectionPending = true;
|
||||
let externalToolsDetectionUnavailable = false;
|
||||
let localModelOptions: LocalModelOption[] = [];
|
||||
let errorMessage = "";
|
||||
let operation = "";
|
||||
let compareFrom = "";
|
||||
@@ -396,6 +393,7 @@
|
||||
let comparisonFromLabel = "";
|
||||
let comparisonToLabel = "";
|
||||
let newBranchCommit: GitCommit | null = null;
|
||||
let mergeBranchTarget: GitBranchInfo | null = null;
|
||||
let renameBranchTarget: GitBranchInfo | null = null;
|
||||
let deleteBranchTarget: GitBranchInfo | null = null;
|
||||
let deleteBranchForce = false;
|
||||
@@ -628,7 +626,6 @@
|
||||
if (autoRefreshTimer) { clearInterval(autoRefreshTimer); autoRefreshTimer = undefined; }
|
||||
if (backgroundRepoStatusTimer) { clearInterval(backgroundRepoStatusTimer); backgroundRepoStatusTimer = undefined; }
|
||||
if (backgroundFetchTimer) { clearInterval(backgroundFetchTimer); backgroundFetchTimer = undefined; }
|
||||
if (commitAiPollTimer) { clearInterval(commitAiPollTimer); commitAiPollTimer = undefined; }
|
||||
}
|
||||
|
||||
function wait(ms: number): Promise<void> {
|
||||
@@ -681,7 +678,7 @@
|
||||
loadRepoLists();
|
||||
|
||||
void checkForUpdates();
|
||||
void initCommitAi();
|
||||
aiSettings = loadAiSettings();
|
||||
|
||||
try {
|
||||
await waitForStartupPaint();
|
||||
@@ -729,7 +726,7 @@
|
||||
if (pendingStartupCloneRequest) {
|
||||
const request = pendingStartupCloneRequest;
|
||||
pendingStartupCloneRequest = null;
|
||||
await cloneRepo(request.remoteUrl, request.parentPath, request.directoryName);
|
||||
await cloneRepo(request.remoteUrl, request.parentPath, request.directoryName, undefined, undefined, undefined, false, "credentials", request.cloneOptions);
|
||||
return;
|
||||
}
|
||||
const path = pendingStartupRepoPath;
|
||||
@@ -1029,48 +1026,10 @@
|
||||
|
||||
// ── Commit AI ──────────────────────────────────────────────────────────────
|
||||
|
||||
function stopCommitAiPolling() {
|
||||
if (commitAiPollTimer) { clearInterval(commitAiPollTimer); commitAiPollTimer = undefined; }
|
||||
}
|
||||
|
||||
async function pollCommitAiStatus() {
|
||||
try {
|
||||
const result = await commitAiStatus();
|
||||
commitAiPhase = result.phase;
|
||||
} catch { /* ignore transient errors */ }
|
||||
if (commitAiPhase === "ready" || commitAiPhase === "error") stopCommitAiPolling();
|
||||
}
|
||||
|
||||
function startCommitAiPolling() {
|
||||
// Only the local model has a download/load phase worth polling — cloud providers are
|
||||
// plain API calls with nothing to wait for.
|
||||
stopCommitAiPolling();
|
||||
if (aiSettings.provider !== "local") return;
|
||||
void pollCommitAiStatus();
|
||||
commitAiPollTimer = setInterval(() => { void pollCommitAiStatus(); }, 2000);
|
||||
}
|
||||
|
||||
async function initCommitAi() {
|
||||
aiSettings = loadAiSettings();
|
||||
try {
|
||||
localModelOptions = await commitAiLocalModels();
|
||||
} catch { /* AI features stay disabled if this fails; not fatal to the app */ }
|
||||
if (aiSettings.provider === "local") {
|
||||
try { await commitAiLoad(aiSettings.localModelId); } catch { /* surfaced via status polling */ }
|
||||
}
|
||||
startCommitAiPolling();
|
||||
}
|
||||
|
||||
function saveAiSettings(next: AiSettings) {
|
||||
const modelChanged = next.provider === "local" && next.localModelId !== aiSettings.localModelId;
|
||||
aiSettings = next;
|
||||
persistAiSettings(next);
|
||||
aiSettingsOpen = false;
|
||||
if (next.provider === "local" && (modelChanged || commitAiPhase === "idle")) {
|
||||
commitAiPhase = "idle";
|
||||
void commitAiLoad(next.localModelId);
|
||||
}
|
||||
startCommitAiPolling();
|
||||
}
|
||||
|
||||
function defaultAnalyticsSettings(): AnalyticsSettings {
|
||||
@@ -1324,27 +1283,15 @@
|
||||
|
||||
function updateCommitMessage(message: string) {
|
||||
commitMessage = message;
|
||||
if (message !== lastLocalAiGeneratedMessage) {
|
||||
lastLocalAiGeneratedMessage = "";
|
||||
}
|
||||
}
|
||||
|
||||
async function generateCommitMessageWithAi() {
|
||||
if (!activeRepoPath || commitAiGenerating) return;
|
||||
if (aiSettings.provider === "local" && commitAiPhase !== "ready") return;
|
||||
commitAiGenerating = true;
|
||||
errorMessage = "";
|
||||
try {
|
||||
const notes = commitMessage.trim() || undefined;
|
||||
if (aiSettings.provider === "local") {
|
||||
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") {
|
||||
if (aiSettings.provider === "openai") {
|
||||
const cred = await credLoad("ai:openai");
|
||||
commitMessage = await commitAiGenerate(activeRepoPath, {
|
||||
provider: "openai",
|
||||
@@ -1352,7 +1299,6 @@
|
||||
model: aiSettings.openaiModel,
|
||||
apiKey: cred?.password,
|
||||
});
|
||||
lastLocalAiGeneratedMessage = "";
|
||||
} else if (aiSettings.provider === "anthropic") {
|
||||
const cred = await credLoad("ai:anthropic");
|
||||
commitMessage = await commitAiGenerate(activeRepoPath, {
|
||||
@@ -1361,7 +1307,6 @@
|
||||
model: aiSettings.anthropicModel,
|
||||
apiKey: cred?.password,
|
||||
});
|
||||
lastLocalAiGeneratedMessage = "";
|
||||
} else {
|
||||
const cred = await credLoad("ai:custom");
|
||||
commitMessage = await commitAiGenerate(activeRepoPath, {
|
||||
@@ -1371,7 +1316,6 @@
|
||||
baseUrl: aiSettings.customBaseUrl,
|
||||
apiKey: cred?.password,
|
||||
});
|
||||
lastLocalAiGeneratedMessage = "";
|
||||
}
|
||||
} catch (error) {
|
||||
errorMessage = errorToMessage(error);
|
||||
@@ -1382,10 +1326,6 @@
|
||||
|
||||
async function reviewStagedWithAi() {
|
||||
if (!activeRepoPath || commitAiReviewing || stagedCount === 0) return;
|
||||
if (aiSettings.provider === "local") {
|
||||
errorMessage = "Pre-commit review currently requires OpenAI, Anthropic, or a custom endpoint.";
|
||||
return;
|
||||
}
|
||||
commitAiReviewing = true;
|
||||
errorMessage = "";
|
||||
try {
|
||||
@@ -1427,10 +1367,6 @@
|
||||
|
||||
async function splitStagedWithAi() {
|
||||
if (!activeRepoPath || commitAiSplitting || stagedCount < 2) return;
|
||||
if (aiSettings.provider === "local") {
|
||||
errorMessage = "Commit splitting currently requires OpenAI, Anthropic, or a custom endpoint.";
|
||||
return;
|
||||
}
|
||||
commitAiSplitting = true;
|
||||
errorMessage = "";
|
||||
try {
|
||||
@@ -1735,8 +1671,6 @@
|
||||
function defaultAiSettings(): AiSettings {
|
||||
return {
|
||||
provider: "openai",
|
||||
localModelId: "qwen2.5-0.5b",
|
||||
localProfile: "fast",
|
||||
openaiModel: "gpt-4o-mini",
|
||||
anthropicModel: "claude-3-5-haiku-latest",
|
||||
customBaseUrl: "",
|
||||
@@ -1748,11 +1682,17 @@
|
||||
try {
|
||||
const stored = JSON.parse(localStorage.getItem(AI_SETTINGS_KEY) ?? "null") as unknown;
|
||||
if (stored && typeof stored === "object") {
|
||||
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;
|
||||
const candidate = stored as Partial<AiSettings> & { provider?: unknown };
|
||||
const provider = candidate.provider === "anthropic" || candidate.provider === "custom"
|
||||
? candidate.provider
|
||||
: "openai";
|
||||
return {
|
||||
provider,
|
||||
openaiModel: typeof candidate.openaiModel === "string" ? candidate.openaiModel : "gpt-4o-mini",
|
||||
anthropicModel: typeof candidate.anthropicModel === "string" ? candidate.anthropicModel : "claude-3-5-haiku-latest",
|
||||
customBaseUrl: typeof candidate.customBaseUrl === "string" ? candidate.customBaseUrl : "",
|
||||
customModel: typeof candidate.customModel === "string" ? candidate.customModel : "",
|
||||
};
|
||||
}
|
||||
} catch {
|
||||
// Fall through to defaults below.
|
||||
@@ -2228,6 +2168,10 @@
|
||||
|| value.includes("fetch first");
|
||||
}
|
||||
|
||||
function isUnrelatedHistoriesError(message: string): boolean {
|
||||
return message.toLowerCase().includes("refusing to merge unrelated histories");
|
||||
}
|
||||
|
||||
function statusHasConflicts(value: GitStatus | null): boolean {
|
||||
return (value?.files ?? []).some((file) => file.staged === "conflicted" || file.unstaged === "conflicted");
|
||||
}
|
||||
@@ -2525,12 +2469,13 @@
|
||||
key?: string | null,
|
||||
fromStore = false,
|
||||
credentialMode: CredentialMode = "credentials",
|
||||
cloneOptions: CloneOptions = { branch: null, blobless: false, customFlags: "", shallowDepth: null, shallowSince: null, sparse: false, sparsePaths: [] },
|
||||
) {
|
||||
if (isBusy) return;
|
||||
if (!remoteUrl) { errorMessage = "Enter a remote URL."; return; }
|
||||
if (!parentPath) { errorMessage = "Select a destination folder."; return; }
|
||||
|
||||
const request: CloneRequest = { remoteUrl, parentPath, directoryName };
|
||||
const request: CloneRequest = { remoteUrl, parentPath, directoryName, cloneOptions };
|
||||
pendingClone = request;
|
||||
const credentialKey = key === undefined ? orgKeyFromUrl(remoteUrl) : key;
|
||||
|
||||
@@ -2546,7 +2491,7 @@
|
||||
credDialogOpen = true;
|
||||
return;
|
||||
}
|
||||
await cloneRepo(remoteUrl, parentPath, directoryName, stored.username, stored.password, credentialKey, true, storedMode);
|
||||
await cloneRepo(remoteUrl, parentPath, directoryName, stored.username, stored.password, credentialKey, true, storedMode, cloneOptions);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -2562,6 +2507,7 @@
|
||||
username,
|
||||
password,
|
||||
COMMIT_HISTORY_PAGE_SIZE + 1,
|
||||
cloneOptions,
|
||||
);
|
||||
resetRepositoryState(false);
|
||||
await applyRepositoryBundle(bundle.status.repo_path, bundle);
|
||||
@@ -2618,9 +2564,9 @@
|
||||
trackEvent("clone_dialog_opened");
|
||||
}
|
||||
|
||||
function cloneFromDialog(remoteUrl: string, parentPath: string, directoryName: string, provider?: GitIntegrationProvider, accountId?: string) {
|
||||
function cloneFromDialog(remoteUrl: string, parentPath: string, directoryName: string, cloneOptions: CloneOptions, provider?: GitIntegrationProvider, accountId?: string) {
|
||||
const credentialKey = provider ? integrationCredentialKey(provider, accountId) : undefined;
|
||||
void cloneRepo(remoteUrl, parentPath, directoryName, undefined, undefined, credentialKey, false, provider ? "token" : "credentials");
|
||||
void cloneRepo(remoteUrl, parentPath, directoryName, undefined, undefined, credentialKey, false, provider ? "token" : "credentials", cloneOptions);
|
||||
}
|
||||
|
||||
function openRepoManagement() {
|
||||
@@ -3264,11 +3210,15 @@
|
||||
|
||||
async function merge(branch: GitBranchInfo) {
|
||||
if (!activeRepoPath || branch.current) return;
|
||||
const strategy = (window.prompt("Merge strategy: default, squash, ff-only, or no-ff", "default") ?? "").trim();
|
||||
if (!strategy) return;
|
||||
if (!["default", "squash", "ff-only", "no-ff"].includes(strategy)) { errorMessage = "Unknown merge strategy."; return; }
|
||||
mergeBranchTarget = branch;
|
||||
}
|
||||
|
||||
async function confirmMerge(strategy: MergeStrategy) {
|
||||
const branch = mergeBranchTarget;
|
||||
if (!activeRepoPath || !branch || branch.current) return;
|
||||
await runOperation(`Merging ${branch.name}`, async () => {
|
||||
applyStatus(await mergeBranch(activeRepoPath, branch.name, strategy as import("./lib/types").MergeStrategy));
|
||||
applyStatus(await mergeBranch(activeRepoPath, branch.name, strategy));
|
||||
mergeBranchTarget = null;
|
||||
await refreshRepositoryViews(activeRepoPath);
|
||||
trackEvent("branch_merged", {
|
||||
remote: branch.remote ? 1 : 0,
|
||||
@@ -3717,17 +3667,61 @@
|
||||
mode: CredentialMode,
|
||||
) {
|
||||
errorMessage = "";
|
||||
await runOperation("Pulling", async () => {
|
||||
applyStatus(await pull(activeRepoPath, username, password, pullStrategy, selectedRemote || undefined));
|
||||
await refreshRepositoryViews(activeRepoPath);
|
||||
const pulled = await pullWithUnrelatedHistoryConfirmation(username, password, "Pulling");
|
||||
if (pulled) {
|
||||
trackEvent("repository_pulled", {
|
||||
from_stored_credential: fromStore ? 1 : 0,
|
||||
changed_files: status?.files.length ?? 0,
|
||||
});
|
||||
});
|
||||
}
|
||||
handleRemoteResult("pull", key, fromStore, username, mode);
|
||||
}
|
||||
|
||||
async function pullWithUnrelatedHistoryConfirmation(
|
||||
username: string,
|
||||
password: string,
|
||||
label: string,
|
||||
): Promise<boolean> {
|
||||
await runOperation(label, async () => {
|
||||
applyStatus(await pull(activeRepoPath, username, password, pullStrategy, selectedRemote || undefined));
|
||||
await refreshRepositoryViews(activeRepoPath);
|
||||
});
|
||||
|
||||
if (!errorMessage || !isUnrelatedHistoriesError(errorMessage)) return !errorMessage;
|
||||
|
||||
if (pullStrategy !== "merge") {
|
||||
errorMessage = appLanguage === "de"
|
||||
? "Lokales und entferntes Repository haben unabhängige Historien. Wähle in den Sync-Einstellungen die Merge-Strategie, um sie zusammenzuführen."
|
||||
: "The local and remote repositories have unrelated histories. Choose the Merge strategy in Sync settings to combine them.";
|
||||
return false;
|
||||
}
|
||||
|
||||
errorMessage = "";
|
||||
const confirmed = window.confirm(appLanguage === "de"
|
||||
? "Das lokale und das entfernte Repository besitzen getrennte Commit-Historien.\n\nTrotzdem zusammenführen? Dabei können Merge-Konflikte entstehen."
|
||||
: "The local and remote repositories have separate commit histories.\n\nMerge them anyway? This may produce merge conflicts.");
|
||||
if (!confirmed) {
|
||||
errorMessage = appLanguage === "de"
|
||||
? "Pull abgebrochen: Die getrennten Historien wurden nicht verändert."
|
||||
: "Pull cancelled: the separate histories were left unchanged.";
|
||||
return false;
|
||||
}
|
||||
|
||||
await runOperation(appLanguage === "de" ? "Historien zusammenführen" : "Merging histories", async () => {
|
||||
applyStatus(await pull(
|
||||
activeRepoPath,
|
||||
username,
|
||||
password,
|
||||
pullStrategy,
|
||||
selectedRemote || undefined,
|
||||
undefined,
|
||||
true,
|
||||
));
|
||||
await refreshRepositoryViews(activeRepoPath);
|
||||
});
|
||||
return !errorMessage;
|
||||
}
|
||||
|
||||
async function doActualFetch(
|
||||
username: string,
|
||||
password: string,
|
||||
@@ -3782,10 +3776,7 @@
|
||||
|
||||
if (!fromStore) credDialogError = "";
|
||||
|
||||
await runOperation("Pulling before push", async () => {
|
||||
applyStatus(await pull(activeRepoPath, username, password, pullStrategy, selectedRemote || undefined));
|
||||
await refreshRepositoryViews(activeRepoPath);
|
||||
});
|
||||
await pullWithUnrelatedHistoryConfirmation(username, password, "Pulling before push");
|
||||
|
||||
if (errorMessage) {
|
||||
handleRemoteResult("pull", key, fromStore, username, mode);
|
||||
@@ -3899,6 +3890,7 @@
|
||||
key,
|
||||
false,
|
||||
mode,
|
||||
pendingClone.cloneOptions,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -3943,10 +3935,17 @@
|
||||
}
|
||||
|
||||
async function initializeRepository() {
|
||||
const selected = await openDialog({ directory: true, multiple: false, title: "Choose an empty or existing folder" });
|
||||
if (typeof selected !== "string") return;
|
||||
const branch = window.prompt("Initial branch name", "main")?.trim(); if (!branch) return;
|
||||
await runOperation("Initializing repository", async () => { await initRepository(selected, branch); await openRepo(selected); });
|
||||
initRepositoryDialogOpen = true;
|
||||
}
|
||||
|
||||
async function confirmInitializeRepository(path: string, branch: string) {
|
||||
const selected = path.trim();
|
||||
if (!selected) return;
|
||||
await runOperation("Initializing repository", async () => {
|
||||
await initRepository(selected, branch);
|
||||
initRepositoryDialogOpen = false;
|
||||
await openRepo(selected);
|
||||
});
|
||||
}
|
||||
|
||||
async function revertHistoryCommit(commit: GitCommit) {
|
||||
@@ -4385,7 +4384,6 @@
|
||||
commitMessage = "";
|
||||
amendMode = false;
|
||||
preAmendDraftMessage = "";
|
||||
lastLocalAiGeneratedMessage = "";
|
||||
await refreshRepositoryViews(activeRepoPath);
|
||||
trackEvent("commit_created", { amend: 1 });
|
||||
});
|
||||
@@ -4396,7 +4394,6 @@
|
||||
await runOperation("Committing", async () => {
|
||||
applyStatus(await commit(activeRepoPath, message));
|
||||
commitMessage = "";
|
||||
lastLocalAiGeneratedMessage = "";
|
||||
await refreshRepositoryViews(activeRepoPath);
|
||||
trackEvent("commit_created", { amend: 0, staged_files: trackedStagedCount });
|
||||
});
|
||||
@@ -5617,8 +5614,6 @@
|
||||
{isBusy}
|
||||
{operation}
|
||||
{stagedCount}
|
||||
commitAiProvider={aiSettings.provider}
|
||||
{commitAiPhase}
|
||||
{commitAiGenerating}
|
||||
{commitAiReviewing}
|
||||
{commitAiSplitting}
|
||||
@@ -5938,6 +5933,17 @@
|
||||
/>
|
||||
{/if}
|
||||
|
||||
{#if mergeBranchTarget}
|
||||
<MergeBranchDialog
|
||||
branch={mergeBranchTarget}
|
||||
currentBranch={status?.current_branch ?? ""}
|
||||
{isBusy}
|
||||
language={appLanguage}
|
||||
onMerge={confirmMerge}
|
||||
onClose={() => { if (!isBusy) mergeBranchTarget = null; }}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
{#if commitNoteTarget}
|
||||
<CommitNoteDialog
|
||||
commit={commitNoteTarget}
|
||||
@@ -5983,7 +5989,6 @@
|
||||
{#await import("./lib/components/AiSettingsDialog.svelte") then module}
|
||||
<module.default
|
||||
settings={aiSettings}
|
||||
localModels={localModelOptions}
|
||||
onSave={saveAiSettings}
|
||||
onClose={() => { aiSettingsOpen = false; }}
|
||||
/>
|
||||
@@ -6112,6 +6117,16 @@
|
||||
/>
|
||||
{/if}
|
||||
|
||||
<!-- Initialize repository dialog -->
|
||||
{#if initRepositoryDialogOpen}
|
||||
<InitRepositoryDialog
|
||||
isBusy={operation === "Initializing repository"}
|
||||
language={appLanguage}
|
||||
onInit={confirmInitializeRepository}
|
||||
onClose={() => { if (!isBusy) initRepositoryDialogOpen = false; }}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
<!-- Full-screen overlay while a repository is being opened -->
|
||||
{#if openingRepo}
|
||||
<RepoLoadingOverlay repoName={repoDisplayName} />
|
||||
|
||||
+206
-127
@@ -1486,73 +1486,61 @@
|
||||
right: 18px;
|
||||
bottom: 18px;
|
||||
z-index: 70;
|
||||
display: grid;
|
||||
grid-template-columns: auto minmax(0, 1fr);
|
||||
gap: 12px;
|
||||
width: min(430px, calc(100vw - 32px));
|
||||
padding: 14px;
|
||||
width: min(410px, calc(100vw - 28px));
|
||||
overflow: hidden;
|
||||
border: 1px solid rgba(100, 108, 255, 0.42);
|
||||
border-radius: 14px;
|
||||
border: 1px solid var(--color-border);
|
||||
border-top: 2px solid var(--color-accent);
|
||||
color: var(--color-ink);
|
||||
background:
|
||||
linear-gradient(135deg, rgba(100,108,255,0.22), rgba(189,52,254,0.12) 42%, rgba(65,209,255,0.08)),
|
||||
rgba(12, 13, 24, 0.96);
|
||||
box-shadow: 0 24px 72px rgba(0,0,0,0.48), 0 0 0 1px rgba(255,255,255,0.04) inset;
|
||||
backdrop-filter: blur(18px);
|
||||
background: var(--app-dialog-bg);
|
||||
box-shadow: 0 18px 48px rgba(0,0,0,0.42);
|
||||
animation: update-toast-in 180ms cubic-bezier(.2,.8,.2,1) both;
|
||||
}
|
||||
.update-toast.error {
|
||||
border-color: rgba(232,96,96,0.45);
|
||||
background:
|
||||
linear-gradient(135deg, rgba(232,96,96,0.16), rgba(100,108,255,0.11)),
|
||||
rgba(12, 13, 24, 0.96);
|
||||
border-top-color: var(--code-delete-strong);
|
||||
}
|
||||
.update-toast.installed {
|
||||
border-color: rgba(78,202,118,0.38);
|
||||
background:
|
||||
linear-gradient(135deg, rgba(78,202,118,0.15), rgba(65,209,255,0.1), rgba(100,108,255,0.12)),
|
||||
rgba(12, 13, 24, 0.96);
|
||||
border-top-color: var(--code-add-strong);
|
||||
}
|
||||
|
||||
.update-toast-glow {
|
||||
position: absolute;
|
||||
inset: auto 18px -46px auto;
|
||||
width: 170px;
|
||||
height: 95px;
|
||||
border-radius: 999px;
|
||||
background: rgba(65,209,255,0.18);
|
||||
filter: blur(34px);
|
||||
pointer-events: none;
|
||||
.update-toast-header {
|
||||
display: grid;
|
||||
grid-template-columns: 34px minmax(0, 1fr) auto;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
min-height: 58px;
|
||||
padding: 10px 11px;
|
||||
border-bottom: 1px solid var(--color-border-subtle);
|
||||
background: var(--app-dialog-chrome);
|
||||
}
|
||||
|
||||
.update-toast-icon {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 42px;
|
||||
height: 42px;
|
||||
width: 34px;
|
||||
height: 34px;
|
||||
flex: 0 0 auto;
|
||||
border: 1px solid rgba(255,255,255,0.14);
|
||||
border-radius: 12px;
|
||||
color: #ffffff;
|
||||
background: linear-gradient(135deg, rgba(65,209,255,0.28), rgba(100,108,255,0.54), rgba(189,52,254,0.42));
|
||||
box-shadow: 0 14px 32px rgba(100,108,255,0.22), inset 0 1px 0 rgba(255,255,255,0.16);
|
||||
border: 1px solid color-mix(in srgb, var(--color-accent) 32%, var(--color-border));
|
||||
color: var(--color-accent);
|
||||
background: color-mix(in srgb, var(--color-accent) 9%, var(--color-surface-raised));
|
||||
}
|
||||
.update-toast-icon.busy { color: #bfefff; }
|
||||
|
||||
.update-toast-content {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
display: grid;
|
||||
gap: 9px;
|
||||
min-width: 0;
|
||||
.update-toast.error .update-toast-icon {
|
||||
border-color: color-mix(in srgb, var(--code-delete-strong) 34%, var(--color-border));
|
||||
color: var(--code-delete-strong);
|
||||
background: var(--code-delete-bg);
|
||||
}
|
||||
.update-toast.installed .update-toast-icon {
|
||||
border-color: color-mix(in srgb, var(--code-add-strong) 34%, var(--color-border));
|
||||
color: var(--code-add-strong);
|
||||
background: var(--code-add-bg);
|
||||
}
|
||||
.update-toast-icon.busy { color: var(--color-accent); }
|
||||
|
||||
.update-toast-top {
|
||||
.update-toast-body {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) auto;
|
||||
align-items: start;
|
||||
gap: 8px;
|
||||
gap: 10px;
|
||||
min-width: 0;
|
||||
padding: 12px;
|
||||
background: var(--app-dialog-bg);
|
||||
}
|
||||
|
||||
.update-toast-copy { min-width: 0; }
|
||||
@@ -1561,55 +1549,54 @@
|
||||
overflow: hidden;
|
||||
color: var(--color-accent);
|
||||
font-family: var(--font-mono);
|
||||
font-size: 11px;
|
||||
font-size: 10px;
|
||||
font-weight: 800;
|
||||
letter-spacing: .035em;
|
||||
text-transform: uppercase;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.update-toast h2 {
|
||||
margin: 2px 0 0;
|
||||
color: #ffffff;
|
||||
font-size: 15px;
|
||||
margin: 3px 0 0;
|
||||
color: var(--color-ink);
|
||||
font-size: 14px;
|
||||
font-weight: 800;
|
||||
line-height: 1.2;
|
||||
}
|
||||
.update-toast p {
|
||||
margin: 0;
|
||||
color: var(--color-ink-muted);
|
||||
font-size: 12.5px;
|
||||
font-size: 12px;
|
||||
line-height: 1.45;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.update-toast-close {
|
||||
width: 28px;
|
||||
min-width: 28px;
|
||||
min-height: 28px;
|
||||
width: 26px;
|
||||
min-width: 26px;
|
||||
min-height: 26px;
|
||||
padding: 0;
|
||||
border-color: rgba(255,255,255,0.1);
|
||||
border-radius: 8px;
|
||||
border-color: var(--color-border-subtle);
|
||||
color: var(--color-ink-dim);
|
||||
background: rgba(255,255,255,0.04);
|
||||
background: transparent;
|
||||
}
|
||||
.update-toast-close:hover:not(:disabled) {
|
||||
border-color: rgba(255,255,255,0.2);
|
||||
color: #ffffff;
|
||||
background: rgba(255,255,255,0.1);
|
||||
border-color: var(--color-border);
|
||||
color: var(--color-ink);
|
||||
background: var(--color-surface-hover);
|
||||
}
|
||||
|
||||
.update-progress {
|
||||
position: relative;
|
||||
height: 6px;
|
||||
height: 4px;
|
||||
overflow: hidden;
|
||||
border-radius: 999px;
|
||||
background: rgba(255,255,255,0.09);
|
||||
background: var(--color-surface-hover);
|
||||
}
|
||||
.update-progress span {
|
||||
position: absolute;
|
||||
inset: 0 auto 0 0;
|
||||
min-width: 0;
|
||||
border-radius: inherit;
|
||||
background: linear-gradient(90deg, #4db6d6, #6f8cff, #238eb4);
|
||||
background: var(--color-accent);
|
||||
transition: width 160ms ease;
|
||||
}
|
||||
.update-progress.indeterminate span {
|
||||
@@ -1627,29 +1614,48 @@
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
gap: 7px;
|
||||
min-height: 49px;
|
||||
padding: 8px 11px;
|
||||
border-top: 1px solid var(--color-border-subtle);
|
||||
background: var(--app-dialog-chrome);
|
||||
}
|
||||
.update-toast-primary,
|
||||
.update-toast-secondary {
|
||||
min-height: 32px;
|
||||
border-radius: 8px;
|
||||
font-size: 12.5px;
|
||||
min-height: 31px;
|
||||
font-size: 11.5px;
|
||||
font-weight: 800;
|
||||
}
|
||||
.update-toast-primary {
|
||||
border-color: rgba(111,140,255,0.72);
|
||||
border-color: var(--color-primary);
|
||||
color: #ffffff;
|
||||
background: linear-gradient(135deg, #5f7df2, #238eb4);
|
||||
background: var(--color-primary);
|
||||
}
|
||||
.update-toast-primary:hover:not(:disabled) {
|
||||
border-color: rgba(77,182,214,0.74);
|
||||
border-color: var(--color-primary-dark);
|
||||
color: #ffffff;
|
||||
background: linear-gradient(135deg, #6f8cff, #2da0c7);
|
||||
background: var(--color-primary-dark);
|
||||
}
|
||||
.update-toast-secondary {
|
||||
border-color: rgba(255,255,255,0.1);
|
||||
border-color: var(--color-border);
|
||||
color: var(--color-ink-muted);
|
||||
background: rgba(255,255,255,0.05);
|
||||
background: var(--app-button-bg);
|
||||
}
|
||||
|
||||
@keyframes update-toast-in {
|
||||
from { opacity: 0; transform: translateY(8px); }
|
||||
to { opacity: 1; transform: translateY(0); }
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
.update-toast {
|
||||
right: 8px;
|
||||
bottom: 8px;
|
||||
width: calc(100vw - 16px);
|
||||
}
|
||||
.update-toast-actions > button {
|
||||
flex: 1 1 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* --- Workspace layout --- */
|
||||
@@ -3872,6 +3878,20 @@
|
||||
max-height: calc(100vh - 32px);
|
||||
overflow: auto;
|
||||
}
|
||||
.init-repository-dialog {
|
||||
display: block;
|
||||
width: min(540px, calc(100vw - 32px));
|
||||
height: auto;
|
||||
max-height: calc(100vh - 32px);
|
||||
overflow: auto;
|
||||
}
|
||||
.merge-branch-dialog {
|
||||
display: block;
|
||||
width: min(590px, calc(100vw - 32px));
|
||||
height: auto;
|
||||
max-height: calc(100vh - 32px);
|
||||
overflow: auto;
|
||||
}
|
||||
.rename-branch-dialog {
|
||||
display: block;
|
||||
width: min(520px, calc(100vw - 32px));
|
||||
@@ -4160,50 +4180,75 @@
|
||||
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;
|
||||
gap: 14px;
|
||||
padding: 16px;
|
||||
}
|
||||
.init-repository-header { padding: 16px 18px; }
|
||||
.init-repository-heading { display: flex; align-items: center; gap: 12px; }
|
||||
.init-repository-heading h2 { margin: 2px 0 0; color: var(--color-ink); font-size: 15px; line-height: 1.25; }
|
||||
.init-repository-icon {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
flex: 0 0 auto;
|
||||
border: 1px solid color-mix(in srgb, var(--color-accent) 34%, var(--color-border));
|
||||
border-radius: 9px;
|
||||
color: var(--color-accent);
|
||||
background: color-mix(in srgb, var(--color-accent) 10%, var(--color-surface-raised));
|
||||
}
|
||||
.init-repository-form { display: flex; flex-direction: column; gap: 16px; padding: 18px; }
|
||||
.init-repository-description { margin: 0; color: var(--color-ink-dim); font-size: 11.5px; line-height: 1.5; }
|
||||
.init-repository-field > span { font-size: 9.5px; }
|
||||
.init-repository-field > div { position: relative; align-items: center; }
|
||||
.init-repository-field > div > svg { position: absolute; left: 11px; z-index: 1; color: var(--color-ink-faint); pointer-events: none; }
|
||||
.init-repository-field > div > input { height: 36px; padding-left: 36px; font-family: var(--font-mono); font-size: 12px; }
|
||||
.init-repository-field small { color: var(--color-ink-faint); font-size: 9.5px; line-height: 1.4; }
|
||||
.init-repository-path-field { padding: 12px; border: 1px solid var(--color-border-subtle); border-radius: 9px; background: var(--color-surface-raised); }
|
||||
.init-repository-path-control { display: grid !important; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
|
||||
.init-repository-path-control > input { grid-column: 1; }
|
||||
.init-repository-browse { grid-column: 2; display: inline-flex; align-items: center; gap: 6px; height: 36px; font-size: 11.5px; white-space: nowrap; }
|
||||
.init-repository-error { color: var(--color-danger, #ff6b78) !important; }
|
||||
.init-repository-actions { padding-top: 2px; }
|
||||
.init-repository-actions > button { font-size: 11.5px; }
|
||||
.merge-branch-header { padding: 15px 17px; }
|
||||
.merge-branch-heading { display: flex; align-items: center; gap: 11px; }
|
||||
.merge-branch-heading h2 { margin: 2px 0 0; color: var(--color-ink); font-size: 15px; line-height: 1.25; }
|
||||
.merge-branch-icon {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
flex: 0 0 auto;
|
||||
border: 1px solid color-mix(in srgb, var(--color-accent) 34%, var(--color-border));
|
||||
border-radius: 9px;
|
||||
color: var(--color-accent);
|
||||
background: color-mix(in srgb, var(--color-accent) 10%, var(--color-surface-raised));
|
||||
}
|
||||
.merge-branch-form { display: flex; flex-direction: column; gap: 15px; padding: 17px; }
|
||||
.merge-branch-route { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 12px; padding: 11px 12px; border: 1px solid var(--color-border-subtle); border-radius: 9px; background: var(--color-surface-raised); }
|
||||
.merge-branch-route > div { display: grid; gap: 3px; min-width: 0; }
|
||||
.merge-branch-route > div:last-child { text-align: right; }
|
||||
.merge-branch-route span { color: var(--color-ink-faint); font-size: 9px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
|
||||
.merge-branch-route strong { overflow: hidden; color: var(--color-ink); font-family: var(--font-mono); font-size: 11.5px; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.merge-branch-route > svg { color: var(--color-accent); }
|
||||
.merge-strategy-fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
|
||||
.merge-strategy-fieldset legend { margin-bottom: 7px; color: var(--color-ink-faint); font-size: 9.5px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
|
||||
.merge-strategy-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
|
||||
.merge-strategy-option { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: 9px; min-width: 0; padding: 11px; border: 1px solid var(--color-border-subtle); border-radius: 8px; background: var(--color-surface-dim); cursor: pointer; }
|
||||
.merge-strategy-option:hover { border-color: var(--color-border); background: var(--color-surface-hover); }
|
||||
.merge-strategy-option.active { border-color: color-mix(in srgb, var(--color-accent) 52%, var(--color-border)); background: color-mix(in srgb, var(--color-accent) 8%, var(--color-surface-raised)); box-shadow: inset 2px 0 0 var(--color-accent); }
|
||||
.merge-strategy-option > input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
|
||||
.merge-strategy-check { display: grid; place-items: center; width: 17px; height: 17px; margin-top: 1px; border: 1px solid var(--color-border-input); border-radius: 50%; color: #fff; background: var(--color-surface-raised); }
|
||||
.merge-strategy-option.active .merge-strategy-check { border-color: var(--color-accent); background: var(--color-accent); }
|
||||
.merge-strategy-copy { display: grid; gap: 3px; min-width: 0; }
|
||||
.merge-strategy-copy strong { color: var(--color-ink); font-size: 11.5px; }
|
||||
.merge-strategy-copy small { color: var(--color-ink-faint); font-size: 9.5px; line-height: 1.4; }
|
||||
.merge-branch-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 1px; }
|
||||
.merge-branch-actions > button { font-size: 11.5px; }
|
||||
.rename-branch-form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -8875,7 +8920,7 @@ input:focus, textarea:focus, select:focus { box-shadow: 0 0 0 3px color-mix(in s
|
||||
.repo-tab {
|
||||
min-height: 35px;
|
||||
height: 35px;
|
||||
padding: 0 31px 0 15px;
|
||||
padding: 0 34px 0 15px;
|
||||
gap: 6px;
|
||||
font-size: 12.5px;
|
||||
font-weight: 650;
|
||||
@@ -8901,19 +8946,21 @@ input:focus, textarea:focus, select:focus { box-shadow: 0 0 0 3px color-mix(in s
|
||||
|
||||
.repo-tab-close {
|
||||
position: absolute;
|
||||
top: 8px;
|
||||
right: 6px;
|
||||
width: 19px;
|
||||
min-width: 19px;
|
||||
max-width: 19px;
|
||||
height: 19px;
|
||||
min-height: 19px;
|
||||
max-height: 19px;
|
||||
top: 6px;
|
||||
right: 5px;
|
||||
width: 23px;
|
||||
min-width: 23px;
|
||||
max-width: 23px;
|
||||
height: 23px;
|
||||
min-height: 23px;
|
||||
max-height: 23px;
|
||||
margin: 0;
|
||||
border-radius: 2px;
|
||||
border-radius: 3px;
|
||||
color: var(--color-ink-faint);
|
||||
background: transparent;
|
||||
box-shadow: none;
|
||||
opacity: 0.62;
|
||||
transition: opacity 120ms ease, color 120ms ease, background 120ms ease, box-shadow 120ms ease;
|
||||
}
|
||||
|
||||
.repo-tab-wrap.active .repo-tab-close { opacity: 0.72; }
|
||||
@@ -8921,8 +8968,16 @@ input:focus, textarea:focus, select:focus { box-shadow: 0 0 0 3px color-mix(in s
|
||||
.repo-tab-wrap:focus-within .repo-tab-close { opacity: 1; }
|
||||
.repo-tab-close:hover:not(:disabled),
|
||||
.repo-tab-close:focus-visible:not(:disabled) {
|
||||
color: #e1848b;
|
||||
background: transparent;
|
||||
color: #ffffff;
|
||||
background: #d93641;
|
||||
box-shadow: inset 0 0 0 1px #f0646d;
|
||||
}
|
||||
|
||||
:root[data-theme="light"] .repo-tab-close:hover:not(:disabled),
|
||||
:root[data-theme="light"] .repo-tab-close:focus-visible:not(:disabled) {
|
||||
color: #ffffff;
|
||||
background: #c92f3a;
|
||||
box-shadow: inset 0 0 0 1px #a9212b;
|
||||
}
|
||||
|
||||
.repo-tab-add {
|
||||
@@ -8971,3 +9026,27 @@ input:focus, textarea:focus, select:focus { box-shadow: 0 0 0 3px color-mix(in s
|
||||
:root:not([data-theme="light"]) .repo-tab.management.active > svg {
|
||||
color: #d7dae0;
|
||||
}
|
||||
|
||||
/* Keep every dialog close action neutral until it is intentionally targeted. */
|
||||
:root .dialog-close:hover:not(:disabled),
|
||||
:root .dialog-close:focus-visible:not(:disabled),
|
||||
:root .dialog-icon-button:hover:not(:disabled),
|
||||
:root .dialog-icon-button:focus-visible:not(:disabled),
|
||||
:root .cred-close:hover:not(:disabled),
|
||||
:root .cred-close:focus-visible:not(:disabled) {
|
||||
color: #ffffff;
|
||||
border-color: #f0646d;
|
||||
background: #d93641;
|
||||
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
|
||||
}
|
||||
|
||||
:root[data-theme="light"] .dialog-close:hover:not(:disabled),
|
||||
:root[data-theme="light"] .dialog-close:focus-visible:not(:disabled),
|
||||
:root[data-theme="light"] .dialog-icon-button:hover:not(:disabled),
|
||||
:root[data-theme="light"] .dialog-icon-button:focus-visible:not(:disabled),
|
||||
:root[data-theme="light"] .cred-close:hover:not(:disabled),
|
||||
:root[data-theme="light"] .cred-close:focus-visible:not(:disabled) {
|
||||
color: #ffffff;
|
||||
border-color: #a9212b;
|
||||
background: #c92f3a;
|
||||
}
|
||||
|
||||
@@ -15,8 +15,7 @@
|
||||
function providerLabel(value: CommitAiProvider): string {
|
||||
if (value === "openai") return "OpenAI";
|
||||
if (value === "anthropic") return "Anthropic";
|
||||
if (value === "custom") return "Custom endpoint";
|
||||
return "Local AI";
|
||||
return "Custom endpoint";
|
||||
}
|
||||
|
||||
function locationLabel(finding: AiReviewFinding): string {
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
<script lang="ts">
|
||||
import { onDestroy, onMount } from "svelte";
|
||||
import { AlertCircle, Bot, Check, Cpu, Eye, EyeOff, Gauge, Globe, Key, LoaderCircle, Sparkles, X, Zap } from "@lucide/svelte";
|
||||
import { Bot, Check, Eye, EyeOff, Globe, Key, LoaderCircle, X } from "@lucide/svelte";
|
||||
import { credDelete, credLoad, credSave } from "../git";
|
||||
import type { AiSettings, CommitAiLocalProfile, CommitAiProvider, LocalModelOption } from "../types";
|
||||
import SelectMenu from "./SelectMenu.svelte";
|
||||
import type { AiSettings, CommitAiProvider } from "../types";
|
||||
|
||||
interface Props {
|
||||
settings: AiSettings;
|
||||
localModels: LocalModelOption[];
|
||||
onSave: (settings: AiSettings) => void;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
let { settings, localModels = [], onSave, onClose }: Props = $props();
|
||||
let { settings, onSave, onClose }: Props = $props();
|
||||
|
||||
type CloudProvider = Exclude<CommitAiProvider, "local">;
|
||||
type CloudProvider = CommitAiProvider;
|
||||
|
||||
const CRED_KEYS: Record<CloudProvider, string> = {
|
||||
openai: "ai:openai",
|
||||
@@ -22,9 +20,7 @@
|
||||
custom: "ai:custom",
|
||||
};
|
||||
|
||||
let provider = $state<CommitAiProvider>("local");
|
||||
let localModelId = $state("");
|
||||
let localProfile = $state<CommitAiLocalProfile>("fast");
|
||||
let provider = $state<CommitAiProvider>("openai");
|
||||
let openaiModel = $state("");
|
||||
let anthropicModel = $state("");
|
||||
let customBaseUrl = $state("");
|
||||
@@ -41,8 +37,6 @@
|
||||
|
||||
$effect(() => {
|
||||
provider = settings.provider;
|
||||
localModelId = settings.localModelId;
|
||||
localProfile = settings.localProfile ?? "fast";
|
||||
openaiModel = settings.openaiModel;
|
||||
anthropicModel = settings.anthropicModel;
|
||||
customBaseUrl = settings.customBaseUrl;
|
||||
@@ -103,8 +97,6 @@
|
||||
]);
|
||||
onSave({
|
||||
provider,
|
||||
localModelId,
|
||||
localProfile,
|
||||
openaiModel: openaiModel.trim() || "gpt-4o-mini",
|
||||
anthropicModel: anthropicModel.trim() || "claude-3-5-haiku-latest",
|
||||
customBaseUrl: customBaseUrl.trim(),
|
||||
@@ -117,26 +109,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
function formatSize(mb: number): string {
|
||||
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>
|
||||
|
||||
<div
|
||||
@@ -156,17 +128,6 @@
|
||||
|
||||
<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 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" />
|
||||
OpenAI
|
||||
@@ -181,38 +142,7 @@
|
||||
</button>
|
||||
</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>
|
||||
<SelectMenu value={localModelId} options={localModels.map((option) => ({ value: option.id, label: `${option.label} - ${formatSize(option.approx_size_mb)}` }))} onChange={(value) => { localModelId = value; }} />
|
||||
</label>
|
||||
<div class="cred-token-hint">
|
||||
<AlertCircle size={13} aria-hidden="true" />
|
||||
<span>
|
||||
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"}
|
||||
{#if provider === "openai"}
|
||||
<label class="cred-field">
|
||||
<span class="cred-field-label">Model</span>
|
||||
<input type="text" bind:value={openaiModel} placeholder="gpt-4o-mini" autocomplete="off" spellcheck="false" />
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import { Cloud, Download, FolderOpen, GitBranch, Globe2, LoaderCircle, LockKeyhole, RefreshCw, Search, X } from "@lucide/svelte";
|
||||
import { listIntegrationRepositories } from "../git";
|
||||
import { configuredIntegrationSources } from "../integrations";
|
||||
import type { AppLanguage, GitIntegrationProvider, GitIntegrationRepository, GitIntegrationSettings, GitIntegrationSource } from "../types";
|
||||
import type { AppLanguage, CloneOptions, GitIntegrationProvider, GitIntegrationRepository, GitIntegrationSettings, GitIntegrationSource } from "../types";
|
||||
|
||||
type CloneSource = "url" | "integrations";
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
error: string;
|
||||
language: AppLanguage;
|
||||
integrations: GitIntegrationSettings;
|
||||
onClone: (remoteUrl: string, parentPath: string, directoryName: string, provider?: GitIntegrationProvider, accountId?: string) => void;
|
||||
onClone: (remoteUrl: string, parentPath: string, directoryName: string, options: CloneOptions, provider?: GitIntegrationProvider, accountId?: string) => void;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
@@ -45,6 +45,15 @@
|
||||
let repositoryScrollbarDragScrollTop = 0;
|
||||
let repositoryScrollbarFrame: number | undefined;
|
||||
let repositoryRequestId = 0;
|
||||
let shallowClone = $state(false);
|
||||
let branchToClone = $state("");
|
||||
let shallowLimitMode = $state<"depth" | "since">("depth");
|
||||
let shallowDepth = $state(1);
|
||||
let shallowSince = $state("");
|
||||
let customFlags = $state("");
|
||||
let sparseCheckout = $state(false);
|
||||
let bloblessClone = $state(false);
|
||||
let sparsePathInput = $state("");
|
||||
|
||||
const isGerman = $derived(language === "de");
|
||||
const configuredSources = $derived(configuredIntegrationSources(integrations));
|
||||
@@ -55,9 +64,24 @@
|
||||
if (!query) return activeRepositories;
|
||||
return activeRepositories.filter((repository) => `${repository.fullName} ${repository.description}`.toLocaleLowerCase().includes(query));
|
||||
});
|
||||
const azureRepositoryGroups = $derived.by(() => {
|
||||
if (activeSource?.provider !== "azure-devops") return [];
|
||||
const groups = new Map<string, GitIntegrationRepository[]>();
|
||||
for (const repository of filteredRepositories) {
|
||||
const separator = repository.fullName.indexOf("/");
|
||||
const project = separator > 0 ? repository.fullName.slice(0, separator) : (isGerman ? "Weitere Repositories" : "Other repositories");
|
||||
const repositories = groups.get(project) ?? [];
|
||||
repositories.push(repository);
|
||||
groups.set(project, repositories);
|
||||
}
|
||||
return [...groups.entries()].map(([project, repositories]) => ({ project, repositories }));
|
||||
});
|
||||
const selectedRepository = $derived(activeRepositories.find((repository) => repository.id === selectedRepositoryId));
|
||||
const directorySuggestion = $derived(directoryNameFromRemoteUrl(remoteUrl));
|
||||
const canSubmit = $derived(!isBusy && remoteUrl.trim().length > 0 && parentPath.trim().length > 0);
|
||||
const sparsePaths = $derived.by(() => [...new Set(sparsePathInput.split(/\r?\n/).map((path) => path.trim()).filter(Boolean))]);
|
||||
const shallowLimitValid = $derived(!shallowClone || (shallowLimitMode === "depth" ? Number.isInteger(shallowDepth) && shallowDepth > 0 : shallowSince.trim().length > 0));
|
||||
const cloneOptionsValid = $derived(shallowLimitValid);
|
||||
const canSubmit = $derived(!isBusy && remoteUrl.trim().length > 0 && parentPath.trim().length > 0 && cloneOptionsValid);
|
||||
|
||||
$effect(() => {
|
||||
const nextError = error || browseError;
|
||||
@@ -230,10 +254,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
function showIntegrations() {
|
||||
function selectIntegrationSource(integrationSource: GitIntegrationSource) {
|
||||
source = "integrations";
|
||||
const nextSource = configuredSources.find((candidate) => candidate.id === selectedSourceId) ?? configuredSources[0];
|
||||
if (nextSource) void loadRepositories(nextSource);
|
||||
void loadRepositories(integrationSource);
|
||||
}
|
||||
|
||||
function showUrlInput() {
|
||||
@@ -249,26 +272,104 @@
|
||||
|
||||
function submit(event: SubmitEvent) {
|
||||
event.preventDefault();
|
||||
if (canSubmit) onClone(remoteUrl.trim(), parentPath.trim(), directoryName.trim(), source === "integrations" ? activeSource?.provider : undefined, source === "integrations" ? activeSource?.accountId : undefined);
|
||||
if (canSubmit) onClone(
|
||||
remoteUrl.trim(),
|
||||
parentPath.trim(),
|
||||
directoryName.trim(),
|
||||
{
|
||||
branch: shallowClone && branchToClone.trim() ? branchToClone.trim() : null,
|
||||
blobless: sparseCheckout && bloblessClone,
|
||||
customFlags: shallowClone ? customFlags.trim() : "",
|
||||
shallowDepth: shallowClone && shallowLimitMode === "depth" ? shallowDepth : null,
|
||||
shallowSince: shallowClone && shallowLimitMode === "since" ? shallowSince : null,
|
||||
sparse: sparseCheckout,
|
||||
sparsePaths: sparseCheckout ? sparsePaths : [],
|
||||
},
|
||||
source === "integrations" ? activeSource?.provider : undefined,
|
||||
source === "integrations" ? activeSource?.accountId : undefined,
|
||||
);
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="dialog-backdrop" role="presentation">
|
||||
<div class="dialog clone-repository-dialog" role="dialog" aria-modal="true" aria-label={isGerman ? "Repository klonen" : "Clone repository"} tabindex="-1">
|
||||
<header class="dialog-header">
|
||||
<div><span class="eyebrow">Repository Management</span><h2 class="mt-0.5 text-ink text-base font-bold leading-tight">{isGerman ? "Repository klonen" : "Clone repository"}</h2></div>
|
||||
<header class="dialog-header clone-dialog-header">
|
||||
<div><h2>{isGerman ? "Repository klonen" : "Clone a Repository"}</h2></div>
|
||||
<button class="dialog-close" type="button" onclick={onClose} disabled={isBusy} title={isGerman ? "Schließen" : "Close"} aria-label={isGerman ? "Klonen schließen" : "Close clone dialog"}><X size={18} /></button>
|
||||
</header>
|
||||
|
||||
<form class="clone-dialog-form" onsubmit={submit}>
|
||||
<div class="clone-source-tabs" role="tablist" aria-label={isGerman ? "Repository-Quelle" : "Repository source"}>
|
||||
<button type="button" role="tab" aria-selected={source === "url"} class:active={source === "url"} onclick={showUrlInput}><Globe2 size={15} />URL</button>
|
||||
<button type="button" role="tab" aria-selected={source === "integrations"} class:active={source === "integrations"} onclick={showIntegrations}><Cloud size={15} />{isGerman ? "Integrationen" : "Integrations"}{#if configuredSources.length}<em>{configuredSources.length}</em>{/if}</button>
|
||||
<div class="clone-dialog-layout">
|
||||
<aside class="clone-source-nav" aria-label={isGerman ? "Repository-Quellen" : "Repository sources"}>
|
||||
<div class="clone-source-heading">{isGerman ? "Quelle" : "Source"}</div>
|
||||
<div class="clone-source-list" role="tablist" aria-label={isGerman ? "Repository-Quelle" : "Repository source"}>
|
||||
<button type="button" role="tab" aria-selected={source === "url"} class:active={source === "url"} onclick={showUrlInput}><Globe2 size={15} /><span>{isGerman ? "Mit URL klonen" : "Clone with URL"}</span></button>
|
||||
{#each configuredSources as integrationSource}
|
||||
<button type="button" role="tab" aria-selected={source === "integrations" && selectedSourceId === integrationSource.id} class:active={source === "integrations" && selectedSourceId === integrationSource.id} onclick={() => selectIntegrationSource(integrationSource)}>
|
||||
{#if integrationSource.provider === "azure-devops"}<Cloud size={15} />{:else}<GitBranch size={15} />{/if}
|
||||
<span>{integrationSource.provider === "azure-devops" ? `Azure · ${integrationSource.label}` : integrationSource.label}</span>
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
{#if configuredSources.length === 0}<p>{isGerman ? "Integrationen kannst du in den Einstellungen einrichten." : "Set up integrations in Settings."}</p>{/if}
|
||||
</aside>
|
||||
|
||||
<section class="clone-dialog-content">
|
||||
<div class="clone-dialog-title">
|
||||
<span>{source === "integrations" ? (activeSource?.label ?? "Integration") : "URL"}</span>
|
||||
<h3>{isGerman ? "Repository klonen" : "Clone a Repo"}</h3>
|
||||
</div>
|
||||
|
||||
<div class="clone-target-grid">
|
||||
<label class="clone-dialog-field"><span>{isGerman ? "Klonen nach" : "Where to clone to"}</span><div class="clone-dialog-path-field"><input bind:value={parentPath} autocomplete="off" spellcheck="false" placeholder={isGerman ? "Übergeordneten Ordner auswählen" : "Choose parent folder"} disabled={isBusy} /><button class="btn-secondary" type="button" onclick={chooseParentFolder} disabled={isBusy}><FolderOpen size={14} />{isGerman ? "Durchsuchen" : "Browse"}</button></div></label>
|
||||
<label class="clone-dialog-field"><span>{isGerman ? "Ordnername" : "Folder name"}</span><input bind:value={directoryName} oninput={handleDirectoryInput} autocomplete="off" spellcheck="false" placeholder={directorySuggestion || "Optional"} disabled={isBusy} /></label>
|
||||
</div>
|
||||
|
||||
<section class="clone-options" aria-label={isGerman ? "Clone-Optionen" : "Clone options"}>
|
||||
<div class="clone-option-card" class:expanded={shallowClone}>
|
||||
<label class="clone-option-toggle">
|
||||
<input type="checkbox" bind:checked={shallowClone} disabled={isBusy} />
|
||||
<span><strong>Shallow Clone</strong><small>{isGerman ? "Nur die neuesten Commits laden" : "Download only the latest commits"}</small></span>
|
||||
</label>
|
||||
{#if shallowClone}
|
||||
<div class="clone-option-body">
|
||||
<label class="clone-option-detail"><span>{isGerman ? "Zu klonender Branch" : "Branch to clone"}</span><input bind:value={branchToClone} autocomplete="off" spellcheck="false" placeholder={isGerman ? "Standard-Branch" : "Default branch"} disabled={isBusy} /></label>
|
||||
<fieldset class="clone-history-mode">
|
||||
<legend>{isGerman ? "Historie begrenzen nach" : "Limit history by"}</legend>
|
||||
<label><input type="radio" bind:group={shallowLimitMode} value="depth" disabled={isBusy} />{isGerman ? "Commit-Tiefe" : "Commit depth"}</label>
|
||||
<label><input type="radio" bind:group={shallowLimitMode} value="since" disabled={isBusy} />{isGerman ? "Seit Datum" : "Since date"}</label>
|
||||
</fieldset>
|
||||
{#if shallowLimitMode === "depth"}
|
||||
<label class="clone-option-detail"><span>{isGerman ? "Tiefe" : "Depth"}</span><input type="number" min="1" step="1" bind:value={shallowDepth} disabled={isBusy} aria-invalid={!Number.isInteger(shallowDepth) || shallowDepth < 1} /></label>
|
||||
{:else}
|
||||
<label class="clone-option-detail"><span>{isGerman ? "Seit" : "Since"}</span><input type="date" bind:value={shallowSince} disabled={isBusy} aria-invalid={!shallowSince.trim()} /></label>
|
||||
{/if}
|
||||
<label class="clone-option-detail"><span>{isGerman ? "Zusätzliche Flags" : "Custom flags"}</span><input bind:value={customFlags} autocomplete="off" spellcheck="false" placeholder="--recurse-submodules --single-branch" disabled={isBusy} /></label>
|
||||
<small class="clone-option-help">{isGerman ? "Flags wie in der Git-Kommandozeile; verwaltete oder unsichere Flags werden abgewiesen." : "Enter flags as on the Git command line; managed or unsafe flags are rejected."}</small>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="clone-option-card" class:expanded={sparseCheckout}>
|
||||
<label class="clone-option-toggle">
|
||||
<input type="checkbox" bind:checked={sparseCheckout} disabled={isBusy} />
|
||||
<span><strong>Sparse Checkout</strong><small>{isGerman ? "Nur ausgewählte Pfade auschecken" : "Check out only selected paths"}</small></span>
|
||||
</label>
|
||||
{#if sparseCheckout}
|
||||
<div class="clone-option-body">
|
||||
<label class="clone-blobless-toggle"><input type="checkbox" bind:checked={bloblessClone} disabled={isBusy} /><span><strong>Blobless Clone</strong><small>{isGerman ? "Lädt zunächst Bäume und Commits ohne Dateiinhalte. Blobs werden bei Bedarf nachgeladen." : "Fetch trees and commits without file contents initially. Blobs are downloaded on demand."}</small></span></label>
|
||||
<label class="clone-option-detail clone-sparse-paths">
|
||||
<span>{isGerman ? "Pfade einschließen" : "Paths to include"}</span>
|
||||
<textarea bind:value={sparsePathInput} rows="3" spellcheck="false" placeholder={"src/\ndocs/\nREADME.md"} disabled={isBusy}></textarea>
|
||||
<small class="clone-option-help">{isGerman ? "Ein Pfad pro Zeile. Nur diese Pfade werden im Arbeitsverzeichnis ausgecheckt. Ohne Pfade werden nur Dateien im Repository-Root ausgecheckt." : "Enter one path per line. Only these paths will be checked out in the working directory. With no paths, only files in the repository root are checked out."}</small>
|
||||
</label>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{#if source === "url"}
|
||||
<label class="clone-dialog-field">
|
||||
<span>{isGerman ? "Remote-URL" : "Remote URL"}</span>
|
||||
<label class="clone-dialog-field clone-url-field">
|
||||
<span>{isGerman ? "Repository-URL" : "Repository URL"}</span>
|
||||
<!-- svelte-ignore a11y_autofocus -->
|
||||
<input value={remoteUrl} oninput={handleRemoteInput} autocomplete="off" spellcheck="false" placeholder="https://gitlab.com/org/project.git" disabled={isBusy} autofocus />
|
||||
</label>
|
||||
@@ -277,11 +378,8 @@
|
||||
{#if configuredSources.length === 0}
|
||||
<div class="integration-empty"><Cloud size={26} /><strong>{isGerman ? "Keine aktive Integration" : "No active integration"}</strong><p>{isGerman ? "Richte unter Einstellungen → Integrationen zuerst GitHub, GitLab, Azure DevOps oder Gitea ein." : "Set up GitHub, GitLab, Azure DevOps, or Gitea under Settings → Integrations first."}</p></div>
|
||||
{:else}
|
||||
<div class="integration-provider-tabs" role="tablist" aria-label={isGerman ? "Konfigurierte Anbieter" : "Configured providers"}>
|
||||
{#each configuredSources as integrationSource}<button type="button" role="tab" aria-selected={selectedSourceId === integrationSource.id} class:active={selectedSourceId === integrationSource.id} onclick={() => loadRepositories(integrationSource)}>{integrationSource.provider === "azure-devops" ? `Azure · ${integrationSource.label}` : integrationSource.label}</button>{/each}
|
||||
</div>
|
||||
<div class="repository-toolbar">
|
||||
<label><Search size={14} /><input bind:value={repositorySearch} placeholder={isGerman ? "Repositories filtern…" : "Filter repositories…"} aria-label={isGerman ? "Repositories filtern" : "Filter repositories"} /></label>
|
||||
<label><Search size={14} /><input bind:value={repositorySearch} placeholder={isGerman ? "Repositories durchsuchen…" : "Search repositories…"} aria-label={isGerman ? "Repositories durchsuchen" : "Search repositories"} /></label>
|
||||
<button type="button" onclick={() => activeSource && loadRepositories(activeSource, true)} disabled={!activeSource || loadingSourceId.length > 0} title={isGerman ? "Neu laden" : "Refresh"} aria-label={isGerman ? "Repository-Liste neu laden" : "Refresh repository list"}><RefreshCw class={loadingSourceId ? "spin" : ""} size={14} /></button>
|
||||
</div>
|
||||
<div class="repository-list-shell">
|
||||
@@ -292,6 +390,19 @@
|
||||
<div class="repository-state repository-state-error"><strong>{isGerman ? "Repositories konnten nicht geladen werden" : "Could not load repositories"}</strong><span>{repositoryError}</span></div>
|
||||
{:else if filteredRepositories.length === 0}
|
||||
<div class="repository-state"><GitBranch size={20} /><span>{repositorySearch ? (isGerman ? "Keine passenden Repositories." : "No matching repositories.") : (isGerman ? "Keine Repositories gefunden." : "No repositories found.")}</span></div>
|
||||
{:else if activeSource?.provider === "azure-devops"}
|
||||
{#each azureRepositoryGroups as group (group.project)}
|
||||
<section class="repository-project-group" aria-label={group.project}>
|
||||
<div class="repository-project-header"><span>{group.project}</span><em>{group.repositories.length}</em></div>
|
||||
{#each group.repositories as repository (repository.id)}
|
||||
<button type="button" class="repository-option" class:selected={selectedRepositoryId === repository.id} onclick={() => selectRepository(repository)}>
|
||||
<span class="repository-option-icon"><GitBranch size={15} /></span>
|
||||
<span class="repository-option-copy"><strong>{repository.name}</strong><small>{repository.description || repository.cloneUrl}</small></span>
|
||||
<span class="repository-option-meta">{#if repository.private}<LockKeyhole size={12} aria-label={isGerman ? "Privat" : "Private"} />{/if}{formatUpdatedAt(repository.updatedAt)}</span>
|
||||
</button>
|
||||
{/each}
|
||||
</section>
|
||||
{/each}
|
||||
{:else}
|
||||
{#each filteredRepositories as repository (repository.id)}
|
||||
<button type="button" class="repository-option" class:selected={selectedRepositoryId === repository.id} onclick={() => selectRepository(repository)}>
|
||||
@@ -334,35 +445,65 @@
|
||||
</section>
|
||||
{/if}
|
||||
|
||||
<div class="clone-target-grid">
|
||||
<label class="clone-dialog-field"><span>{isGerman ? "Ziel" : "Destination"}</span><div class="clone-dialog-path-field"><input bind:value={parentPath} autocomplete="off" spellcheck="false" placeholder={isGerman ? "Übergeordneten Ordner auswählen" : "Choose parent folder"} disabled={isBusy} /><button class="btn-secondary" type="button" onclick={chooseParentFolder} disabled={isBusy}><FolderOpen size={14} />{isGerman ? "Durchsuchen" : "Browse"}</button></div></label>
|
||||
<label class="clone-dialog-field"><span>{isGerman ? "Ordnername" : "Folder name"}</span><input bind:value={directoryName} oninput={handleDirectoryInput} autocomplete="off" spellcheck="false" placeholder={directorySuggestion || "Optional"} disabled={isBusy} /></label>
|
||||
</div>
|
||||
|
||||
{#if visibleError}<div class="clone-dialog-error" role="alert">{visibleError}</div>{/if}
|
||||
</section>
|
||||
</div>
|
||||
<div class="clone-dialog-actions"><button class="btn-secondary" type="button" onclick={onClose} disabled={isBusy}>{isGerman ? "Abbrechen" : "Cancel"}</button><button class="btn-primary" type="submit" disabled={!canSubmit}>{#if isBusy}<LoaderCircle class="spin" size={16} />{:else}<Download size={16} />{/if}{isGerman ? "Klonen" : "Clone"}</button></div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.clone-repository-dialog { width: min(760px, calc(100vw - 32px)); }
|
||||
.clone-source-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; padding: 4px; border: 1px solid var(--color-border-subtle); border-radius: 9px; background: var(--app-settings-row-bg); }
|
||||
.clone-source-tabs button { min-height: 36px; border-color: transparent; color: var(--color-ink-dim); background: transparent; font-size: 11px; font-weight: 800; }
|
||||
.clone-source-tabs button.active { border-color: var(--color-border-input); color: var(--color-ink); background: var(--color-surface-raised); box-shadow: 0 2px 8px rgba(0,0,0,.12); }
|
||||
.clone-source-tabs button.active :global(svg) { color: var(--color-accent); }
|
||||
.clone-source-tabs em { display: grid; place-items: center; min-width: 19px; height: 18px; padding: 0 5px; border-radius: 9px; color: var(--color-accent); background: color-mix(in srgb, var(--color-accent) 12%, transparent); font-size: 9px; font-style: normal; }
|
||||
.integration-browser { display: grid; gap: 9px; min-height: 270px; padding: 11px; border: 1px solid var(--color-border-subtle); border-radius: 10px; background: color-mix(in srgb, var(--app-settings-row-bg) 72%, transparent); }
|
||||
.integration-provider-tabs { display: flex; gap: 5px; overflow-x: auto; }
|
||||
.integration-provider-tabs button { flex: 0 0 auto; min-height: 29px; padding: 0 9px; border-color: transparent; color: var(--color-ink-dim); background: transparent; font-size: 10px; font-weight: 750; }
|
||||
.integration-provider-tabs button.active { border-color: color-mix(in srgb, var(--color-accent) 30%, var(--color-border)); color: var(--color-ink); background: color-mix(in srgb, var(--color-accent) 8%, var(--color-surface-raised)); }
|
||||
.clone-repository-dialog { width: min(900px, calc(100vw - 32px)); height: min(660px, calc(100vh - 32px)); }
|
||||
.clone-dialog-header { min-height: 52px; padding: 0 16px 0 20px; }
|
||||
.clone-dialog-header h2 { margin: 0; color: var(--color-ink); font-size: 15px; font-weight: 650; }
|
||||
.clone-dialog-form { grid-template-rows: minmax(0, 1fr) auto; gap: 0; height: calc(100% - 53px); padding: 0; }
|
||||
.clone-dialog-layout { display: grid; grid-template-columns: 205px minmax(0, 1fr); min-height: 0; }
|
||||
.clone-source-nav { min-width: 0; padding: 12px 0; border-right: 1px solid var(--color-border-subtle); background: var(--app-dialog-chrome); }
|
||||
.clone-source-heading { padding: 2px 14px 8px; color: var(--color-ink-faint); font-size: 8.5px; font-weight: 850; text-transform: uppercase; letter-spacing: .08em; }
|
||||
.clone-source-list { display: grid; gap: 2px; }
|
||||
.clone-source-list button { display: grid; grid-template-columns: 18px minmax(0, 1fr); align-items: center; gap: 8px; width: 100%; min-height: 38px; padding: 0 14px; border: 0; border-radius: 0; color: var(--color-ink-dim); background: transparent; box-shadow: none; font-size: 10.5px; font-weight: 650; text-align: left; }
|
||||
.clone-source-list button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.clone-source-list button :global(svg) { color: var(--color-ink-faint); }
|
||||
.clone-source-list button:hover { color: var(--color-ink); background: var(--color-surface-hover); }
|
||||
.clone-source-list button.active { color: var(--color-ink); background: color-mix(in srgb, var(--color-accent) 18%, var(--color-surface-hover)); box-shadow: inset 3px 0 0 var(--color-accent); }
|
||||
.clone-source-list button.active :global(svg) { color: var(--color-accent); }
|
||||
.clone-source-nav > p { margin: 12px 14px 0; color: var(--color-ink-faint); font-size: 9px; line-height: 1.45; }
|
||||
.clone-dialog-content { display: grid; grid-template-rows: auto auto auto minmax(0, 1fr); grid-auto-rows: auto; align-content: stretch; gap: 12px; min-width: 0; min-height: 0; padding: 16px 18px; overflow: hidden; }
|
||||
.clone-dialog-title { display: grid; gap: 3px; }
|
||||
.clone-dialog-title > span { color: var(--color-accent); font-size: 8.5px; font-weight: 850; text-transform: uppercase; letter-spacing: .07em; }
|
||||
.clone-dialog-title h3 { margin: 0; color: var(--color-ink); font-size: 16px; font-weight: 650; }
|
||||
.clone-url-field { align-self: start; margin-top: 2px; }
|
||||
.clone-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 8px; }
|
||||
.clone-option-card { min-width: 0; border: 1px solid var(--color-border-subtle); border-radius: 6px; background: color-mix(in srgb, var(--color-surface-raised) 70%, transparent); }
|
||||
.clone-option-card.expanded { border-color: color-mix(in srgb, var(--color-accent) 34%, var(--color-border)); }
|
||||
.clone-option-toggle { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 8px; min-height: 42px; padding: 6px 9px; cursor: pointer; }
|
||||
.clone-option-toggle > input { width: 14px; height: 14px; margin: 0; accent-color: var(--color-accent); }
|
||||
.clone-option-toggle > span { display: grid; min-width: 0; gap: 2px; }
|
||||
.clone-option-toggle strong { color: var(--color-ink); font-size: 10.5px; }
|
||||
.clone-option-toggle small { overflow: hidden; color: var(--color-ink-faint); font-size: 8.5px; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.clone-option-body { display: grid; gap: 8px; padding: 1px 9px 9px 31px; }
|
||||
.clone-option-detail { display: grid; grid-template-columns: minmax(82px, auto) minmax(64px, 1fr); align-items: center; gap: 8px; color: var(--color-ink-faint); font-size: 8.5px; font-weight: 750; text-transform: uppercase; letter-spacing: .035em; }
|
||||
.clone-option-detail input { height: 28px; min-width: 0; font-size: 10px; }
|
||||
.clone-history-mode { display: flex; flex-wrap: wrap; align-items: center; gap: 7px 12px; min-width: 0; margin: 0; padding: 0; border: 0; color: var(--color-ink-dim); font-size: 9.5px; }
|
||||
.clone-history-mode legend { float: left; min-width: 100%; margin-bottom: 1px; color: var(--color-ink-faint); font-size: 8.5px; font-weight: 750; text-transform: uppercase; letter-spacing: .035em; }
|
||||
.clone-history-mode label, .clone-blobless-toggle { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
|
||||
.clone-history-mode input, .clone-blobless-toggle > input { width: 13px; height: 13px; margin: 0; accent-color: var(--color-accent); }
|
||||
.clone-option-help { color: var(--color-ink-faint); font-size: 8px; line-height: 1.35; }
|
||||
.clone-blobless-toggle { align-items: start; }
|
||||
.clone-blobless-toggle > span { display: grid; gap: 2px; }
|
||||
.clone-blobless-toggle strong { color: var(--color-ink); font-size: 9.5px; }
|
||||
.clone-blobless-toggle small { color: var(--color-ink-faint); font-size: 8px; }
|
||||
.clone-sparse-paths { grid-template-columns: 1fr; gap: 5px; }
|
||||
.clone-sparse-paths textarea { min-height: 54px; max-height: 72px; resize: vertical; font: 9.5px/1.35 var(--font-mono); }
|
||||
.integration-browser { display: grid; grid-template-rows: auto minmax(0, 1fr); grid-auto-rows: auto; gap: 8px; min-height: 0; }
|
||||
.repository-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) 32px; gap: 6px; }
|
||||
.repository-toolbar label { position: relative; min-width: 0; }
|
||||
.repository-toolbar label > :global(svg) { position: absolute; z-index: 1; top: 10px; left: 10px; color: var(--color-ink-faint); }
|
||||
.repository-toolbar input { height: 34px; padding-left: 31px; font-size: 11px; }
|
||||
.repository-toolbar button { min-height: 32px; padding: 0; }
|
||||
.repository-list-shell { position: relative; min-height: 162px; max-height: 250px; overflow: hidden; border: 1px solid var(--color-border-subtle); border-radius: 8px; background: var(--color-surface-raised); }
|
||||
.repository-list { min-height: 160px; max-height: 248px; padding-right: 8px; overflow: auto; scrollbar-width: none; border-radius: inherit; background: transparent; }
|
||||
.repository-list-shell { position: relative; min-height: 0; height: 100%; overflow: hidden; border: 1px solid var(--color-border-input); border-radius: 7px; background: var(--color-surface-raised); box-shadow: 0 8px 18px rgba(0,0,0,.13); }
|
||||
.repository-list { min-height: 0; height: 100%; padding-right: 8px; overflow: auto; scrollbar-width: none; border-radius: inherit; background: transparent; }
|
||||
.repository-list::-webkit-scrollbar { display: none; width: 0; height: 0; }
|
||||
.repository-scrollbar { position: absolute; z-index: 2; top: 3px; right: 1px; bottom: 3px; width: 7px; border-radius: 4px; opacity: 0; pointer-events: none; touch-action: none; transition: opacity 120ms ease; }
|
||||
.repository-scrollbar.visible { opacity: 1; pointer-events: auto; }
|
||||
@@ -371,28 +512,57 @@
|
||||
.repository-scrollbar:focus-visible .repository-scrollbar-thumb,
|
||||
.repository-scrollbar.dragging .repository-scrollbar-thumb { right: 1px; width: 4px; background: var(--app-scrollbar-thumb-hover); }
|
||||
.repository-scrollbar:focus-visible { outline: 1px solid color-mix(in srgb, var(--color-accent) 70%, transparent); outline-offset: 1px; }
|
||||
.repository-option { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 9px; width: 100%; min-height: 52px; padding: 7px 9px; border: 0; border-bottom: 1px solid var(--color-border-subtle); border-radius: 0; color: var(--color-ink-dim); background: transparent; text-align: left; }
|
||||
.repository-project-group + .repository-project-group { border-top: 1px solid var(--color-border-subtle); }
|
||||
.repository-project-header { position: sticky; z-index: 1; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 34px; padding: 7px 10px 6px 12px; color: var(--color-accent); background: color-mix(in srgb, var(--color-surface-raised) 96%, transparent); font-size: 9.5px; font-weight: 900; text-transform: uppercase; letter-spacing: .045em; }
|
||||
.repository-project-header span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.repository-project-header em { display: grid; flex: 0 0 auto; place-items: center; min-width: 19px; height: 16px; padding: 0 5px; color: var(--color-ink); background: color-mix(in srgb, var(--color-ink) 12%, transparent); font-size: 8px; font-style: normal; line-height: 1; letter-spacing: 0; }
|
||||
.repository-option { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 8px; width: 100%; min-height: 44px; padding: 6px 10px 6px 12px; border: 0; border-bottom: 1px solid var(--color-border-subtle); border-radius: 0; color: var(--color-ink-dim); background: transparent; text-align: left; }
|
||||
.repository-option:last-child { border-bottom: 0; }
|
||||
.repository-option:hover { color: var(--color-ink); background: var(--color-surface-hover); }
|
||||
.repository-option.selected { color: var(--color-ink); background: color-mix(in srgb, var(--color-accent) 8%, var(--color-surface-hover)); box-shadow: inset 2px 0 0 var(--color-accent); }
|
||||
.repository-option-icon { display: grid; place-items: center; width: 30px; height: 30px; border: 1px solid var(--color-border-subtle); border-radius: 7px; color: var(--color-accent); background: color-mix(in srgb, var(--color-accent) 7%, transparent); }
|
||||
.repository-option.selected { color: var(--color-ink); background: color-mix(in srgb, var(--color-accent) 15%, var(--color-surface-hover)); box-shadow: inset 3px 0 0 var(--color-accent); }
|
||||
.repository-option-icon { display: grid; place-items: center; width: 22px; height: 22px; color: var(--color-ink-faint); }
|
||||
.repository-option.selected .repository-option-icon { color: var(--color-accent); }
|
||||
.repository-option-copy { display: grid; min-width: 0; gap: 3px; }
|
||||
.repository-option-copy strong, .repository-option-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.repository-option-copy strong { color: inherit; font-size: 10.5px; }
|
||||
.repository-option-copy small { color: var(--color-ink-faint); font-size: 9px; }
|
||||
.repository-project-group .repository-option { min-height: 38px; padding-block: 5px; }
|
||||
.repository-project-group .repository-option-copy { gap: 0; }
|
||||
.repository-project-group .repository-option-copy strong { color: var(--color-ink); font-size: 11.5px; font-weight: 800; }
|
||||
.repository-project-group .repository-option-copy small { display: none; }
|
||||
.repository-option-meta { display: flex; align-items: center; gap: 5px; color: var(--color-ink-faint); font-size: 8.5px; }
|
||||
.repository-state, .integration-empty { display: grid; place-items: center; align-content: center; min-height: 160px; padding: 20px; color: var(--color-ink-faint); text-align: center; }
|
||||
.repository-state, .integration-empty { display: grid; place-items: center; align-content: center; min-height: 188px; padding: 20px; color: var(--color-ink-faint); text-align: center; }
|
||||
.repository-state { gap: 7px; font-size: 10.5px; }
|
||||
.repository-state strong, .integration-empty strong { color: var(--color-ink); font-size: 11px; }
|
||||
.repository-state-error strong { color: #e86060; }
|
||||
.repository-state-error span { max-width: 520px; line-height: 1.45; }
|
||||
.integration-empty { min-height: 235px; gap: 8px; }
|
||||
.integration-empty { min-height: 260px; gap: 8px; }
|
||||
.integration-empty :global(svg) { color: var(--color-accent); }
|
||||
.integration-empty p { max-width: 400px; margin: 0; color: var(--color-ink-faint); font-size: 10px; line-height: 1.5; }
|
||||
.selected-repository { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 3px 8px; min-width: 0; padding: 8px 9px; border-left: 2px solid var(--color-accent); background: color-mix(in srgb, var(--color-accent) 6%, transparent); }
|
||||
.selected-repository span { color: var(--color-accent); font-size: 8.5px; font-weight: 850; text-transform: uppercase; letter-spacing: .04em; }
|
||||
.selected-repository strong { overflow: hidden; color: var(--color-ink); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.selected-repository code { grid-column: 2; overflow: hidden; color: var(--color-ink-faint); font: 8.5px var(--font-mono); text-overflow: ellipsis; white-space: nowrap; }
|
||||
.clone-target-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(150px, .75fr); gap: 10px; }
|
||||
@media (max-width: 620px) { .clone-repository-dialog { width: min(620px, calc(100vw - 20px)); } .clone-target-grid { grid-template-columns: 1fr; } .repository-option-meta { display: none; } }
|
||||
.clone-target-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(150px, .72fr); gap: 10px; }
|
||||
.clone-dialog-actions { min-height: 54px; align-items: center; padding: 9px 16px; border-top: 1px solid var(--color-border-subtle); background: var(--app-dialog-chrome); }
|
||||
@media (max-width: 700px) {
|
||||
.clone-repository-dialog { width: min(660px, calc(100vw - 20px)); }
|
||||
.clone-dialog-layout { grid-template-columns: 155px minmax(0, 1fr); }
|
||||
.clone-source-list button { padding-inline: 10px; }
|
||||
.clone-target-grid { grid-template-columns: 1fr; }
|
||||
.repository-option-meta { display: none; }
|
||||
}
|
||||
@media (max-width: 500px) {
|
||||
.dialog-backdrop { padding: 10px; }
|
||||
.clone-repository-dialog { width: calc(100vw - 20px); height: min(660px, calc(100vh - 20px)); }
|
||||
.clone-dialog-layout { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
|
||||
.clone-source-nav { padding: 6px 0; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--color-border-subtle); }
|
||||
.clone-source-heading, .clone-source-nav > p { display: none; }
|
||||
.clone-source-list { display: flex; width: max-content; min-width: 100%; padding: 0 6px; }
|
||||
.clone-source-list button { width: auto; min-height: 34px; padding-inline: 9px; border-radius: 5px; }
|
||||
.clone-source-list button.active { box-shadow: inset 0 -2px 0 var(--color-accent); }
|
||||
.clone-options { grid-template-columns: 1fr; }
|
||||
.clone-dialog-content { grid-template-rows: auto; grid-auto-rows: auto; align-content: start; padding: 13px 12px; overflow: auto; }
|
||||
.integration-browser { min-height: 260px; }
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { Check, GitCommitHorizontal, LoaderCircle, RotateCcw, Settings, ShieldCheck, Sparkles } from "@lucide/svelte";
|
||||
import type { CommitAiPhase, CommitAiProvider } from "../types";
|
||||
|
||||
interface Props {
|
||||
commitMessage: string;
|
||||
@@ -10,8 +9,6 @@
|
||||
isBusy: boolean;
|
||||
operation: string;
|
||||
stagedCount: number;
|
||||
commitAiProvider: CommitAiProvider;
|
||||
commitAiPhase: CommitAiPhase;
|
||||
commitAiGenerating: boolean;
|
||||
commitAiReviewing: boolean;
|
||||
commitAiSplitting: boolean;
|
||||
@@ -35,8 +32,6 @@
|
||||
isBusy = false,
|
||||
operation = "",
|
||||
stagedCount = 0,
|
||||
commitAiProvider = "local",
|
||||
commitAiPhase = "idle",
|
||||
commitAiGenerating = false,
|
||||
commitAiReviewing = false,
|
||||
commitAiSplitting = false,
|
||||
@@ -57,23 +52,19 @@
|
||||
onCommit();
|
||||
}
|
||||
|
||||
function aiButtonTitle(provider: CommitAiProvider, phase: CommitAiPhase, staged: number): string {
|
||||
function aiButtonTitle(staged: number): string {
|
||||
if (staged === 0) return "Stage changes first";
|
||||
if (provider === "local" && phase === "loading") return "AI model is downloading/loading — this happens once";
|
||||
if (provider === "local" && phase === "error") return "AI model failed to load — check AI settings";
|
||||
return "Generate commit message with AI from the staged diff";
|
||||
}
|
||||
|
||||
let localModelLoading = $derived(commitAiProvider === "local" && commitAiPhase === "loading");
|
||||
let canGenerate = $derived(
|
||||
hasRepository &&
|
||||
!isBusy &&
|
||||
!commitAiGenerating &&
|
||||
!commitAiReviewing &&
|
||||
stagedCount > 0 &&
|
||||
(commitAiProvider !== "local" || commitAiPhase === "ready"),
|
||||
stagedCount > 0,
|
||||
);
|
||||
let canReview = $derived(canGenerate && commitAiProvider !== "local");
|
||||
let canReview = $derived(canGenerate);
|
||||
let canSplit = $derived(canReview && stagedCount > 1 && !commitAiSplitting);
|
||||
</script>
|
||||
|
||||
@@ -90,7 +81,7 @@
|
||||
type="button"
|
||||
onclick={onSplitStaged}
|
||||
disabled={!canSplit}
|
||||
title={commitAiProvider === "local" ? "Commit splitting currently requires an API provider" : "Suggest logical commits for the staged files"}
|
||||
title="Suggest logical commits for the staged files"
|
||||
>
|
||||
{#if commitAiSplitting}<LoaderCircle class="spin" size={14} aria-hidden="true" />{:else}<GitCommitHorizontal size={14} aria-hidden="true" />{/if}
|
||||
Split
|
||||
@@ -100,7 +91,7 @@
|
||||
type="button"
|
||||
onclick={onReviewStaged}
|
||||
disabled={!canReview}
|
||||
title={commitAiProvider === "local" ? "Pre-commit review currently requires an API provider" : stagedCount === 0 ? "Stage changes first" : "Review staged changes for bugs and risks"}
|
||||
title={stagedCount === 0 ? "Stage changes first" : "Review staged changes for bugs and risks"}
|
||||
>
|
||||
{#if commitAiReviewing}<LoaderCircle class="spin" size={14} aria-hidden="true" />{:else}<ShieldCheck size={14} aria-hidden="true" />{/if}
|
||||
Review
|
||||
@@ -110,9 +101,9 @@
|
||||
type="button"
|
||||
onclick={onGenerateCommitMessage}
|
||||
disabled={!canGenerate}
|
||||
title={aiButtonTitle(commitAiProvider, commitAiPhase, stagedCount)}
|
||||
title={aiButtonTitle(stagedCount)}
|
||||
>
|
||||
{#if commitAiGenerating || localModelLoading}<LoaderCircle class="spin" size={14} aria-hidden="true" />{:else}<Sparkles size={14} aria-hidden="true" />{/if}
|
||||
{#if commitAiGenerating}<LoaderCircle class="spin" size={14} aria-hidden="true" />{:else}<Sparkles size={14} aria-hidden="true" />{/if}
|
||||
Generate
|
||||
</button>
|
||||
<button class="commit-settings-button" type="button" onclick={onOpenAiSettings} disabled={isBusy} title="AI settings" aria-label="AI settings">
|
||||
|
||||
@@ -2116,7 +2116,8 @@
|
||||
.help-search-icon { position: absolute; left: 12px; display: grid; color: var(--color-ink-faint); pointer-events: none; }
|
||||
.help-search input { width: 100%; height: 40px; padding: 0 68px 0 39px; border-color: var(--color-border-input); border-radius: 8px; background: var(--app-input-bg); color: var(--color-ink); font-size: 12.5px; }
|
||||
.help-search kbd { position: absolute; right: 8px; }
|
||||
.help-close { justify-self: end; width: 36px; min-height: 36px; padding: 0; border-color: transparent; border-radius: 7px; background: transparent; color: var(--color-ink-muted); }
|
||||
.help-close { justify-self: end; width: 36px; min-height: 36px; padding: 0; border-color: transparent; border-radius: 7px; background: transparent; color: var(--color-ink-muted); transition: color 120ms ease, border-color 120ms ease, background 120ms ease, box-shadow 120ms ease; }
|
||||
.help-close:hover:not(:disabled), .help-close:focus-visible:not(:disabled) { color: #fff; border-color: #f0646d; background: #d93641; box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); }
|
||||
|
||||
.help-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 0; }
|
||||
.help-nav { display: flex; flex-direction: column; min-height: 0; padding: 14px 10px 12px; border-right: 1px solid var(--color-border); background: var(--color-surface-dim); }
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from "svelte";
|
||||
import { open as openDialog } from "@tauri-apps/plugin-dialog";
|
||||
import { Folder, FolderOpen, GitBranch, LoaderCircle, Plus, X } from "@lucide/svelte";
|
||||
import type { AppLanguage } from "../types";
|
||||
|
||||
interface Props {
|
||||
isBusy: boolean;
|
||||
language: AppLanguage;
|
||||
onInit: (path: string, branch: string) => void;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
let {
|
||||
isBusy = false,
|
||||
language = "en",
|
||||
onInit = () => {},
|
||||
onClose = () => {},
|
||||
}: Props = $props();
|
||||
|
||||
let path = $state("");
|
||||
let branch = $state("main");
|
||||
let browseError = $state("");
|
||||
const isGerman = $derived(language === "de");
|
||||
const pathPlaceholder = navigator.userAgent.includes("Windows")
|
||||
? "C:\\Projects\\my-repository"
|
||||
: "/home/user/projects/my-repository";
|
||||
|
||||
function submit(event: SubmitEvent) {
|
||||
event.preventDefault();
|
||||
const targetPath = path.trim();
|
||||
const branchName = branch.trim();
|
||||
if (!targetPath || !branchName || isBusy) return;
|
||||
onInit(targetPath, branchName);
|
||||
}
|
||||
|
||||
function handleKeydown(event: KeyboardEvent) {
|
||||
if (event.key === "Escape" && !isBusy) onClose();
|
||||
}
|
||||
|
||||
async function chooseFolder() {
|
||||
if (isBusy) return;
|
||||
browseError = "";
|
||||
try {
|
||||
const selected = await openDialog({
|
||||
title: isGerman ? "Ordner für das neue Repository auswählen" : "Select folder for the new repository",
|
||||
directory: true,
|
||||
multiple: false,
|
||||
defaultPath: path.trim() || undefined,
|
||||
});
|
||||
if (typeof selected === "string") path = selected;
|
||||
} catch (error) {
|
||||
browseError = error instanceof Error ? error.message : String(error);
|
||||
}
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
window.addEventListener("keydown", handleKeydown);
|
||||
return () => window.removeEventListener("keydown", handleKeydown);
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="dialog-backdrop app-chrome-backdrop" role="presentation">
|
||||
<div
|
||||
class="dialog init-repository-dialog"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-labelledby="init-repository-title"
|
||||
tabindex="-1"
|
||||
>
|
||||
<header class="dialog-header init-repository-header">
|
||||
<div class="init-repository-heading">
|
||||
<span class="init-repository-icon" aria-hidden="true"><Plus size={18} /></span>
|
||||
<div>
|
||||
<span class="eyebrow">{isGerman ? "Neues Repository" : "New repository"}</span>
|
||||
<h2 id="init-repository-title">{isGerman ? "Repository initialisieren" : "Initialize repository"}</h2>
|
||||
</div>
|
||||
</div>
|
||||
<button class="dialog-close" type="button" onclick={onClose} disabled={isBusy} title={isGerman ? "Schließen" : "Close"}>
|
||||
<X size={18} aria-hidden="true" />
|
||||
</button>
|
||||
</header>
|
||||
|
||||
<form class="init-repository-form" onsubmit={submit}>
|
||||
<p class="init-repository-description">
|
||||
{isGerman
|
||||
? "GitLite richtet in diesem Ordner ein neues Git-Repository ein. Vorhandene Dateien bleiben unverändert."
|
||||
: "GitLite will create a new Git repository in this folder. Existing files will remain unchanged."}
|
||||
</p>
|
||||
|
||||
<label class="new-branch-field init-repository-field init-repository-path-field">
|
||||
<span>{isGerman ? "Zielordner" : "Repository folder"}</span>
|
||||
<div class="init-repository-path-control">
|
||||
<Folder size={16} aria-hidden="true" />
|
||||
<!-- svelte-ignore a11y_autofocus -->
|
||||
<input
|
||||
bind:value={path}
|
||||
autocomplete="off"
|
||||
spellcheck="false"
|
||||
placeholder={pathPlaceholder}
|
||||
disabled={isBusy}
|
||||
autofocus
|
||||
aria-describedby="init-repository-path-hint"
|
||||
/>
|
||||
<button class="btn-secondary init-repository-browse" type="button" onclick={chooseFolder} disabled={isBusy}>
|
||||
<FolderOpen size={15} aria-hidden="true" />
|
||||
{isGerman ? "Auswählen…" : "Browse…"}
|
||||
</button>
|
||||
</div>
|
||||
<small id="init-repository-path-hint">
|
||||
{isGerman ? "Der Ordner wird angelegt, falls er noch nicht existiert." : "The folder will be created if it does not exist."}
|
||||
</small>
|
||||
{#if browseError}<small class="init-repository-error" role="alert">{browseError}</small>{/if}
|
||||
</label>
|
||||
|
||||
<label class="new-branch-field init-repository-field">
|
||||
<span>{isGerman ? "Name des ersten Branches" : "Initial branch name"}</span>
|
||||
<div>
|
||||
<GitBranch size={16} aria-hidden="true" />
|
||||
<input
|
||||
bind:value={branch}
|
||||
autocomplete="off"
|
||||
spellcheck="false"
|
||||
placeholder="main"
|
||||
disabled={isBusy}
|
||||
aria-describedby="init-repository-branch-hint"
|
||||
/>
|
||||
</div>
|
||||
<small id="init-repository-branch-hint">
|
||||
{isGerman ? "Du kannst den Branch später jederzeit umbenennen." : "You can rename the branch at any time."}
|
||||
</small>
|
||||
</label>
|
||||
|
||||
<div class="new-branch-actions init-repository-actions">
|
||||
<button class="btn-secondary" type="button" onclick={onClose} disabled={isBusy}>
|
||||
{isGerman ? "Abbrechen" : "Cancel"}
|
||||
</button>
|
||||
<button class="btn-primary" type="submit" disabled={isBusy || path.trim().length === 0 || branch.trim().length === 0}>
|
||||
{#if isBusy}
|
||||
<LoaderCircle class="spin" size={16} aria-hidden="true" />
|
||||
{:else}
|
||||
<Plus size={16} aria-hidden="true" />
|
||||
{/if}
|
||||
{isGerman ? "Repository erstellen" : "Create repository"}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,119 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from "svelte";
|
||||
import { Check, GitMerge, LoaderCircle, X } from "@lucide/svelte";
|
||||
import type { AppLanguage, GitBranch, MergeStrategy } from "../types";
|
||||
|
||||
interface Props {
|
||||
branch: GitBranch;
|
||||
currentBranch: string;
|
||||
isBusy: boolean;
|
||||
language: AppLanguage;
|
||||
onMerge: (strategy: MergeStrategy) => void;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
let {
|
||||
branch,
|
||||
currentBranch,
|
||||
isBusy = false,
|
||||
language = "en",
|
||||
onMerge = () => {},
|
||||
onClose = () => {},
|
||||
}: Props = $props();
|
||||
|
||||
let strategy = $state<MergeStrategy>("default");
|
||||
const isGerman = $derived(language === "de");
|
||||
const options = $derived([
|
||||
{
|
||||
value: "default" as const,
|
||||
label: isGerman ? "Standard" : "Default",
|
||||
description: isGerman ? "Git wählt Fast-forward oder erstellt einen Merge-Commit." : "Git chooses fast-forward or creates a merge commit.",
|
||||
},
|
||||
{
|
||||
value: "squash" as const,
|
||||
label: "Squash",
|
||||
description: isGerman ? "Fasst alle Änderungen zu einem neuen Commit zusammen." : "Combines all changes into one new commit.",
|
||||
},
|
||||
{
|
||||
value: "ff-only" as const,
|
||||
label: "Fast-forward only",
|
||||
description: isGerman ? "Bricht ab, wenn ein Merge-Commit erforderlich wäre." : "Stops if a merge commit would be required.",
|
||||
},
|
||||
{
|
||||
value: "no-ff" as const,
|
||||
label: "No fast-forward",
|
||||
description: isGerman ? "Erstellt immer einen eigenen Merge-Commit." : "Always creates a dedicated merge commit.",
|
||||
},
|
||||
]);
|
||||
|
||||
function submit(event: SubmitEvent) {
|
||||
event.preventDefault();
|
||||
if (!isBusy) onMerge(strategy);
|
||||
}
|
||||
|
||||
function handleKeydown(event: KeyboardEvent) {
|
||||
if (event.key === "Escape" && !isBusy) onClose();
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
window.addEventListener("keydown", handleKeydown);
|
||||
return () => window.removeEventListener("keydown", handleKeydown);
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="dialog-backdrop app-chrome-backdrop" role="presentation">
|
||||
<div class="dialog merge-branch-dialog" role="dialog" aria-modal="true" aria-labelledby="merge-branch-title" tabindex="-1">
|
||||
<header class="dialog-header merge-branch-header">
|
||||
<div class="merge-branch-heading">
|
||||
<span class="merge-branch-icon" aria-hidden="true"><GitMerge size={18} /></span>
|
||||
<div>
|
||||
<span class="eyebrow">{isGerman ? "Branches zusammenführen" : "Combine branches"}</span>
|
||||
<h2 id="merge-branch-title">{isGerman ? "Merge konfigurieren" : "Configure merge"}</h2>
|
||||
</div>
|
||||
</div>
|
||||
<button class="dialog-close" type="button" onclick={onClose} disabled={isBusy} title={isGerman ? "Schließen" : "Close"}>
|
||||
<X size={18} aria-hidden="true" />
|
||||
</button>
|
||||
</header>
|
||||
|
||||
<form class="merge-branch-form" onsubmit={submit}>
|
||||
<div class="merge-branch-route" aria-label={isGerman ? "Merge-Richtung" : "Merge direction"}>
|
||||
<div>
|
||||
<span>{isGerman ? "Quell-Branch" : "Source branch"}</span>
|
||||
<strong>{branch.name}</strong>
|
||||
</div>
|
||||
<GitMerge size={18} aria-hidden="true" />
|
||||
<div>
|
||||
<span>{isGerman ? "In aktuellen Branch" : "Into current branch"}</span>
|
||||
<strong>{currentBranch || "HEAD"}</strong>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<fieldset class="merge-strategy-fieldset" disabled={isBusy}>
|
||||
<legend>{isGerman ? "Merge-Strategie" : "Merge strategy"}</legend>
|
||||
<div class="merge-strategy-grid">
|
||||
{#each options as option}
|
||||
<label class:active={strategy === option.value} class="merge-strategy-option">
|
||||
<input type="radio" name="merge-strategy" value={option.value} bind:group={strategy} />
|
||||
<span class="merge-strategy-check" aria-hidden="true">
|
||||
{#if strategy === option.value}<Check size={13} />{/if}
|
||||
</span>
|
||||
<span class="merge-strategy-copy">
|
||||
<strong>{option.label}</strong>
|
||||
<small>{option.description}</small>
|
||||
</span>
|
||||
</label>
|
||||
{/each}
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<div class="merge-branch-actions">
|
||||
<button class="btn-secondary" type="button" onclick={onClose} disabled={isBusy}>{isGerman ? "Abbrechen" : "Cancel"}</button>
|
||||
<button class="btn-primary" type="submit" disabled={isBusy}>
|
||||
{#if isBusy}<LoaderCircle class="spin" size={16} aria-hidden="true" />{:else}<GitMerge size={16} aria-hidden="true" />{/if}
|
||||
{isGerman ? "Branch mergen" : "Merge branch"}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@@ -33,7 +33,7 @@
|
||||
<style>
|
||||
.repo-loading {
|
||||
position: fixed;
|
||||
top: calc(var(--app-titlebar-height, 42px) + 56px);
|
||||
top: calc(var(--app-titlebar-height, 40px) + var(--app-repo-tabbar-height, 36px));
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
@@ -47,8 +47,8 @@
|
||||
color-mix(in srgb, var(--color-accent) 13%, transparent),
|
||||
transparent 38%
|
||||
),
|
||||
var(--app-dialog-backdrop);
|
||||
backdrop-filter: blur(5px);
|
||||
color-mix(in srgb, var(--app-dialog-bg) 78%, #05070a 22%);
|
||||
backdrop-filter: blur(9px);
|
||||
animation: overlay-in 180ms ease;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
);
|
||||
const versionLabel = $derived(
|
||||
version && currentVersion
|
||||
? `${currentVersion} -> ${version}`
|
||||
? `${currentVersion} → ${version}`
|
||||
: version
|
||||
? `Version ${version}`
|
||||
: "New version",
|
||||
@@ -69,24 +69,21 @@
|
||||
role={state === "error" ? "alert" : "status"}
|
||||
aria-live={state === "error" ? "assertive" : "polite"}
|
||||
>
|
||||
<div class="update-toast-glow" aria-hidden="true"></div>
|
||||
|
||||
<header class="update-toast-header">
|
||||
<div class="update-toast-icon" class:busy={isBusy}>
|
||||
{#if state === "downloading"}
|
||||
<LoaderCircle class="spin" size={21} aria-hidden="true" />
|
||||
<LoaderCircle class="spin" size={18} aria-hidden="true" />
|
||||
{:else if state === "installed"}
|
||||
<PackageCheck size={21} aria-hidden="true" />
|
||||
<PackageCheck size={18} aria-hidden="true" />
|
||||
{:else if state === "error"}
|
||||
<AlertCircle size={21} aria-hidden="true" />
|
||||
<AlertCircle size={18} aria-hidden="true" />
|
||||
{:else}
|
||||
<Sparkles size={21} aria-hidden="true" />
|
||||
<Sparkles size={18} aria-hidden="true" />
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div class="update-toast-content">
|
||||
<div class="update-toast-top">
|
||||
<div class="update-toast-copy">
|
||||
<span class="update-toast-kicker">{versionLabel}</span>
|
||||
<span class="update-toast-kicker">Gitty update · {versionLabel}</span>
|
||||
<h2>{title}</h2>
|
||||
</div>
|
||||
|
||||
@@ -95,8 +92,9 @@
|
||||
<X size={15} aria-hidden="true" />
|
||||
</button>
|
||||
{/if}
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="update-toast-body">
|
||||
<p>{description}</p>
|
||||
|
||||
{#if showProgress}
|
||||
@@ -115,7 +113,9 @@
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<div class="update-toast-actions">
|
||||
</div>
|
||||
|
||||
<footer class="update-toast-actions">
|
||||
{#if state === "installed"}
|
||||
<button class="update-toast-secondary" type="button" onclick={onDismiss}>
|
||||
Got it
|
||||
@@ -142,6 +142,5 @@
|
||||
{/if}
|
||||
</button>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
</section>
|
||||
|
||||
+27
-19
@@ -3,9 +3,8 @@ import { tracedInvoke as invoke } from "./telemetry";
|
||||
import type {
|
||||
AiReviewResult,
|
||||
AiCommitPlan,
|
||||
CommitAiLocalProfile,
|
||||
CommitAiProvider,
|
||||
CommitAiStatus,
|
||||
CloneOptions,
|
||||
ConflictFile,
|
||||
DetectedExternalTool,
|
||||
ExternalToolCommand,
|
||||
@@ -30,7 +29,6 @@ import type {
|
||||
GitStatus,
|
||||
GitTag,
|
||||
GitWorktree,
|
||||
LocalModelOption,
|
||||
PatchApplyAction,
|
||||
RepositoryBundle,
|
||||
StoredCredential,
|
||||
@@ -83,6 +81,7 @@ export function cloneRepository(
|
||||
username?: string,
|
||||
password?: string,
|
||||
commitLimit = 100,
|
||||
options: CloneOptions = { branch: null, blobless: false, customFlags: "", shallowDepth: null, shallowSince: null, sparse: false, sparsePaths: [] },
|
||||
): Promise<RepositoryBundle> {
|
||||
return invoke<RepositoryBundle>("clone_repository", {
|
||||
remoteUrl,
|
||||
@@ -91,6 +90,13 @@ export function cloneRepository(
|
||||
username: username ?? null,
|
||||
password: password ?? null,
|
||||
commitLimit,
|
||||
branch: options.branch,
|
||||
blobless: options.blobless,
|
||||
customFlags: options.customFlags,
|
||||
shallowDepth: options.shallowDepth,
|
||||
shallowSince: options.shallowSince,
|
||||
sparse: options.sparse,
|
||||
sparsePaths: options.sparsePaths,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -369,22 +375,9 @@ 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");
|
||||
}
|
||||
|
||||
export function commitAiLoad(modelId: string): Promise<void> {
|
||||
return invoke<void>("commit_ai_load", { modelId });
|
||||
}
|
||||
|
||||
export function commitAiLocalModels(): Promise<LocalModelOption[]> {
|
||||
return invoke<LocalModelOption[]>("commit_ai_local_models");
|
||||
}
|
||||
|
||||
export interface CommitAiGenerateOptions {
|
||||
notes?: string;
|
||||
provider: CommitAiProvider;
|
||||
localProfile?: CommitAiLocalProfile;
|
||||
model?: string;
|
||||
apiKey?: string;
|
||||
baseUrl?: string;
|
||||
@@ -395,7 +388,6 @@ 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,
|
||||
@@ -422,8 +414,24 @@ export function commitAiSplit(path: string, options: CommitAiGenerateOptions): P
|
||||
});
|
||||
}
|
||||
|
||||
export function pull(path: string, username?: string, password?: string, strategy: PullStrategy = "merge", remote?: string, branch?: string): Promise<GitStatus> {
|
||||
return invoke<GitStatus>("pull", { path, username: username ?? null, password: password ?? null, strategy, remote: remote || null, branch: branch || null });
|
||||
export function pull(
|
||||
path: string,
|
||||
username?: string,
|
||||
password?: string,
|
||||
strategy: PullStrategy = "merge",
|
||||
remote?: string,
|
||||
branch?: string,
|
||||
allowUnrelatedHistories = false,
|
||||
): Promise<GitStatus> {
|
||||
return invoke<GitStatus>("pull", {
|
||||
path,
|
||||
username: username ?? null,
|
||||
password: password ?? null,
|
||||
strategy,
|
||||
remote: remote || null,
|
||||
branch: branch || null,
|
||||
allowUnrelatedHistories,
|
||||
});
|
||||
}
|
||||
|
||||
export function fetchRemote(path: string, username?: string, password?: string, prune = false, remote?: string): Promise<GitStatus> {
|
||||
|
||||
+11
-17
@@ -9,9 +9,7 @@ export type FileStatusKind =
|
||||
|
||||
export type GitIgnoreKind = "file" | "extension" | "folder";
|
||||
|
||||
export type CommitAiPhase = "idle" | "loading" | "ready" | "error";
|
||||
export type CommitAiProvider = "local" | "openai" | "anthropic" | "custom";
|
||||
export type CommitAiLocalProfile = "fast" | "balanced" | "detailed";
|
||||
export type CommitAiProvider = "openai" | "anthropic" | "custom";
|
||||
export type AppTheme = "system" | "light" | "dark";
|
||||
export type AppAppearance = "modern" | "classic" | "custom";
|
||||
export type AppLanguage = "en" | "de";
|
||||
@@ -74,12 +72,6 @@ export interface CustomThemeColors {
|
||||
text: string;
|
||||
}
|
||||
|
||||
export interface CommitAiStatus {
|
||||
phase: CommitAiPhase;
|
||||
model_id: string | null;
|
||||
error: string | null;
|
||||
}
|
||||
|
||||
export type AiReviewRisk = "low" | "medium" | "high";
|
||||
export type AiReviewSeverity = "critical" | "warning" | "info";
|
||||
|
||||
@@ -109,16 +101,8 @@ export interface AiCommitPlan {
|
||||
groups: AiCommitGroup[];
|
||||
}
|
||||
|
||||
export interface LocalModelOption {
|
||||
id: string;
|
||||
label: string;
|
||||
approx_size_mb: number;
|
||||
}
|
||||
|
||||
export interface AiSettings {
|
||||
provider: CommitAiProvider;
|
||||
localModelId: string;
|
||||
localProfile: CommitAiLocalProfile;
|
||||
openaiModel: string;
|
||||
anthropicModel: string;
|
||||
customBaseUrl: string;
|
||||
@@ -177,6 +161,16 @@ export interface GitRemote { name: string; fetch_url: string; push_url: string;
|
||||
export type PullStrategy = "merge" | "rebase" | "ff-only";
|
||||
export type MergeStrategy = "default" | "squash" | "ff-only" | "no-ff";
|
||||
|
||||
export interface CloneOptions {
|
||||
branch: string | null;
|
||||
blobless: boolean;
|
||||
customFlags: string;
|
||||
shallowDepth: number | null;
|
||||
shallowSince: string | null;
|
||||
sparse: boolean;
|
||||
sparsePaths: string[];
|
||||
}
|
||||
|
||||
export interface GitFileStatus {
|
||||
path: string;
|
||||
old_path: string | null;
|
||||
|
||||
Reference in New Issue
Block a user