Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c174fb3a80 | ||
|
|
c747e02f29 | ||
|
|
791275f341 | ||
|
|
f7b8beaad4 | ||
|
|
d0bca62362 | ||
|
|
d3cde83518 | ||
|
|
3fdd6d3467 | ||
|
|
900a6fa230 | ||
|
|
2d7946f6fd | ||
|
|
0af57f1818 | ||
|
|
8e6811b786 | ||
|
|
de8832a919 | ||
|
|
25b98d7c4d | ||
|
|
7ef1a2dac8 | ||
|
|
44a5b776d7 | ||
|
|
55b4c9fc50 |
@@ -100,7 +100,11 @@
|
||||
"Bash(pkg-config --exists openssl)",
|
||||
"Bash(sudo apt-get install -y libssl-dev pkg-config)",
|
||||
"Bash(dpkg -L libssl3t64)",
|
||||
"Bash(grep *)"
|
||||
"Bash(grep *)",
|
||||
"Read(//home/christoph/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tauri-2.11.5/src/**)",
|
||||
"Read(//home/christoph/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tauri-runtime-wry-2.11.4/src/**)",
|
||||
"Read(//home/christoph/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tauri-2.11.5/src/window/**)",
|
||||
"WebSearch"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "gitty",
|
||||
"version": "2026.7.16",
|
||||
"version": "0.200.10",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "gitty",
|
||||
"version": "2026.7.16",
|
||||
"version": "0.200.10",
|
||||
"dependencies": {
|
||||
"@lucide/svelte": "^1.21.0",
|
||||
"@tailwindcss/vite": "^4.3.1",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "gitty",
|
||||
"version": "2026.7.16",
|
||||
"version": "0.200.10",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
||||
+15
-1
@@ -177,7 +177,21 @@ pub fn set_sync_badge(
|
||||
.map_err(|err| format!("Could not set taskbar badge: {err}"))?;
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
// Native badge count: works on Linux (via the desktop's launcher API, e.g. Unity's
|
||||
// LauncherEntry, also honored by GNOME/KDE) and macOS (dock badge). Matched against the
|
||||
// app's `<product-name>.desktop` file on Linux, so it's a silent no-op on launchers that
|
||||
// don't implement the protocol.
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
{
|
||||
let Some(window) = app.get_webview_window("main") else {
|
||||
return Ok(());
|
||||
};
|
||||
window
|
||||
.set_badge_count(if count > 0 { Some(count as i64) } else { None })
|
||||
.map_err(|err| format!("Could not set taskbar badge: {err}"))?;
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "windows", target_os = "linux", target_os = "macos")))]
|
||||
{
|
||||
let _ = (app, count);
|
||||
}
|
||||
|
||||
+580
-7
@@ -1,7 +1,9 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{
|
||||
collections::{BTreeMap, BTreeSet},
|
||||
env,
|
||||
ffi::{OsStr, OsString},
|
||||
fs,
|
||||
path::{Path, PathBuf},
|
||||
process::{Command, Output, Stdio},
|
||||
sync::{
|
||||
@@ -170,6 +172,112 @@ pub struct GitSearchHit {
|
||||
pub matches_added: u32,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
|
||||
pub struct RebaseCommit {
|
||||
pub hash: String,
|
||||
pub short_hash: String,
|
||||
pub summary: String,
|
||||
pub author_name: String,
|
||||
pub date: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum RebaseAction {
|
||||
Pick,
|
||||
Reword,
|
||||
Squash,
|
||||
Fixup,
|
||||
Drop,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
|
||||
pub struct RebasePlanItem {
|
||||
pub hash: String,
|
||||
pub action: RebaseAction,
|
||||
pub message: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
|
||||
pub struct ReflogEntry {
|
||||
pub hash: String,
|
||||
pub short_hash: String,
|
||||
pub selector: String,
|
||||
pub action: String,
|
||||
pub author_name: String,
|
||||
pub date: String,
|
||||
}
|
||||
|
||||
const SEQUENCE_EDITOR_PLAN_ENV: &str = "GITTY_SEQUENCE_EDITOR_PLAN";
|
||||
const COMMIT_EDITOR_QUEUE_ENV: &str = "GITTY_COMMIT_EDITOR_QUEUE";
|
||||
const REBASE_TODO_FILE: &str = "gitty-interactive-rebase-todo";
|
||||
const REWORD_QUEUE_FILE: &str = "gitty-interactive-rebase-messages";
|
||||
const SEQUENCE_HELPER_STEM: &str = ".gitty-sequence-editor";
|
||||
const COMMIT_HELPER_STEM: &str = ".gitty-commit-editor";
|
||||
|
||||
pub fn run_sequence_editor_if_requested() -> Option<Result<(), String>> {
|
||||
let executable = env::current_exe().ok()?;
|
||||
let executable_name = executable.file_name()?.to_string_lossy();
|
||||
let target = env::args_os()
|
||||
.nth(1)
|
||||
.ok_or_else(|| "Git did not provide a sequence-editor target path.".to_string());
|
||||
if executable_name.contains("gitty-sequence-editor") {
|
||||
let plan = env::var_os(SEQUENCE_EDITOR_PLAN_ENV)?;
|
||||
return Some(target.and_then(|target| {
|
||||
fs::copy(PathBuf::from(plan), PathBuf::from(target))
|
||||
.map(|_| ())
|
||||
.map_err(|err| format!("Could not write the interactive rebase plan: {err}"))
|
||||
}));
|
||||
}
|
||||
if executable_name.contains("gitty-commit-editor") {
|
||||
let queue = env::var_os(COMMIT_EDITOR_QUEUE_ENV)?;
|
||||
return Some(
|
||||
target.and_then(|target| apply_reword_message(Path::new(&queue), Path::new(&target))),
|
||||
);
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
fn apply_reword_message(queue_path: &Path, message_path: &Path) -> Result<(), String> {
|
||||
let queue = fs::read_to_string(queue_path)
|
||||
.map_err(|err| format!("Could not read the reword queue: {err}"))?;
|
||||
if queue.is_empty() {
|
||||
return Ok(());
|
||||
}
|
||||
let current = fs::read_to_string(message_path)
|
||||
.map_err(|err| format!("Could not read the commit message: {err}"))?;
|
||||
let current_subject = current
|
||||
.lines()
|
||||
.map(str::trim)
|
||||
.find(|line| !line.is_empty() && !line.starts_with('#'))
|
||||
.unwrap_or("");
|
||||
|
||||
let mut remaining = Vec::new();
|
||||
let mut replacement = None;
|
||||
for record in queue.split('\x1e').filter(|record| !record.is_empty()) {
|
||||
let Some((old, new)) = record.split_once('\x1f') else {
|
||||
return Err("The reword queue is malformed.".to_string());
|
||||
};
|
||||
if replacement.is_none() && old == current_subject {
|
||||
replacement = Some(new.to_string());
|
||||
} else {
|
||||
remaining.push(record);
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(message) = replacement {
|
||||
fs::write(message_path, format!("{message}\n"))
|
||||
.map_err(|err| format!("Could not update the commit message: {err}"))?;
|
||||
let mut next_queue = remaining.join("\x1e");
|
||||
if !next_queue.is_empty() {
|
||||
next_queue.push('\x1e');
|
||||
}
|
||||
fs::write(queue_path, next_queue)
|
||||
.map_err(|err| format!("Could not update the reword queue: {err}"))?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Clone, PartialEq, Eq)]
|
||||
struct BranchInfo {
|
||||
current_branch: Option<String>,
|
||||
@@ -838,7 +946,11 @@ pub async fn unstage_files(path: String, files: Vec<String>) -> Result<GitStatus
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn restore_files(path: String, files: Vec<String>, staged: bool) -> Result<GitStatus, String> {
|
||||
pub async fn restore_files(
|
||||
path: String,
|
||||
files: Vec<String>,
|
||||
staged: bool,
|
||||
) -> Result<GitStatus, String> {
|
||||
tauri::async_runtime::spawn_blocking(move || -> Result<GitStatus, String> {
|
||||
let repo = resolve_repo(&path)?;
|
||||
validate_files(&files)?;
|
||||
@@ -1481,6 +1593,86 @@ pub async fn rebase_branch(path: String, branch: String) -> Result<GitStatus, St
|
||||
.map_err(|err| format!("Could not rebase: {err}"))?
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn list_interactive_rebase_commits(
|
||||
path: String,
|
||||
base: String,
|
||||
) -> Result<Vec<RebaseCommit>, String> {
|
||||
let repo = resolve_repo(&path)?;
|
||||
interactive_rebase_commits_for_repo(&repo, &base)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn start_interactive_rebase(
|
||||
path: String,
|
||||
base: String,
|
||||
plan: Vec<RebasePlanItem>,
|
||||
) -> Result<GitStatus, String> {
|
||||
tauri::async_runtime::spawn_blocking(move || -> Result<GitStatus, String> {
|
||||
let repo = resolve_repo(&path)?;
|
||||
let status = status_for_repo(&repo)?;
|
||||
if !status.clean {
|
||||
return Err(
|
||||
"Commit or stash working tree changes before starting an interactive rebase."
|
||||
.to_string(),
|
||||
);
|
||||
}
|
||||
if status.rebase_in_progress || status.cherry_pick_in_progress {
|
||||
return Err(
|
||||
"Finish the current Git operation before starting an interactive rebase."
|
||||
.to_string(),
|
||||
);
|
||||
}
|
||||
|
||||
let base_hash = verify_commit(&repo, &base)?;
|
||||
let available = interactive_rebase_commits_for_repo(&repo, &base_hash)?;
|
||||
validate_rebase_plan(&available, &plan)?;
|
||||
|
||||
let todo = build_rebase_todo(&available, &plan)?;
|
||||
let reword_queue = build_reword_queue(&available, &plan)?;
|
||||
let git_dir = git_dir_for_repo(&repo)?;
|
||||
cleanup_interactive_rebase_helpers(&repo);
|
||||
let todo_path = git_dir.join(REBASE_TODO_FILE);
|
||||
let reword_queue_path = git_dir.join(REWORD_QUEUE_FILE);
|
||||
fs::write(&todo_path, todo)
|
||||
.map_err(|err| format!("Could not prepare interactive rebase plan: {err}"))?;
|
||||
fs::write(&reword_queue_path, reword_queue)
|
||||
.map_err(|err| format!("Could not prepare reword messages: {err}"))?;
|
||||
|
||||
let sequence_helper_path = repo.join(sequence_helper_name());
|
||||
let commit_helper_path = repo.join(commit_helper_name());
|
||||
let current_exe = env::current_exe()
|
||||
.map_err(|err| format!("Could not locate the Gitty executable: {err}"))?;
|
||||
fs::copy(¤t_exe, &sequence_helper_path)
|
||||
.and_then(|_| fs::copy(¤t_exe, &commit_helper_path))
|
||||
.map_err(|err| format!("Could not prepare interactive rebase helpers: {err}"))?;
|
||||
|
||||
let sequence_editor_command = format!("./{}", sequence_helper_name());
|
||||
let commit_editor_command = format!("./{}", commit_helper_name());
|
||||
let output = git_command()
|
||||
.arg("-C")
|
||||
.arg(&repo)
|
||||
.args(["rebase", "-i", base_hash.as_str()])
|
||||
.env("GIT_SEQUENCE_EDITOR", sequence_editor_command)
|
||||
.env(SEQUENCE_EDITOR_PLAN_ENV, &todo_path)
|
||||
.env("GIT_EDITOR", commit_editor_command)
|
||||
.env(COMMIT_EDITOR_QUEUE_ENV, &reword_queue_path)
|
||||
.output()
|
||||
.map_err(|err| format!("Could not start Git. Is Git installed? {err}"));
|
||||
|
||||
let result = rebase_status_or_error(&repo, output?, "Interactive rebase failed", true);
|
||||
let _ = fs::remove_file(&todo_path);
|
||||
let _ = fs::remove_file(&sequence_helper_path);
|
||||
if !matches!(&result, Ok(status) if status.rebase_in_progress) {
|
||||
let _ = fs::remove_file(&reword_queue_path);
|
||||
let _ = fs::remove_file(&commit_helper_path);
|
||||
}
|
||||
result
|
||||
})
|
||||
.await
|
||||
.map_err(|err| format!("Could not run interactive rebase: {err}"))?
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn rebase_continue(path: String) -> Result<GitStatus, String> {
|
||||
let repo = resolve_repo(&path)?;
|
||||
@@ -1488,15 +1680,27 @@ pub fn rebase_continue(path: String) -> Result<GitStatus, String> {
|
||||
return Err("No rebase is currently in progress.".to_string());
|
||||
}
|
||||
|
||||
let output = git_command()
|
||||
.arg("-C")
|
||||
.arg(&repo)
|
||||
.args(["rebase", "--continue"])
|
||||
.env("GIT_EDITOR", "true")
|
||||
let git_dir = git_dir_for_repo(&repo)?;
|
||||
let queue_path = git_dir.join(REWORD_QUEUE_FILE);
|
||||
let helper_path = repo.join(commit_helper_name());
|
||||
let mut command = git_command();
|
||||
command.arg("-C").arg(&repo).args(["rebase", "--continue"]);
|
||||
if queue_path.exists() && helper_path.exists() {
|
||||
command
|
||||
.env("GIT_EDITOR", format!("./{}", commit_helper_name()))
|
||||
.env(COMMIT_EDITOR_QUEUE_ENV, &queue_path);
|
||||
} else {
|
||||
command.env("GIT_EDITOR", "true");
|
||||
}
|
||||
let output = command
|
||||
.output()
|
||||
.map_err(|err| format!("Could not start Git. Is Git installed? {err}"))?;
|
||||
|
||||
rebase_status_or_error(&repo, output, "Rebase continue failed", false)
|
||||
let result = rebase_status_or_error(&repo, output, "Rebase continue failed", false);
|
||||
if !matches!(&result, Ok(status) if status.rebase_in_progress) {
|
||||
cleanup_interactive_rebase_helpers(&repo);
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
@@ -1507,9 +1711,249 @@ pub fn rebase_abort(path: String) -> Result<GitStatus, String> {
|
||||
}
|
||||
|
||||
run_git(&repo, ["rebase", "--abort"])?;
|
||||
cleanup_interactive_rebase_helpers(&repo);
|
||||
status_for_repo(&repo)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn list_reflog(path: String, limit: Option<u32>) -> Result<Vec<ReflogEntry>, String> {
|
||||
let repo = resolve_repo(&path)?;
|
||||
let limit = limit.unwrap_or(250).clamp(1, 1_000).to_string();
|
||||
let output = run_git(
|
||||
&repo,
|
||||
[
|
||||
"reflog",
|
||||
"show",
|
||||
"--date=iso-strict",
|
||||
"--format=%H%x1f%h%x1f%gD%x1f%gs%x1f%an%x1f%aI%x1e",
|
||||
"-n",
|
||||
limit.as_str(),
|
||||
],
|
||||
)?;
|
||||
parse_reflog(&output)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn restore_reflog_entry(
|
||||
path: String,
|
||||
commit: String,
|
||||
branch: String,
|
||||
) -> Result<GitStatus, String> {
|
||||
let repo = resolve_repo(&path)?;
|
||||
let status = status_for_repo(&repo)?;
|
||||
if !status.clean {
|
||||
return Err(
|
||||
"Commit or stash working tree changes before restoring from the reflog.".to_string(),
|
||||
);
|
||||
}
|
||||
let commit_hash = verify_commit(&repo, &commit)?;
|
||||
let branch = validate_new_branch_name(&repo, &branch)?;
|
||||
run_git(
|
||||
&repo,
|
||||
["checkout", "-b", branch.as_str(), commit_hash.as_str()],
|
||||
)?;
|
||||
status_for_repo(&repo)
|
||||
}
|
||||
|
||||
fn interactive_rebase_commits_for_repo(
|
||||
repo: &Path,
|
||||
base: &str,
|
||||
) -> Result<Vec<RebaseCommit>, String> {
|
||||
let base_hash = verify_commit(repo, base)?;
|
||||
|
||||
let range = format!("{base_hash}..HEAD");
|
||||
let merges = run_git(repo, ["rev-list", "--merges", range.as_str()])?;
|
||||
if !String::from_utf8_lossy(&merges).trim().is_empty() {
|
||||
return Err("Interactive rebase currently supports linear commit ranges only. Choose a base after the last merge commit.".to_string());
|
||||
}
|
||||
|
||||
let output = run_git(
|
||||
repo,
|
||||
[
|
||||
"log",
|
||||
"--reverse",
|
||||
"--format=%H%x1f%h%x1f%s%x1f%an%x1f%aI%x1e",
|
||||
range.as_str(),
|
||||
],
|
||||
)?;
|
||||
|
||||
let mut commits = Vec::new();
|
||||
for raw in output.split(|byte| *byte == 0x1e) {
|
||||
let record = String::from_utf8_lossy(raw);
|
||||
let record = record.trim_matches(['\r', '\n', ' ']);
|
||||
if record.is_empty() {
|
||||
continue;
|
||||
}
|
||||
let fields = record.split('\x1f').collect::<Vec<_>>();
|
||||
if fields.len() != 5 {
|
||||
return Err("Git returned an unexpected interactive rebase record.".to_string());
|
||||
}
|
||||
commits.push(RebaseCommit {
|
||||
hash: fields[0].to_string(),
|
||||
short_hash: fields[1].to_string(),
|
||||
summary: fields[2].to_string(),
|
||||
author_name: fields[3].to_string(),
|
||||
date: fields[4].to_string(),
|
||||
});
|
||||
}
|
||||
Ok(commits)
|
||||
}
|
||||
|
||||
fn validate_rebase_plan(commits: &[RebaseCommit], plan: &[RebasePlanItem]) -> Result<(), String> {
|
||||
if commits.is_empty() {
|
||||
return Err("There are no commits to rebase onto the selected base.".to_string());
|
||||
}
|
||||
if commits.len() != plan.len() {
|
||||
return Err("The rebase plan must include every commit exactly once.".to_string());
|
||||
}
|
||||
|
||||
let expected = commits
|
||||
.iter()
|
||||
.map(|item| item.hash.as_str())
|
||||
.collect::<BTreeSet<_>>();
|
||||
let actual = plan
|
||||
.iter()
|
||||
.map(|item| item.hash.as_str())
|
||||
.collect::<BTreeSet<_>>();
|
||||
if actual.len() != plan.len() || actual != expected {
|
||||
return Err(
|
||||
"The rebase plan contains missing, duplicate, or unexpected commits.".to_string(),
|
||||
);
|
||||
}
|
||||
|
||||
let mut has_kept_commit = false;
|
||||
for item in plan {
|
||||
match item.action {
|
||||
RebaseAction::Drop => {}
|
||||
RebaseAction::Squash | RebaseAction::Fixup if !has_kept_commit => {
|
||||
return Err("Squash and fixup need an earlier picked commit.".to_string());
|
||||
}
|
||||
RebaseAction::Reword => {
|
||||
let message = item.message.as_deref().unwrap_or("").trim();
|
||||
if message.is_empty() || message.contains(['\r', '\n']) {
|
||||
return Err("Reword messages must be a single non-empty line.".to_string());
|
||||
}
|
||||
has_kept_commit = true;
|
||||
}
|
||||
_ => has_kept_commit = true,
|
||||
}
|
||||
}
|
||||
if !has_kept_commit {
|
||||
return Err("Keep at least one commit in the interactive rebase plan.".to_string());
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn build_rebase_todo(commits: &[RebaseCommit], plan: &[RebasePlanItem]) -> Result<String, String> {
|
||||
let by_hash = commits
|
||||
.iter()
|
||||
.map(|commit| (commit.hash.as_str(), commit))
|
||||
.collect::<BTreeMap<_, _>>();
|
||||
let mut todo = String::new();
|
||||
for item in plan {
|
||||
let commit = by_hash
|
||||
.get(item.hash.as_str())
|
||||
.ok_or_else(|| "The rebase plan references an unknown commit.".to_string())?;
|
||||
let summary = commit.summary.replace(['\r', '\n'], " ");
|
||||
match item.action {
|
||||
RebaseAction::Pick => todo.push_str(&format!("pick {} {}\n", item.hash, summary)),
|
||||
RebaseAction::Reword => todo.push_str(&format!("reword {} {}\n", item.hash, summary)),
|
||||
RebaseAction::Squash => todo.push_str(&format!("squash {} {}\n", item.hash, summary)),
|
||||
RebaseAction::Fixup => todo.push_str(&format!("fixup {} {}\n", item.hash, summary)),
|
||||
RebaseAction::Drop => todo.push_str(&format!("drop {} {}\n", item.hash, summary)),
|
||||
}
|
||||
}
|
||||
Ok(todo)
|
||||
}
|
||||
|
||||
fn build_reword_queue(commits: &[RebaseCommit], plan: &[RebasePlanItem]) -> Result<String, String> {
|
||||
let by_hash = commits
|
||||
.iter()
|
||||
.map(|commit| (commit.hash.as_str(), commit))
|
||||
.collect::<BTreeMap<_, _>>();
|
||||
let mut queue = String::new();
|
||||
for item in plan
|
||||
.iter()
|
||||
.filter(|item| item.action == RebaseAction::Reword)
|
||||
{
|
||||
let commit = by_hash
|
||||
.get(item.hash.as_str())
|
||||
.ok_or_else(|| "The rebase plan references an unknown commit.".to_string())?;
|
||||
let message = item.message.as_deref().unwrap_or("").trim();
|
||||
queue.push_str(&commit.summary.replace(['\r', '\n'], " "));
|
||||
queue.push('\x1f');
|
||||
queue.push_str(message);
|
||||
queue.push('\x1e');
|
||||
}
|
||||
Ok(queue)
|
||||
}
|
||||
|
||||
fn git_dir_for_repo(repo: &Path) -> Result<PathBuf, String> {
|
||||
let output = run_git(repo, ["rev-parse", "--absolute-git-dir"])?;
|
||||
let path = String::from_utf8_lossy(&output).trim().to_string();
|
||||
if path.is_empty() {
|
||||
Err("Git could not determine its metadata directory.".to_string())
|
||||
} else {
|
||||
Ok(PathBuf::from(path))
|
||||
}
|
||||
}
|
||||
|
||||
fn sequence_helper_name() -> &'static str {
|
||||
if cfg!(windows) {
|
||||
".gitty-sequence-editor.exe"
|
||||
} else {
|
||||
SEQUENCE_HELPER_STEM
|
||||
}
|
||||
}
|
||||
|
||||
fn commit_helper_name() -> &'static str {
|
||||
if cfg!(windows) {
|
||||
".gitty-commit-editor.exe"
|
||||
} else {
|
||||
COMMIT_HELPER_STEM
|
||||
}
|
||||
}
|
||||
|
||||
fn cleanup_interactive_rebase_helpers(repo: &Path) {
|
||||
if let Ok(git_dir) = git_dir_for_repo(repo) {
|
||||
let _ = fs::remove_file(git_dir.join(REBASE_TODO_FILE));
|
||||
let _ = fs::remove_file(git_dir.join(REWORD_QUEUE_FILE));
|
||||
}
|
||||
let _ = fs::remove_file(repo.join(sequence_helper_name()));
|
||||
let _ = fs::remove_file(repo.join(commit_helper_name()));
|
||||
}
|
||||
|
||||
fn is_interactive_rebase_helper_path(path: &str) -> bool {
|
||||
matches!(
|
||||
path.replace('\\', "/").rsplit('/').next(),
|
||||
Some(name) if name == sequence_helper_name() || name == commit_helper_name()
|
||||
)
|
||||
}
|
||||
|
||||
fn parse_reflog(output: &[u8]) -> Result<Vec<ReflogEntry>, String> {
|
||||
let mut entries = Vec::new();
|
||||
for raw in output.split(|byte| *byte == 0x1e) {
|
||||
let record = String::from_utf8_lossy(raw);
|
||||
let record = record.trim_matches(['\r', '\n', ' ']);
|
||||
if record.is_empty() {
|
||||
continue;
|
||||
}
|
||||
let fields = record.split('\x1f').collect::<Vec<_>>();
|
||||
if fields.len() != 6 {
|
||||
return Err("Git returned an unexpected reflog record.".to_string());
|
||||
}
|
||||
entries.push(ReflogEntry {
|
||||
hash: fields[0].to_string(),
|
||||
short_hash: fields[1].to_string(),
|
||||
selector: fields[2].to_string(),
|
||||
action: fields[3].to_string(),
|
||||
author_name: fields[4].to_string(),
|
||||
date: fields[5].to_string(),
|
||||
});
|
||||
}
|
||||
Ok(entries)
|
||||
}
|
||||
|
||||
fn rebase_status_or_error(
|
||||
repo: &Path,
|
||||
output: Output,
|
||||
@@ -2521,6 +2965,7 @@ fn status_for_repo(repo: &Path) -> Result<GitStatus, String> {
|
||||
)?;
|
||||
let (branch, mut files) = parse_status_output(&output)?;
|
||||
detect_worktree_renames(repo, &mut files);
|
||||
files.retain(|file| !is_interactive_rebase_helper_path(&file.path));
|
||||
|
||||
Ok(GitStatus {
|
||||
repo_path: repo.to_string_lossy().to_string(),
|
||||
@@ -4582,6 +5027,134 @@ mod tests {
|
||||
assert_eq!(branch.behind, 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parses_reflog_records() {
|
||||
let raw = b"1111111111111111111111111111111111111111\x1f1111111\x1fHEAD@{0}\x1fcommit: Add feature\x1fAda\x1f2026-07-10T12:00:00+02:00\x1e";
|
||||
let entries = parse_reflog(raw).expect("reflog should parse");
|
||||
|
||||
assert_eq!(entries.len(), 1);
|
||||
assert_eq!(entries[0].selector, "HEAD@{0}");
|
||||
assert_eq!(entries[0].action, "commit: Add feature");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn commit_editor_applies_only_the_matching_reword_message() {
|
||||
let temp = temp_dir("commit_editor");
|
||||
let queue = temp.path.join("queue");
|
||||
let message = temp.path.join("COMMIT_EDITMSG");
|
||||
fs::write(
|
||||
&queue,
|
||||
"first commit\x1frenamed first\x1esecond commit\x1frenamed second\x1e",
|
||||
)
|
||||
.expect("queue should be written");
|
||||
fs::write(
|
||||
&message,
|
||||
"first commit\n\n# Please enter the commit message\n",
|
||||
)
|
||||
.expect("message should be written");
|
||||
|
||||
apply_reword_message(&queue, &message).expect("message should be applied");
|
||||
|
||||
assert_eq!(fs::read_to_string(&message).unwrap(), "renamed first\n");
|
||||
assert_eq!(
|
||||
fs::read_to_string(&queue).unwrap(),
|
||||
"second commit\x1frenamed second\x1e"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn interactive_rebase_builds_a_valid_reword_and_squash_plan() {
|
||||
let repo = init_temp_repo("interactive_rebase");
|
||||
commit_initial_file(&repo.path);
|
||||
let base = git_output_test(&repo.path, ["rev-parse", "HEAD"]);
|
||||
|
||||
fs::write(repo.path.join("first.txt"), "first\n").expect("first file should be written");
|
||||
run_git_test(&repo.path, ["add", "first.txt"]);
|
||||
run_git_test(&repo.path, ["commit", "-q", "-m", "first commit"]);
|
||||
fs::write(repo.path.join("second.txt"), "second\n").expect("second file should be written");
|
||||
run_git_test(&repo.path, ["add", "second.txt"]);
|
||||
run_git_test(&repo.path, ["commit", "-q", "-m", "second commit"]);
|
||||
|
||||
let commits = interactive_rebase_commits_for_repo(&repo.path, &base)
|
||||
.expect("rebase commits should load");
|
||||
assert_eq!(commits.len(), 2);
|
||||
let plan = vec![
|
||||
RebasePlanItem {
|
||||
hash: commits[0].hash.clone(),
|
||||
action: RebaseAction::Reword,
|
||||
message: Some("combined feature".to_string()),
|
||||
},
|
||||
RebasePlanItem {
|
||||
hash: commits[1].hash.clone(),
|
||||
action: RebaseAction::Squash,
|
||||
message: None,
|
||||
},
|
||||
];
|
||||
|
||||
validate_rebase_plan(&commits, &plan).expect("plan should be valid");
|
||||
let todo = build_rebase_todo(&commits, &plan).expect("todo should build");
|
||||
|
||||
assert!(todo.contains(&format!("reword {} first commit", commits[0].hash)));
|
||||
assert!(todo.contains(&format!("squash {} second commit", commits[1].hash)));
|
||||
assert_eq!(
|
||||
build_reword_queue(&commits, &plan).expect("queue should build"),
|
||||
"first commit\x1fcombined feature\x1e"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn interactive_rebase_accepts_a_diverged_base_branch() {
|
||||
let repo = init_temp_repo("interactive_rebase_diverged");
|
||||
commit_initial_file(&repo.path);
|
||||
let main_branch = git_output_test(&repo.path, ["branch", "--show-current"]);
|
||||
run_git_test(&repo.path, ["checkout", "-q", "-b", "feature"]);
|
||||
fs::write(repo.path.join("feature.txt"), "feature\n")
|
||||
.expect("feature file should be written");
|
||||
run_git_test(&repo.path, ["add", "feature.txt"]);
|
||||
run_git_test(&repo.path, ["commit", "-q", "-m", "feature commit"]);
|
||||
run_git_test(&repo.path, ["checkout", "-q", main_branch.as_str()]);
|
||||
fs::write(repo.path.join("main.txt"), "main\n").expect("main file should be written");
|
||||
run_git_test(&repo.path, ["add", "main.txt"]);
|
||||
run_git_test(&repo.path, ["commit", "-q", "-m", "main advanced"]);
|
||||
run_git_test(&repo.path, ["checkout", "-q", "feature"]);
|
||||
|
||||
let commits = interactive_rebase_commits_for_repo(&repo.path, &main_branch)
|
||||
.expect("diverged base should be accepted");
|
||||
|
||||
assert_eq!(commits.len(), 1);
|
||||
assert_eq!(commits[0].summary, "feature commit");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reflog_restore_creates_a_recovery_branch_without_resetting_existing_branch() {
|
||||
let repo = init_temp_repo("reflog_restore");
|
||||
commit_initial_file(&repo.path);
|
||||
let initial = git_output_test(&repo.path, ["rev-parse", "HEAD"]);
|
||||
let original_branch = git_output_test(&repo.path, ["branch", "--show-current"]);
|
||||
|
||||
fs::write(repo.path.join("later.txt"), "later\n").expect("later file should be written");
|
||||
run_git_test(&repo.path, ["add", "later.txt"]);
|
||||
run_git_test(&repo.path, ["commit", "-q", "-m", "later"]);
|
||||
|
||||
let entries = list_reflog(repo.path.to_string_lossy().to_string(), Some(20))
|
||||
.expect("reflog should load");
|
||||
assert!(entries.len() >= 2);
|
||||
|
||||
let status = restore_reflog_entry(
|
||||
repo.path.to_string_lossy().to_string(),
|
||||
initial.clone(),
|
||||
"recovery/initial".to_string(),
|
||||
)
|
||||
.expect("recovery branch should be created");
|
||||
|
||||
assert_eq!(status.current_branch.as_deref(), Some("recovery/initial"));
|
||||
assert_eq!(git_output_test(&repo.path, ["rev-parse", "HEAD"]), initial);
|
||||
assert!(
|
||||
ref_exists(&repo.path, &format!("refs/heads/{original_branch}"))
|
||||
.expect("original branch should still exist")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parses_commit_history_records() {
|
||||
let raw = b"1111111111111111111111111111111111111111\x1f1111111\x1fAda Lovelace\x1fada@example.com\x1f2026-06-26T12:34:56+02:00\x1fHEAD -> main, tag: v1\x1f2222222222222222222222222222222222222222 3333333333333333333333333333333333333333\x1fAdd history panel\x1e";
|
||||
|
||||
+23
-8
@@ -12,14 +12,16 @@ use git::{
|
||||
compare_file_to_parent, create_branch, create_tag, cred_delete, cred_load, cred_save,
|
||||
delete_branch, delete_tag, diff_file_against_working_tree, fetch, get_file_blame,
|
||||
get_file_patch, get_remote_url, get_status, last_commit_message, list_branches, list_commits,
|
||||
list_file_history, list_repository_files, list_stashes, list_tags, merge_branch,
|
||||
open_repo_in_explorer, open_repository, open_repository_bundle, open_repository_file, pull,
|
||||
push, push_tag, read_conflict, rebase_abort, rebase_branch, rebase_continue, rename_branch,
|
||||
resolve_conflict, resolve_conflict_side, restore_file_from_commit, restore_files,
|
||||
restore_to_commit, search_code_introductions, stage_files, stash_apply, stash_drop, stash_pop,
|
||||
stash_push, undo_last_commit, unstage_files,
|
||||
list_file_history, list_interactive_rebase_commits, list_reflog, list_repository_files,
|
||||
list_stashes, list_tags, merge_branch, open_repo_in_explorer, open_repository,
|
||||
open_repository_bundle, open_repository_file, pull, push, push_tag, read_conflict,
|
||||
rebase_abort, rebase_branch, rebase_continue, rename_branch, resolve_conflict,
|
||||
resolve_conflict_side, restore_file_from_commit, restore_files, restore_reflog_entry,
|
||||
restore_to_commit, run_sequence_editor_if_requested, search_code_introductions, stage_files,
|
||||
start_interactive_rebase, stash_apply, stash_drop, stash_pop, stash_push, undo_last_commit,
|
||||
unstage_files,
|
||||
};
|
||||
use tauri::{Manager, AppHandle};
|
||||
use tauri::Manager;
|
||||
|
||||
#[tauri::command]
|
||||
fn close_splashscreen(app: tauri::AppHandle) -> Result<(), String> {
|
||||
@@ -42,10 +44,19 @@ fn close_splashscreen(app: tauri::AppHandle) -> Result<(), String> {
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
if let Some(result) = run_sequence_editor_if_requested() {
|
||||
if let Err(error) = result {
|
||||
eprintln!("{error}");
|
||||
std::process::exit(1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
tauri::Builder::default()
|
||||
.plugin(tauri_plugin_single_instance::init(|app, _, _| {
|
||||
#[cfg(desktop)]
|
||||
let _ = app.get_webview_window("main")
|
||||
let _ = app
|
||||
.get_webview_window("main")
|
||||
.expect("no main window")
|
||||
.set_focus();
|
||||
}))
|
||||
@@ -107,6 +118,10 @@ async fn main() {
|
||||
rebase_branch,
|
||||
rebase_continue,
|
||||
rebase_abort,
|
||||
list_interactive_rebase_commits,
|
||||
start_interactive_rebase,
|
||||
list_reflog,
|
||||
restore_reflog_entry,
|
||||
list_repository_files,
|
||||
open_repository_bundle,
|
||||
list_file_history,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://schema.tauri.app/config/2",
|
||||
"productName": "Gitty",
|
||||
"version": "2026.7.16",
|
||||
"version": "0.200.10",
|
||||
"identifier": "com.gitty",
|
||||
"build": {
|
||||
"beforeDevCommand": "npm run dev",
|
||||
|
||||
+279
-24
@@ -22,9 +22,11 @@
|
||||
import FileHistoryPanel from "./lib/components/FileHistoryPanel.svelte";
|
||||
import GlobalSearchDialog from "./lib/components/GlobalSearchDialog.svelte";
|
||||
import HistoryPanel from "./lib/components/HistoryPanel.svelte";
|
||||
import InteractiveRebaseDialog from "./lib/components/InteractiveRebaseDialog.svelte";
|
||||
import LinePatchDialog from "./lib/components/LinePatchDialog.svelte";
|
||||
import NewBranchDialog from "./lib/components/NewBranchDialog.svelte";
|
||||
import RenameBranchDialog from "./lib/components/RenameBranchDialog.svelte";
|
||||
import ReflogDialog from "./lib/components/ReflogDialog.svelte";
|
||||
import RepoLoadingOverlay from "./lib/components/RepoLoadingOverlay.svelte";
|
||||
import ResolveDialog from "./lib/components/ResolveDialog.svelte";
|
||||
import StashPanel from "./lib/components/StashPanel.svelte";
|
||||
@@ -62,6 +64,8 @@
|
||||
listTags,
|
||||
listCommits,
|
||||
listFileHistory,
|
||||
listInteractiveRebaseCommits,
|
||||
listReflog,
|
||||
listRepositoryFiles,
|
||||
mergeBranch,
|
||||
openRepoInExplorer,
|
||||
@@ -83,9 +87,11 @@
|
||||
resolveConflict,
|
||||
resolveConflictSide,
|
||||
restoreFileFromCommit,
|
||||
restoreReflogEntry,
|
||||
restoreFiles,
|
||||
restoreToCommit,
|
||||
searchCodeIntroductions,
|
||||
startInteractiveRebase,
|
||||
setSyncBadge,
|
||||
stageFiles,
|
||||
stashApply,
|
||||
@@ -98,6 +104,7 @@
|
||||
|
||||
import type {
|
||||
AiSettings,
|
||||
AppTheme,
|
||||
AnalyticsSettings,
|
||||
CommitAiPhase,
|
||||
ConflictFile,
|
||||
@@ -118,6 +125,9 @@
|
||||
LocalModelOption,
|
||||
PatchApplyAction,
|
||||
PreparedResolution,
|
||||
RebaseCommit,
|
||||
RebasePlanItem,
|
||||
ReflogEntry,
|
||||
StoredCredential,
|
||||
} from "./lib/types";
|
||||
|
||||
@@ -133,7 +143,8 @@
|
||||
type AppView = "management" | "repository";
|
||||
type CredentialAction = "push" | "pull" | "fetch" | "clone";
|
||||
type PendingDiscard =
|
||||
| { kind: "file"; file: GitFileStatus; staged: boolean }
|
||||
| { kind: "file"; files: GitFileStatus[]; staged: boolean }
|
||||
| { kind: "all-changes"; files: GitFileStatus[] }
|
||||
| { kind: "hunk"; file: GitFileStatus; staged: boolean; action: PatchApplyAction; patch: string };
|
||||
|
||||
interface RepoTab {
|
||||
@@ -164,6 +175,7 @@
|
||||
const REPO_STATUS_CACHE_KEY = "gitlite.repoStatusCache.v1";
|
||||
const AI_SETTINGS_KEY = "gitlite.aiSettings.v1";
|
||||
const ANALYTICS_SETTINGS_KEY = "gitlite.analyticsSettings.v1";
|
||||
const APP_THEME_KEY = "gitlite.theme.v1";
|
||||
const COMMIT_PANEL_HEIGHT_KEY = "gitlite.commitPanelHeight.v1";
|
||||
const LEFT_SIDEBAR_WIDTH_KEY = "gitlite.leftSidebarWidth.v1";
|
||||
const LEFT_BRANCH_PANEL_HEIGHT_KEY = "gitlite.leftBranchPanelHeight.v1";
|
||||
@@ -238,6 +250,7 @@
|
||||
let appSettingsOpen = false;
|
||||
let analyticsNoticeOpen = false;
|
||||
let analyticsSettings: AnalyticsSettings = defaultAnalyticsSettings();
|
||||
let appTheme: AppTheme = loadThemePreference();
|
||||
let localModelOptions: LocalModelOption[] = [];
|
||||
let errorMessage = "";
|
||||
let operation = "";
|
||||
@@ -250,6 +263,15 @@
|
||||
let deleteBranchForce = false;
|
||||
let compareSelectOpen = false;
|
||||
let compareDialogOpen = false;
|
||||
let interactiveRebaseOpen = false;
|
||||
let interactiveRebaseBase = "";
|
||||
let interactiveRebaseCommits: RebaseCommit[] = [];
|
||||
let interactiveRebaseLoading = false;
|
||||
let interactiveRebaseError = "";
|
||||
let reflogOpen = false;
|
||||
let reflogEntries: ReflogEntry[] = [];
|
||||
let reflogLoading = false;
|
||||
let reflogError = "";
|
||||
let selectedDiffPath = "";
|
||||
let diffHighlightQuery = "";
|
||||
let pendingRestoreFile: { commit: GitCommit; file: GitCommitFile } | null = null;
|
||||
@@ -336,6 +358,7 @@
|
||||
let fileHistoryResizeStartX = 0;
|
||||
let fileHistoryResizeStartWidth = 0;
|
||||
let fileHistoryCollapsed = true;
|
||||
let themeMediaQuery: MediaQueryList | undefined;
|
||||
|
||||
// ── Derived ────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -388,13 +411,18 @@
|
||||
$: leftSidebarRows = buildLeftSidebarRows(branchPanelCollapsed, stashPanelCollapsed, explorerPanelCollapsed);
|
||||
$: allLeftPanelsCollapsed = branchPanelCollapsed && stashPanelCollapsed && explorerPanelCollapsed;
|
||||
|
||||
$: applyThemePreference(appTheme);
|
||||
|
||||
// ── Lifecycle ──────────────────────────────────────────────────────────────
|
||||
|
||||
onMount(() => {
|
||||
themeMediaQuery = window.matchMedia("(prefers-color-scheme: light)");
|
||||
themeMediaQuery.addEventListener("change", handleSystemThemeChange);
|
||||
void runStartupSequence();
|
||||
});
|
||||
|
||||
onDestroy(() => {
|
||||
themeMediaQuery?.removeEventListener("change", handleSystemThemeChange);
|
||||
if (autoRefreshTimer) clearInterval(autoRefreshTimer);
|
||||
if (backgroundRepoStatusTimer) clearInterval(backgroundRepoStatusTimer);
|
||||
if (backgroundFetchTimer) clearInterval(backgroundFetchTimer);
|
||||
@@ -411,7 +439,21 @@
|
||||
}
|
||||
|
||||
function waitForAnimationFrame(): Promise<void> {
|
||||
return new Promise((resolve) => requestAnimationFrame(() => resolve()));
|
||||
// requestAnimationFrame never fires for an unmapped/invisible window on
|
||||
// WebKitGTK (Linux) — the compositor frame clock only runs for realized
|
||||
// windows. The main window starts hidden until the splashscreen closes,
|
||||
// so without a timeout fallback this promise (and the whole startup
|
||||
// sequence, including closing the splashscreen) would hang forever on Linux.
|
||||
return new Promise((resolve) => {
|
||||
let settled = false;
|
||||
const settle = () => {
|
||||
if (settled) return;
|
||||
settled = true;
|
||||
resolve();
|
||||
};
|
||||
requestAnimationFrame(() => settle());
|
||||
window.setTimeout(settle, 50);
|
||||
});
|
||||
}
|
||||
|
||||
async function waitForStartupPaint() {
|
||||
@@ -630,27 +672,33 @@
|
||||
}
|
||||
|
||||
async function autoRefreshTick() {
|
||||
if (!autoRefreshEnabled || activeView !== "repository" || !activeRepoPath || isBusy || autoRefreshInFlight || resolveDialogOpen || compareDialogOpen || compareSelectOpen || newBranchCommit || globalSearchOpen) return;
|
||||
if (!autoRefreshEnabled || activeView !== "repository" || !activeRepoPath || isBusy || autoRefreshInFlight || resolveDialogOpen || compareDialogOpen || compareSelectOpen || interactiveRebaseOpen || reflogOpen || newBranchCommit || globalSearchOpen) return;
|
||||
const path = activeRepoPath;
|
||||
autoRefreshInFlight = true;
|
||||
try {
|
||||
// Cheap fast path: only fetch status; skip the heavy reload if nothing changed.
|
||||
const nextStatus = await getStatus(activeRepoPath);
|
||||
const nextStatus = await getStatus(path);
|
||||
// The user may have switched repos (or closed this one) while the status
|
||||
// call was in flight — applying a stale result would flash/overwrite the
|
||||
// now-active repo's name and data with this one's.
|
||||
if (!sameRepoPath(path, activeRepoPath)) return;
|
||||
if (statusFingerprint(nextStatus) === lastStatusFingerprint) return;
|
||||
applyStatus(nextStatus);
|
||||
// Something changed — reload branches, commits and files in one bundled call.
|
||||
const bundle = await openRepositoryBundle(activeRepoPath, 100);
|
||||
const bundle = await openRepositoryBundle(path, 100);
|
||||
if (!sameRepoPath(path, activeRepoPath)) return;
|
||||
const previousHeadHash = lastFileHistoryHeadHash;
|
||||
await refreshBranchList(activeRepoPath, bundle.branches);
|
||||
await refreshTags(activeRepoPath, bundle.tags);
|
||||
await refreshStashes(activeRepoPath, bundle.stashes);
|
||||
await refreshCommitHistory(activeRepoPath, bundle.commits);
|
||||
await refreshExplorerFiles(activeRepoPath, bundle.files);
|
||||
await refreshBranchList(path, bundle.branches);
|
||||
await refreshTags(path, bundle.tags);
|
||||
await refreshStashes(path, bundle.stashes);
|
||||
await refreshCommitHistory(path, bundle.commits);
|
||||
await refreshExplorerFiles(path, bundle.files);
|
||||
// File history reflects `git log`, which only changes when HEAD actually moves
|
||||
// (new commit, checkout, merge, ...) — skip the reload otherwise so a plain
|
||||
// working-tree/status change (staging, edits) doesn't keep re-fetching and
|
||||
// flickering the currently viewed file's history.
|
||||
if (lastFileHistoryHeadHash !== previousHeadHash) {
|
||||
await refreshFileHistory(activeRepoPath);
|
||||
if (lastFileHistoryHeadHash !== previousHeadHash && sameRepoPath(path, activeRepoPath)) {
|
||||
await refreshFileHistory(path);
|
||||
}
|
||||
} catch { /* ignore transient errors */ } finally {
|
||||
autoRefreshInFlight = false;
|
||||
@@ -747,11 +795,46 @@
|
||||
trackEvent("app_started", { first_run: 1 });
|
||||
}
|
||||
|
||||
function saveAppSettings(next: AnalyticsSettings) {
|
||||
function loadThemePreference(): AppTheme {
|
||||
try {
|
||||
const stored = localStorage.getItem(APP_THEME_KEY);
|
||||
if (stored === "system" || stored === "light" || stored === "dark") return stored;
|
||||
} catch {
|
||||
// Local storage is optional; system theme is a sane default.
|
||||
}
|
||||
return "system";
|
||||
}
|
||||
|
||||
function persistThemePreference(next: AppTheme) {
|
||||
try {
|
||||
localStorage.setItem(APP_THEME_KEY, next);
|
||||
} catch {
|
||||
// Ignore storage quota/private-mode errors.
|
||||
}
|
||||
}
|
||||
|
||||
function applyThemePreference(next: AppTheme) {
|
||||
const prefersLight = themeMediaQuery?.matches ?? window.matchMedia("(prefers-color-scheme: light)").matches;
|
||||
const resolved = next === "system"
|
||||
? prefersLight
|
||||
? "light"
|
||||
: "dark"
|
||||
: next;
|
||||
document.documentElement.dataset.themePreference = next;
|
||||
document.documentElement.dataset.theme = resolved;
|
||||
}
|
||||
|
||||
function handleSystemThemeChange() {
|
||||
if (appTheme === "system") applyThemePreference(appTheme);
|
||||
}
|
||||
|
||||
function saveAppSettings(next: AnalyticsSettings, nextTheme: AppTheme) {
|
||||
analyticsSettings = next;
|
||||
appTheme = nextTheme;
|
||||
persistAnalyticsSettings(next);
|
||||
persistThemePreference(nextTheme);
|
||||
appSettingsOpen = false;
|
||||
if (next.enabled) trackEvent("settings_saved", { analytics_enabled: 1 });
|
||||
if (next.enabled) trackEvent("settings_saved", { analytics_enabled: 1, theme: nextTheme });
|
||||
}
|
||||
|
||||
function updateCommitMessage(message: string) {
|
||||
@@ -1515,6 +1598,13 @@
|
||||
comparison = null;
|
||||
compareSelectOpen = false;
|
||||
compareDialogOpen = false;
|
||||
interactiveRebaseOpen = false;
|
||||
interactiveRebaseBase = "";
|
||||
interactiveRebaseCommits = [];
|
||||
interactiveRebaseError = "";
|
||||
reflogOpen = false;
|
||||
reflogEntries = [];
|
||||
reflogError = "";
|
||||
selectedDiffPath = "";
|
||||
pendingRestoreFile = null;
|
||||
newBranchCommit = null;
|
||||
@@ -2185,6 +2275,99 @@
|
||||
});
|
||||
}
|
||||
|
||||
function preferredInteractiveRebaseBase(): string {
|
||||
const candidates = [status?.upstream, "origin/main", "main", "origin/master", "master"]
|
||||
.filter((value): value is string => Boolean(value) && value !== status?.current_branch);
|
||||
for (const candidate of candidates) {
|
||||
if (branches.some((branch) => branch.name === candidate)) return candidate;
|
||||
}
|
||||
return branches.find((branch) => !branch.current)?.name ?? "";
|
||||
}
|
||||
|
||||
async function loadInteractiveRebaseRange(base: string) {
|
||||
interactiveRebaseBase = base;
|
||||
interactiveRebaseCommits = [];
|
||||
interactiveRebaseError = "";
|
||||
if (!activeRepoPath || !base) return;
|
||||
interactiveRebaseLoading = true;
|
||||
try {
|
||||
const result = await listInteractiveRebaseCommits(activeRepoPath, base);
|
||||
if (interactiveRebaseBase === base) interactiveRebaseCommits = result;
|
||||
} catch (error) {
|
||||
if (interactiveRebaseBase === base) interactiveRebaseError = errorToMessage(error);
|
||||
} finally {
|
||||
if (interactiveRebaseBase === base) interactiveRebaseLoading = false;
|
||||
}
|
||||
}
|
||||
|
||||
function openInteractiveRebase() {
|
||||
if (!hasRepository || rebaseInProgress || cherryPickInProgress || isBusy) return;
|
||||
interactiveRebaseOpen = true;
|
||||
const base = preferredInteractiveRebaseBase();
|
||||
void loadInteractiveRebaseRange(base);
|
||||
trackEvent("interactive_rebase_opened");
|
||||
}
|
||||
|
||||
async function runInteractiveRebase(plan: RebasePlanItem[]) {
|
||||
if (!activeRepoPath || !interactiveRebaseBase || isBusy) return;
|
||||
interactiveRebaseError = "";
|
||||
await runOperation("Starting interactive rebase", async () => {
|
||||
applyStatus(await startInteractiveRebase(activeRepoPath, interactiveRebaseBase, plan));
|
||||
interactiveRebaseOpen = false;
|
||||
await refreshBranchList(activeRepoPath);
|
||||
await refreshCommitHistory(activeRepoPath);
|
||||
await refreshExplorerFiles(activeRepoPath);
|
||||
await refreshFileHistory(activeRepoPath);
|
||||
trackEvent("interactive_rebase_started", { commits: plan.length });
|
||||
});
|
||||
if (interactiveRebaseOpen && errorMessage) interactiveRebaseError = errorMessage;
|
||||
}
|
||||
|
||||
async function openReflog() {
|
||||
if (!hasRepository || isBusy) return;
|
||||
reflogOpen = true;
|
||||
reflogEntries = [];
|
||||
reflogError = "";
|
||||
reflogLoading = true;
|
||||
try {
|
||||
reflogEntries = await listReflog(activeRepoPath, 300);
|
||||
trackEvent("reflog_opened", { entries: reflogEntries.length });
|
||||
} catch (error) {
|
||||
reflogError = errorToMessage(error);
|
||||
} finally {
|
||||
reflogLoading = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function previewReflogEntry(entry: ReflogEntry) {
|
||||
if (!activeRepoPath || isBusy) return;
|
||||
await runOperation("Previewing reflog entry", async () => {
|
||||
const result = await compareCommits(activeRepoPath, entry.hash, "HEAD");
|
||||
comparison = result;
|
||||
selectedDiffPath = result.files[0]?.path ?? "";
|
||||
diffHighlightQuery = "";
|
||||
pendingRestoreFile = null;
|
||||
reflogOpen = false;
|
||||
compareDialogOpen = true;
|
||||
trackEvent("reflog_previewed", { files: result.files.length });
|
||||
});
|
||||
}
|
||||
|
||||
async function recoverReflogEntry(entry: ReflogEntry, branch: string) {
|
||||
if (!activeRepoPath || !branch.trim() || isBusy) return;
|
||||
reflogError = "";
|
||||
await runOperation("Restoring reflog entry", async () => {
|
||||
applyStatus(await restoreReflogEntry(activeRepoPath, entry.hash, branch.trim()));
|
||||
reflogOpen = false;
|
||||
await refreshBranchList(activeRepoPath);
|
||||
await refreshCommitHistory(activeRepoPath);
|
||||
await refreshExplorerFiles(activeRepoPath);
|
||||
await refreshFileHistory(activeRepoPath);
|
||||
trackEvent("reflog_recovered");
|
||||
});
|
||||
if (reflogOpen && errorMessage) reflogError = errorMessage;
|
||||
}
|
||||
|
||||
async function createNewTag(name: string, message: string) {
|
||||
const trimmed = name.trim();
|
||||
if (!activeRepoPath || !trimmed) return;
|
||||
@@ -2582,26 +2765,59 @@
|
||||
});
|
||||
}
|
||||
|
||||
function discardFile(file: GitFileStatus, staged: boolean) {
|
||||
if (!activeRepoPath || isBusy) return;
|
||||
pendingDiscard = { kind: "file", file, staged };
|
||||
function discardFiles(files: GitFileStatus[], staged: boolean) {
|
||||
if (!activeRepoPath || isBusy || files.length === 0) return;
|
||||
pendingDiscard = { kind: "file", files, staged };
|
||||
trackEvent("discard_confirm_opened", {
|
||||
kind: "file",
|
||||
staged: staged ? 1 : 0,
|
||||
files: files.length,
|
||||
});
|
||||
}
|
||||
|
||||
async function runDiscardFile(file: GitFileStatus, staged: boolean) {
|
||||
await runOperation(`Discarding ${file.path}`, async () => {
|
||||
applyStatus(await restoreFiles(activeRepoPath, [file.path], staged));
|
||||
function discardChanges(files: GitFileStatus[]) {
|
||||
if (!activeRepoPath || isBusy || files.length === 0) return;
|
||||
pendingDiscard = { kind: "all-changes", files };
|
||||
trackEvent("discard_confirm_opened", {
|
||||
kind: "all",
|
||||
files: files.length,
|
||||
});
|
||||
}
|
||||
|
||||
async function runDiscardFiles(files: GitFileStatus[], staged: boolean) {
|
||||
if (files.length === 0) return;
|
||||
const paths = files.map((file) => file.path);
|
||||
await runOperation(files.length === 1 ? `Discarding ${baseName(files[0].path)}` : `Discarding ${files.length} files`, async () => {
|
||||
applyStatus(await restoreFiles(activeRepoPath, paths, staged));
|
||||
await refreshExplorerFiles(activeRepoPath);
|
||||
await refreshFileHistory(activeRepoPath);
|
||||
trackEvent("file_discarded", {
|
||||
files: files.length,
|
||||
staged: staged ? 1 : 0,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Discards both the staged and unstaged changes for each given file (used
|
||||
// by "Discard all" and "Discard selected", which don't distinguish lanes).
|
||||
async function runDiscardAllChanges(files: GitFileStatus[]) {
|
||||
const stagedPaths = files.filter((file) => file.staged !== null).map((file) => file.path);
|
||||
const unstagedPaths = files.filter((file) => file.unstaged !== null).map((file) => file.path);
|
||||
if (stagedPaths.length === 0 && unstagedPaths.length === 0) return;
|
||||
await runOperation(files.length === 1 ? `Discarding ${baseName(files[0].path)}` : `Discarding ${files.length} files`, async () => {
|
||||
let nextStatus: GitStatus | null = null;
|
||||
if (stagedPaths.length > 0) nextStatus = await restoreFiles(activeRepoPath, stagedPaths, true);
|
||||
if (unstagedPaths.length > 0) nextStatus = await restoreFiles(activeRepoPath, unstagedPaths, false);
|
||||
if (nextStatus) applyStatus(nextStatus);
|
||||
await refreshExplorerFiles(activeRepoPath);
|
||||
await refreshFileHistory(activeRepoPath);
|
||||
trackEvent("file_discarded", {
|
||||
files: files.length,
|
||||
staged: 2,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function openLinePatch(file: GitFileStatus, staged: boolean) {
|
||||
if (!activeRepoPath) return;
|
||||
linePatchOpen = true;
|
||||
@@ -2737,7 +2953,9 @@
|
||||
if (!discard || !activeRepoPath || isBusy) return;
|
||||
|
||||
if (discard.kind === "file") {
|
||||
await runDiscardFile(discard.file, discard.staged);
|
||||
await runDiscardFiles(discard.files, discard.staged);
|
||||
} else if (discard.kind === "all-changes") {
|
||||
await runDiscardAllChanges(discard.files);
|
||||
} else {
|
||||
await runLinePatchAction(discard.action, discard.patch, discard.file, discard.staged);
|
||||
}
|
||||
@@ -3237,6 +3455,8 @@
|
||||
else if (event.key === "Escape" && newBranchCommit) newBranchCommit = null;
|
||||
else if (event.key === "Escape" && renameBranchTarget) renameBranchTarget = null;
|
||||
else if (event.key === "Escape" && deleteBranchTarget) closeDeleteBranchDialog();
|
||||
else if (event.key === "Escape" && interactiveRebaseOpen && !isBusy) interactiveRebaseOpen = false;
|
||||
else if (event.key === "Escape" && reflogOpen && !isBusy) reflogOpen = false;
|
||||
else if (event.key === "Escape" && compareSelectOpen) compareSelectOpen = false;
|
||||
else if (event.key === "Escape" && globalSearchOpen) closeGlobalSearchDialog();
|
||||
}
|
||||
@@ -3274,6 +3494,8 @@
|
||||
onRefresh={refreshRepo}
|
||||
onSearch={openGlobalSearchDialog}
|
||||
onCompare={openCompareSelect}
|
||||
onInteractiveRebase={openInteractiveRebase}
|
||||
onReflog={openReflog}
|
||||
onOpenInExplorer={openActiveRepoInExplorer}
|
||||
onToggleAutoRefresh={toggleAutoRefresh}
|
||||
onOpenSettings={() => { appSettingsOpen = true; }}
|
||||
@@ -3744,7 +3966,8 @@
|
||||
onSelectFile={selectFileFromStatus}
|
||||
onStage={stageFile}
|
||||
onUnstage={unstageFile}
|
||||
onDiscard={discardFile}
|
||||
onDiscard={discardFiles}
|
||||
onDiscardMany={discardChanges}
|
||||
onPatch={openLinePatch}
|
||||
onStageAll={stageAllFiles}
|
||||
onUnstageAll={unstageAllFiles}
|
||||
@@ -3889,6 +4112,7 @@
|
||||
{#if appSettingsOpen}
|
||||
<AppSettingsDialog
|
||||
analytics={analyticsSettings}
|
||||
theme={appTheme}
|
||||
onSave={saveAppSettings}
|
||||
onClose={() => { appSettingsOpen = false; }}
|
||||
/>
|
||||
@@ -3921,8 +4145,8 @@
|
||||
|
||||
{#if pendingDiscard}
|
||||
<DiscardConfirmDialog
|
||||
file={pendingDiscard.file}
|
||||
staged={pendingDiscard.staged}
|
||||
files={pendingDiscard.kind === "hunk" ? [pendingDiscard.file] : pendingDiscard.files}
|
||||
staged={pendingDiscard.kind === "all-changes" ? null : pendingDiscard.staged}
|
||||
scope={pendingDiscard.kind === "hunk" ? "hunk" : "file"}
|
||||
{isBusy}
|
||||
onConfirm={confirmDiscard}
|
||||
@@ -3991,6 +4215,37 @@
|
||||
/>
|
||||
{/if}
|
||||
|
||||
<!-- Compare: pick the two commits to diff -->
|
||||
{#if interactiveRebaseOpen}
|
||||
<InteractiveRebaseDialog
|
||||
{branches}
|
||||
currentBranch={status?.current_branch ?? ""}
|
||||
base={interactiveRebaseBase}
|
||||
commits={interactiveRebaseCommits}
|
||||
isLoading={interactiveRebaseLoading}
|
||||
{isBusy}
|
||||
{operation}
|
||||
error={interactiveRebaseError}
|
||||
onBaseChange={loadInteractiveRebaseRange}
|
||||
onStart={runInteractiveRebase}
|
||||
onClose={() => { if (!isBusy) interactiveRebaseOpen = false; }}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
{#if reflogOpen}
|
||||
<ReflogDialog
|
||||
entries={reflogEntries}
|
||||
currentHash={reflogEntries.find((entry) => entry.selector === "HEAD@{0}")?.hash ?? ""}
|
||||
isLoading={reflogLoading}
|
||||
{isBusy}
|
||||
{operation}
|
||||
error={reflogError}
|
||||
onPreview={previewReflogEntry}
|
||||
onRestore={recoverReflogEntry}
|
||||
onClose={() => { if (!isBusy) reflogOpen = false; }}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
<!-- Compare: pick the two commits to diff -->
|
||||
{#if compareSelectOpen}
|
||||
<CompareSelectDialog
|
||||
|
||||
+899
-157
File diff suppressed because it is too large
Load Diff
+59
-7
@@ -2,7 +2,7 @@
|
||||
import { onDestroy, onMount } from "svelte";
|
||||
import { getVersion } from "@tauri-apps/api/app";
|
||||
import { getCurrentWindow } from "@tauri-apps/api/window";
|
||||
import { CloudDownload, Download, FolderOpen, GitBranch, GitCompare, LoaderCircle, Minus, RefreshCw, Search, Settings, Upload, X } from "@lucide/svelte";
|
||||
import { CloudDownload, Download, FolderOpen, GitBranch, GitCompare, History, ListRestart, LoaderCircle, Minus, RefreshCw, Search, Settings, Upload, X } from "@lucide/svelte";
|
||||
import iconUrl from "../../src-tauri/icons/icon.png";
|
||||
|
||||
export let branch: string = "";
|
||||
@@ -20,26 +20,50 @@
|
||||
export let onRefresh: () => void = () => {};
|
||||
export let onSearch: () => void = () => {};
|
||||
export let onCompare: () => void = () => {};
|
||||
export let onInteractiveRebase: () => void = () => {};
|
||||
export let onReflog: () => void = () => {};
|
||||
export let onOpenInExplorer: () => void = () => {};
|
||||
export let onToggleAutoRefresh: () => void = () => {};
|
||||
export let onOpenSettings: () => void = () => {};
|
||||
|
||||
const win = getCurrentWindow();
|
||||
let win: ReturnType<typeof getCurrentWindow> | null = null;
|
||||
let isMaximized = false;
|
||||
let unlisten: (() => void) | undefined;
|
||||
let appVersion = "";
|
||||
|
||||
onMount(async () => {
|
||||
try {
|
||||
win = getCurrentWindow();
|
||||
isMaximized = await win.isMaximized();
|
||||
unlisten = await win.onResized(async () => {
|
||||
isMaximized = await win.isMaximized();
|
||||
isMaximized = await win?.isMaximized() ?? false;
|
||||
});
|
||||
} catch {
|
||||
win = null;
|
||||
}
|
||||
|
||||
try {
|
||||
appVersion = await getVersion();
|
||||
} catch {
|
||||
appVersion = "";
|
||||
}
|
||||
});
|
||||
|
||||
onDestroy(() => {
|
||||
unlisten?.();
|
||||
});
|
||||
|
||||
function minimizeWindow() {
|
||||
void win?.minimize();
|
||||
}
|
||||
|
||||
function toggleMaximizeWindow() {
|
||||
void win?.toggleMaximize();
|
||||
}
|
||||
|
||||
function closeWindow() {
|
||||
void win?.close();
|
||||
}
|
||||
</script>
|
||||
|
||||
<header class="titlebar" data-tauri-drag-region>
|
||||
@@ -57,18 +81,24 @@
|
||||
<!-- Center: repo + branch info -->
|
||||
<div class="titlebar-info" data-tauri-drag-region>
|
||||
{#if hasRepository}
|
||||
<div class="titlebar-context" data-tauri-drag-region>
|
||||
{#if repoName}
|
||||
<span class="tb-repo" data-tauri-drag-region>{repoName}</span>
|
||||
<span class="tb-sep" data-tauri-drag-region aria-hidden="true">/</span>
|
||||
{/if}
|
||||
<GitBranch size={12} aria-hidden="true" />
|
||||
<span class="tb-branch" data-tauri-drag-region>{branch}</span>
|
||||
<span class="tb-branch" data-tauri-drag-region title={branch}>{branch}</span>
|
||||
</div>
|
||||
{#if ahead > 0 || behind > 0}
|
||||
<div class="tb-sync-group" aria-label="Branch synchronization status">
|
||||
{#if ahead > 0}
|
||||
<span class="tb-sync ahead" title="{ahead} commits ahead">↑{ahead}</span>
|
||||
{/if}
|
||||
{#if behind > 0}
|
||||
<span class="tb-sync behind" title="{behind} commits behind">↓{behind}</span>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
{:else}
|
||||
<span class="tb-no-repo" data-tauri-drag-region>No repository open</span>
|
||||
{/if}
|
||||
@@ -110,6 +140,28 @@
|
||||
<span class="tb-action-label">Compare</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
class="tb-action"
|
||||
onclick={onInteractiveRebase}
|
||||
disabled={!hasRepository || isBusy}
|
||||
title="Interactive rebase"
|
||||
aria-label="Interactive rebase"
|
||||
>
|
||||
<ListRestart size={14} aria-hidden="true" />
|
||||
<span class="tb-action-label">Rebase</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
class="tb-action"
|
||||
onclick={onReflog}
|
||||
disabled={!hasRepository || isBusy}
|
||||
title="Reflog"
|
||||
aria-label="Reflog"
|
||||
>
|
||||
<History size={14} aria-hidden="true" />
|
||||
<span class="tb-action-label">Reflog</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
class="tb-action"
|
||||
onclick={onFetch}
|
||||
@@ -200,12 +252,12 @@
|
||||
<div class="titlebar-divider" aria-hidden="true"></div>
|
||||
|
||||
<div class="titlebar-controls">
|
||||
<button class="tb-btn" onclick={() => win.minimize()} title="Minimize" aria-label="Minimize">
|
||||
<button class="tb-btn" onclick={minimizeWindow} title="Minimize" aria-label="Minimize">
|
||||
<Minus size={12} aria-hidden="true" />
|
||||
</button>
|
||||
<button
|
||||
class="tb-btn"
|
||||
onclick={() => win.toggleMaximize()}
|
||||
onclick={toggleMaximizeWindow}
|
||||
title={isMaximized ? "Restore" : "Maximize"}
|
||||
aria-label={isMaximized ? "Restore" : "Maximize"}
|
||||
>
|
||||
@@ -220,7 +272,7 @@
|
||||
</svg>
|
||||
{/if}
|
||||
</button>
|
||||
<button class="tb-btn close" onclick={() => win.close()} title="Close" aria-label="Close">
|
||||
<button class="tb-btn close" onclick={closeWindow} title="Close" aria-label="Close">
|
||||
<X size={12} aria-hidden="true" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -1,19 +1,22 @@
|
||||
<script lang="ts">
|
||||
import { Check, Settings, X } from "@lucide/svelte";
|
||||
import type { AnalyticsSettings } from "../types";
|
||||
import type { AnalyticsSettings, AppTheme } from "../types";
|
||||
|
||||
interface Props {
|
||||
analytics: AnalyticsSettings;
|
||||
onSave: (settings: AnalyticsSettings) => void;
|
||||
theme: AppTheme;
|
||||
onSave: (settings: AnalyticsSettings, theme: AppTheme) => void;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
let { analytics, onSave = () => {}, onClose = () => {} }: Props = $props();
|
||||
let { analytics, theme = "system", onSave = () => {}, onClose = () => {} }: Props = $props();
|
||||
|
||||
let analyticsEnabled = $state(true);
|
||||
let selectedTheme = $state<AppTheme>("system");
|
||||
|
||||
$effect(() => {
|
||||
analyticsEnabled = analytics.enabled;
|
||||
selectedTheme = theme;
|
||||
});
|
||||
|
||||
function save() {
|
||||
@@ -21,7 +24,7 @@
|
||||
...analytics,
|
||||
enabled: analyticsEnabled,
|
||||
noticeSeen: true,
|
||||
});
|
||||
}, selectedTheme);
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -38,6 +41,31 @@
|
||||
</header>
|
||||
|
||||
<form class="app-settings-form" onsubmit={(event) => { event.preventDefault(); save(); }}>
|
||||
<section class="settings-section">
|
||||
<header>
|
||||
<Settings size={16} aria-hidden="true" />
|
||||
<div>
|
||||
<span class="eyebrow">Appearance</span>
|
||||
<h3>Theme</h3>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="settings-segmented" role="radiogroup" aria-label="Theme">
|
||||
<label class:active={selectedTheme === "system"}>
|
||||
<input type="radio" bind:group={selectedTheme} value="system" />
|
||||
<span>System</span>
|
||||
</label>
|
||||
<label class:active={selectedTheme === "light"}>
|
||||
<input type="radio" bind:group={selectedTheme} value="light" />
|
||||
<span>Light</span>
|
||||
</label>
|
||||
<label class:active={selectedTheme === "dark"}>
|
||||
<input type="radio" bind:group={selectedTheme} value="dark" />
|
||||
<span>Dark</span>
|
||||
</label>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="settings-section">
|
||||
<header>
|
||||
<Settings size={16} aria-hidden="true" />
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
import type { GitFileStatus } from "../types";
|
||||
|
||||
interface Props {
|
||||
file: GitFileStatus;
|
||||
staged: boolean;
|
||||
files: GitFileStatus[];
|
||||
staged: boolean | null;
|
||||
scope: "file" | "hunk";
|
||||
isBusy: boolean;
|
||||
onConfirm: () => void | Promise<void>;
|
||||
@@ -12,7 +12,7 @@
|
||||
}
|
||||
|
||||
let {
|
||||
file,
|
||||
files,
|
||||
staged = false,
|
||||
scope = "file",
|
||||
isBusy = false,
|
||||
@@ -20,10 +20,16 @@
|
||||
onClose = () => {},
|
||||
}: Props = $props();
|
||||
|
||||
let targetPath = $derived(file.old_path ? `${file.old_path} -> ${file.path}` : file.path);
|
||||
let title = $derived(scope === "hunk" ? "Discard hunk?" : "Discard file changes?");
|
||||
let scopeLabel = $derived(scope === "hunk" ? "Selected hunk" : "File changes");
|
||||
let sourceLabel = $derived(staged ? "staged changes" : "unstaged changes");
|
||||
function targetPath(file: GitFileStatus): string {
|
||||
return file.old_path ? `${file.old_path} -> ${file.path}` : file.path;
|
||||
}
|
||||
|
||||
let count = $derived(files.length);
|
||||
let title = $derived(
|
||||
scope === "hunk" ? "Discard hunk?" : count > 1 ? `Discard changes in ${count} files?` : "Discard file changes?"
|
||||
);
|
||||
let scopeLabel = $derived(scope === "hunk" ? "selected hunk" : count > 1 ? `${count} files` : "file");
|
||||
let sourceLabel = $derived(staged === null ? "staged and unstaged changes" : staged ? "staged changes" : "unstaged changes");
|
||||
|
||||
</script>
|
||||
|
||||
@@ -46,11 +52,22 @@
|
||||
|
||||
<div class="discard-confirm-copy">
|
||||
<p>
|
||||
This will reset the {sourceLabel} for the {scopeLabel.toLowerCase()} below.
|
||||
This will reset the {sourceLabel} for the {scopeLabel} below.
|
||||
</p>
|
||||
<code class="discard-target" title={targetPath}>{targetPath}</code>
|
||||
{#if count > 1}
|
||||
<ul class="discard-target-list">
|
||||
{#each files.slice(0, 8) as file (`${file.old_path ?? ""}:${file.path}`)}
|
||||
<li><code class="discard-target" title={targetPath(file)}>{targetPath(file)}</code></li>
|
||||
{/each}
|
||||
{#if files.length > 8}
|
||||
<li class="discard-target-more">+{files.length - 8} more</li>
|
||||
{/if}
|
||||
</ul>
|
||||
{:else if count === 1}
|
||||
<code class="discard-target" title={targetPath(files[0])}>{targetPath(files[0])}</code>
|
||||
{/if}
|
||||
<p class="discard-warning-text">
|
||||
This cannot be undone. If the file only exists in your working tree, it can be deleted entirely.
|
||||
This cannot be undone. If a file only exists in your working tree, it can be deleted entirely.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,148 @@
|
||||
<script lang="ts">
|
||||
import { AlertTriangle, ArrowDown, ArrowUp, GitBranch, LoaderCircle, Play, X } from "@lucide/svelte";
|
||||
import type { GitBranch as GitBranchInfo, RebaseAction, RebaseCommit, RebasePlanItem } from "../types";
|
||||
|
||||
interface PlanRow extends RebaseCommit {
|
||||
action: RebaseAction;
|
||||
message: string;
|
||||
}
|
||||
|
||||
interface Props {
|
||||
branches: GitBranchInfo[];
|
||||
currentBranch: string;
|
||||
base: string;
|
||||
commits: RebaseCommit[];
|
||||
isLoading: boolean;
|
||||
isBusy: boolean;
|
||||
operation: string;
|
||||
error: string;
|
||||
onBaseChange: (base: string) => void;
|
||||
onStart: (plan: RebasePlanItem[]) => void;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
let {
|
||||
branches = [], currentBranch = "", base = "", commits = [], isLoading = false,
|
||||
isBusy = false, operation = "", error = "", onBaseChange = () => {},
|
||||
onStart = () => {}, onClose = () => {},
|
||||
}: Props = $props();
|
||||
|
||||
let rows = $state<PlanRow[]>([]);
|
||||
|
||||
$effect(() => {
|
||||
rows = commits.map((commit) => ({ ...commit, action: "pick", message: commit.summary }));
|
||||
});
|
||||
|
||||
let availableBases = $derived(branches.filter((branch) => !branch.current));
|
||||
let keptCount = $derived(rows.filter((row) => row.action !== "drop").length);
|
||||
let invalidSquash = $derived(rows.some((row, index) =>
|
||||
(row.action === "squash" || row.action === "fixup")
|
||||
&& rows.slice(0, index).every((previous) => previous.action === "drop")
|
||||
));
|
||||
let invalidReword = $derived(rows.some((row) => row.action === "reword" && !row.message.trim()));
|
||||
let canStart = $derived(Boolean(base) && rows.length > 0 && keptCount > 0 && !invalidSquash && !invalidReword && !isLoading && !isBusy);
|
||||
|
||||
function updateAction(index: number, action: RebaseAction) {
|
||||
rows = rows.map((row, rowIndex) => rowIndex === index ? { ...row, action } : row);
|
||||
}
|
||||
|
||||
function updateMessage(index: number, message: string) {
|
||||
rows = rows.map((row, rowIndex) => rowIndex === index ? { ...row, message } : row);
|
||||
}
|
||||
|
||||
function move(index: number, direction: -1 | 1) {
|
||||
const target = index + direction;
|
||||
if (target < 0 || target >= rows.length) return;
|
||||
const next = [...rows];
|
||||
[next[index], next[target]] = [next[target], next[index]];
|
||||
rows = next;
|
||||
}
|
||||
|
||||
function start() {
|
||||
if (!canStart) return;
|
||||
onStart(rows.map((row) => ({
|
||||
hash: row.hash,
|
||||
action: row.action,
|
||||
message: row.action === "reword" ? row.message.trim() : null,
|
||||
})));
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="dialog-backdrop app-chrome-backdrop" role="presentation">
|
||||
<div class="dialog interactive-rebase-dialog" role="dialog" aria-modal="true" aria-label="Interactive rebase" tabindex="-1">
|
||||
<header class="dialog-header">
|
||||
<div>
|
||||
<span class="eyebrow">Rewrite local history</span>
|
||||
<h2 class="dialog-title">Interactive rebase</h2>
|
||||
</div>
|
||||
<button class="dialog-close" type="button" onclick={onClose} disabled={isBusy} title="Close"><X size={18} aria-hidden="true" /></button>
|
||||
</header>
|
||||
|
||||
<div class="interactive-rebase-body">
|
||||
<section class="rebase-base-bar">
|
||||
<label>
|
||||
<span>Rebase <strong>{currentBranch || "current branch"}</strong> onto</span>
|
||||
<select value={base} onchange={(event) => onBaseChange((event.target as HTMLSelectElement).value)} disabled={isBusy || isLoading}>
|
||||
<option value="" disabled>Select a base branch</option>
|
||||
{#each availableBases as branch (branch.name)}
|
||||
<option value={branch.name}>{branch.remote ? "Remote · " : "Local · "}{branch.name}</option>
|
||||
{/each}
|
||||
</select>
|
||||
</label>
|
||||
<p>Oldest commit first. Reorder commits, then choose how each one should be replayed.</p>
|
||||
</section>
|
||||
|
||||
{#if error}
|
||||
<div class="rebase-warning error"><AlertTriangle size={16} aria-hidden="true" /><span>{error}</span></div>
|
||||
{/if}
|
||||
|
||||
{#if isLoading}
|
||||
<div class="blank-state"><LoaderCircle class="spin" size={18} aria-hidden="true" /> Loading rebase range…</div>
|
||||
{:else if !base}
|
||||
<div class="blank-state">Select the branch or commit that should become the new base.</div>
|
||||
{:else if rows.length === 0}
|
||||
<div class="blank-state">No linear commits are available above this base.</div>
|
||||
{:else}
|
||||
<div class="rebase-plan" role="list" aria-label="Interactive rebase plan">
|
||||
{#each rows as row, index (row.hash)}
|
||||
<article class:drop={row.action === "drop"} class="rebase-plan-row" role="listitem">
|
||||
<div class="rebase-order-actions">
|
||||
<button type="button" onclick={() => move(index, -1)} disabled={isBusy || index === 0} title="Move up"><ArrowUp size={14} aria-hidden="true" /></button>
|
||||
<button type="button" onclick={() => move(index, 1)} disabled={isBusy || index === rows.length - 1} title="Move down"><ArrowDown size={14} aria-hidden="true" /></button>
|
||||
</div>
|
||||
<select class={`rebase-action ${row.action}`} value={row.action} onchange={(event) => updateAction(index, (event.target as HTMLSelectElement).value as RebaseAction)} disabled={isBusy} aria-label={`Action for ${row.short_hash}`}>
|
||||
<option value="pick">pick</option><option value="reword">reword</option><option value="squash">squash</option><option value="fixup">fixup</option><option value="drop">drop</option>
|
||||
</select>
|
||||
<code>{row.short_hash}</code>
|
||||
<div class="rebase-commit-copy">
|
||||
{#if row.action === "reword"}
|
||||
<input value={row.message} oninput={(event) => updateMessage(index, (event.target as HTMLInputElement).value)} disabled={isBusy} aria-label={`New message for ${row.short_hash}`} maxlength="240" />
|
||||
{:else}
|
||||
<strong>{row.summary}</strong>
|
||||
{/if}
|
||||
<span>{row.author_name} · {new Date(row.date).toLocaleString()}</span>
|
||||
</div>
|
||||
</article>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if invalidSquash}
|
||||
<div class="rebase-warning"><AlertTriangle size={15} aria-hidden="true" /> Squash and fixup need an earlier commit that is not dropped.</div>
|
||||
{:else if invalidReword}
|
||||
<div class="rebase-warning"><AlertTriangle size={15} aria-hidden="true" /> Reword messages cannot be empty.</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<footer class="dialog-footer">
|
||||
<span class="dialog-footer-info">{keptCount} of {rows.length} commits kept</span>
|
||||
<div class="rebase-footer-actions">
|
||||
<button class="btn-secondary" type="button" onclick={onClose} disabled={isBusy}>Cancel</button>
|
||||
<button class="btn-primary" type="button" onclick={start} disabled={!canStart}>
|
||||
{#if operation === "Starting interactive rebase"}<LoaderCircle class="spin" size={16} aria-hidden="true" />{:else}<Play size={16} aria-hidden="true" />{/if}
|
||||
Start rebase
|
||||
</button>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,80 @@
|
||||
<script lang="ts">
|
||||
import { GitBranch, History, LoaderCircle, Search, ShieldCheck, X } from "@lucide/svelte";
|
||||
import type { ReflogEntry } from "../types";
|
||||
|
||||
interface Props {
|
||||
entries: ReflogEntry[];
|
||||
currentHash: string;
|
||||
isLoading: boolean;
|
||||
isBusy: boolean;
|
||||
operation: string;
|
||||
error: string;
|
||||
onPreview: (entry: ReflogEntry) => void;
|
||||
onRestore: (entry: ReflogEntry, branch: string) => void;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
let { entries = [], currentHash = "", isLoading = false, isBusy = false, operation = "", error = "", onPreview = () => {}, onRestore = () => {}, onClose = () => {} }: Props = $props();
|
||||
let query = $state("");
|
||||
let selectedHash = $state("");
|
||||
let recoveryBranch = $state("");
|
||||
let filteredEntries = $derived(entries.filter((entry) => `${entry.selector} ${entry.action} ${entry.short_hash} ${entry.author_name}`.toLowerCase().includes(query.trim().toLowerCase())));
|
||||
let selected = $derived(entries.find((entry) => entry.hash === selectedHash) ?? filteredEntries[0] ?? null);
|
||||
|
||||
$effect(() => {
|
||||
if (!selectedHash && entries.length > 0) select(entries[0]);
|
||||
});
|
||||
|
||||
function select(entry: ReflogEntry) {
|
||||
selectedHash = entry.hash;
|
||||
recoveryBranch = `recovery/${entry.short_hash}`;
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="dialog-backdrop app-chrome-backdrop" role="presentation">
|
||||
<div class="dialog reflog-dialog" role="dialog" aria-modal="true" aria-label="Reflog" tabindex="-1">
|
||||
<header class="dialog-header">
|
||||
<div><span class="eyebrow">Recovery history</span><h2 class="dialog-title">Reflog</h2></div>
|
||||
<button class="dialog-close" type="button" onclick={onClose} disabled={isBusy} title="Close"><X size={18} aria-hidden="true" /></button>
|
||||
</header>
|
||||
<div class="reflog-body">
|
||||
<aside class="reflog-list-pane">
|
||||
<label class="reflog-search"><Search size={15} aria-hidden="true" /><input bind:value={query} placeholder="Search actions, hashes or authors" aria-label="Search reflog" /></label>
|
||||
{#if isLoading}
|
||||
<div class="blank-state"><LoaderCircle class="spin" size={18} aria-hidden="true" /> Loading reflog…</div>
|
||||
{:else if filteredEntries.length === 0}
|
||||
<div class="blank-state">No reflog entries match this search.</div>
|
||||
{:else}
|
||||
<div class="reflog-list" role="listbox" aria-label="Reflog entries">
|
||||
{#each filteredEntries as entry (`${entry.selector}:${entry.hash}`)}
|
||||
<button class:active={selected?.selector === entry.selector} type="button" role="option" aria-selected={selected?.selector === entry.selector} onclick={() => select(entry)}>
|
||||
<span class="reflog-row-top"><code>{entry.selector}</code><span>{new Date(entry.date).toLocaleString()}</span></span>
|
||||
<strong>{entry.action}</strong>
|
||||
<span class="reflog-row-bottom"><code>{entry.short_hash}</code><span>{entry.author_name}</span></span>
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
</aside>
|
||||
|
||||
<section class="reflog-detail">
|
||||
{#if error}<div class="rebase-warning error">{error}</div>{/if}
|
||||
{#if selected}
|
||||
<div class="reflog-detail-head"><History size={20} aria-hidden="true" /><div><span class="eyebrow">{selected.selector}</span><h3>{selected.action}</h3></div></div>
|
||||
<dl><div><dt>Commit</dt><dd><code>{selected.hash}</code></dd></div><div><dt>Author</dt><dd>{selected.author_name}</dd></div><div><dt>Date</dt><dd>{new Date(selected.date).toLocaleString()}</dd></div></dl>
|
||||
<button class="btn-secondary reflog-preview" type="button" onclick={() => onPreview(selected)} disabled={isBusy || selected.hash === currentHash}><History size={15} aria-hidden="true" /> Preview changes to current HEAD</button>
|
||||
<div class="reflog-recovery-card">
|
||||
<div class="reflog-recovery-title"><ShieldCheck size={18} aria-hidden="true" /><div><strong>Safe recovery</strong><span>Create a new branch here. The current branch is not reset or deleted.</span></div></div>
|
||||
<label><span>Recovery branch</span><div><GitBranch size={15} aria-hidden="true" /><input bind:value={recoveryBranch} disabled={isBusy} spellcheck="false" /></div></label>
|
||||
<button class="btn-primary" type="button" onclick={() => onRestore(selected, recoveryBranch.trim())} disabled={isBusy || !recoveryBranch.trim()}>
|
||||
{#if operation === "Restoring reflog entry"}<LoaderCircle class="spin" size={16} aria-hidden="true" />{:else}<ShieldCheck size={16} aria-hidden="true" />{/if}
|
||||
Create and checkout recovery branch
|
||||
</button>
|
||||
</div>
|
||||
{:else}
|
||||
<div class="blank-state">Select a reflog entry to inspect or recover it.</div>
|
||||
{/if}
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -41,9 +41,7 @@
|
||||
display: grid;
|
||||
place-items: center;
|
||||
overflow: hidden;
|
||||
background:
|
||||
radial-gradient(circle at 50% 42%, rgba(137, 92, 255, 0.18), transparent 34%),
|
||||
linear-gradient(135deg, #050712 0%, #080b16 46%, #120b18 100%);
|
||||
background: linear-gradient(135deg, #070a10 0%, #0c111a 48%, #090e16 100%);
|
||||
animation: overlay-in 180ms ease;
|
||||
}
|
||||
|
||||
@@ -52,8 +50,8 @@
|
||||
inset: 0;
|
||||
opacity: 0.28;
|
||||
background-image:
|
||||
linear-gradient(rgba(151, 118, 255, 0.12) 1px, transparent 1px),
|
||||
linear-gradient(90deg, rgba(255, 109, 38, 0.08) 1px, transparent 1px);
|
||||
linear-gradient(rgba(111, 140, 255, 0.09) 1px, transparent 1px),
|
||||
linear-gradient(90deg, rgba(77, 182, 214, 0.07) 1px, transparent 1px);
|
||||
background-size: 42px 42px;
|
||||
mask-image: radial-gradient(circle at center, black 0%, transparent 68%);
|
||||
animation: grid-drift 10s linear infinite;
|
||||
@@ -67,14 +65,14 @@
|
||||
gap: 18px;
|
||||
width: min(420px, calc(100vw - 42px));
|
||||
padding: 30px 34px 28px;
|
||||
border: 1px solid rgba(160, 124, 255, 0.24);
|
||||
border: 1px solid rgba(90, 111, 154, 0.28);
|
||||
border-radius: 16px;
|
||||
background:
|
||||
linear-gradient(180deg, rgba(23, 26, 43, 0.9), rgba(12, 15, 27, 0.92)),
|
||||
linear-gradient(180deg, rgba(23, 29, 43, 0.92), rgba(12, 17, 27, 0.94)),
|
||||
var(--color-surface-raised);
|
||||
box-shadow:
|
||||
0 26px 90px rgba(0, 0, 0, 0.62),
|
||||
inset 0 1px 0 rgba(255, 255, 255, 0.06);
|
||||
0 26px 78px rgba(0, 0, 0, 0.54),
|
||||
inset 0 1px 0 rgba(255, 255, 255, 0.05);
|
||||
}
|
||||
|
||||
.repo-loading-mark {
|
||||
@@ -89,7 +87,7 @@
|
||||
.repo-loading-halo {
|
||||
position: absolute;
|
||||
inset: 10px;
|
||||
border: 1px solid rgba(151, 118, 255, 0.24);
|
||||
border: 1px solid rgba(111, 140, 255, 0.22);
|
||||
border-radius: 34px;
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
@@ -98,7 +96,7 @@
|
||||
}
|
||||
.repo-loading-halo.halo-two {
|
||||
inset: 24px;
|
||||
border-color: rgba(255, 109, 38, 0.26);
|
||||
border-color: rgba(77, 182, 214, 0.24);
|
||||
animation: halo-breathe 2.4s ease-in-out infinite reverse;
|
||||
}
|
||||
|
||||
@@ -116,18 +114,18 @@
|
||||
stroke-linecap: round;
|
||||
stroke-dasharray: 165;
|
||||
stroke-dashoffset: 165;
|
||||
filter: drop-shadow(0 0 8px rgba(151, 118, 255, 0.55));
|
||||
filter: drop-shadow(0 0 8px rgba(77, 182, 214, 0.32));
|
||||
animation: trace-draw 2.6s ease-in-out infinite;
|
||||
}
|
||||
.repo-loading-traces .trace-main {
|
||||
stroke: #9b70ff;
|
||||
stroke: #6f8cff;
|
||||
}
|
||||
.repo-loading-traces .trace-branch {
|
||||
stroke: #ff6d26;
|
||||
stroke: #4db6d6;
|
||||
animation-delay: 0.28s;
|
||||
}
|
||||
.repo-loading-traces .trace-cut {
|
||||
stroke: rgba(255, 255, 255, 0.42);
|
||||
stroke: rgba(177, 186, 208, 0.42);
|
||||
stroke-dasharray: 128;
|
||||
stroke-dashoffset: 128;
|
||||
animation-delay: 0.55s;
|
||||
@@ -141,7 +139,7 @@
|
||||
object-fit: contain;
|
||||
filter:
|
||||
drop-shadow(0 18px 24px rgba(0, 0, 0, 0.55))
|
||||
drop-shadow(0 0 18px rgba(151, 118, 255, 0.28));
|
||||
drop-shadow(0 0 18px rgba(77, 182, 214, 0.2));
|
||||
animation: icon-float 2.4s ease-in-out infinite;
|
||||
}
|
||||
|
||||
@@ -175,18 +173,59 @@
|
||||
height: 4px;
|
||||
overflow: hidden;
|
||||
border-radius: 999px;
|
||||
background: rgba(151, 118, 255, 0.14);
|
||||
background: rgba(111, 140, 255, 0.14);
|
||||
}
|
||||
.repo-loading-bar span {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
width: 46%;
|
||||
border-radius: inherit;
|
||||
background: linear-gradient(90deg, transparent, #9b70ff 40%, #ff6d26 74%, transparent);
|
||||
box-shadow: 0 0 16px rgba(255, 109, 38, 0.32);
|
||||
background: linear-gradient(90deg, transparent, #6f8cff 40%, #4db6d6 74%, transparent);
|
||||
box-shadow: 0 0 16px rgba(77, 182, 214, 0.26);
|
||||
animation: bar-slide 1.35s ease-in-out infinite;
|
||||
}
|
||||
|
||||
:global(:root[data-theme="light"]) .repo-loading {
|
||||
background:
|
||||
radial-gradient(circle at 50% 42%, rgba(49, 95, 214, 0.12), transparent 34%),
|
||||
linear-gradient(135deg, #f7f9fd 0%, #eef3f9 48%, #f8fafc 100%);
|
||||
}
|
||||
|
||||
:global(:root[data-theme="light"]) .repo-loading-grid {
|
||||
opacity: 0.38;
|
||||
background-image:
|
||||
linear-gradient(rgba(49, 95, 214, 0.1) 1px, transparent 1px),
|
||||
linear-gradient(90deg, rgba(15, 143, 181, 0.08) 1px, transparent 1px);
|
||||
}
|
||||
|
||||
:global(:root[data-theme="light"]) .repo-loading-card {
|
||||
border-color: rgba(61, 89, 142, 0.2);
|
||||
background:
|
||||
linear-gradient(180deg, rgba(255,255,255,0.96), rgba(244,247,252,0.94)),
|
||||
var(--color-surface-raised);
|
||||
box-shadow:
|
||||
0 26px 72px rgba(28,44,74,0.18),
|
||||
inset 0 1px 0 rgba(255,255,255,0.9);
|
||||
}
|
||||
|
||||
:global(:root[data-theme="light"]) .repo-loading-traces .trace {
|
||||
filter: drop-shadow(0 0 8px rgba(49,95,214,0.22));
|
||||
}
|
||||
|
||||
:global(:root[data-theme="light"]) .repo-loading-traces .trace-cut {
|
||||
stroke: rgba(49,95,214,0.34);
|
||||
}
|
||||
|
||||
:global(:root[data-theme="light"]) .repo-loading-icon {
|
||||
filter:
|
||||
drop-shadow(0 18px 24px rgba(28,44,74,0.2))
|
||||
drop-shadow(0 0 18px rgba(49,95,214,0.18));
|
||||
}
|
||||
|
||||
:global(:root[data-theme="light"]) .repo-loading-bar {
|
||||
background: rgba(49,95,214,0.12);
|
||||
}
|
||||
|
||||
@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }
|
||||
@keyframes grid-drift { to { transform: translate3d(42px, 42px, 0); } }
|
||||
@keyframes icon-float {
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
onSelectFile: (file: GitFileStatus) => void;
|
||||
onStage: (files: GitFileStatus[]) => void;
|
||||
onUnstage: (files: GitFileStatus[]) => void;
|
||||
onDiscard: (file: GitFileStatus, staged: boolean) => void;
|
||||
onDiscard: (files: GitFileStatus[], staged: boolean) => void;
|
||||
onDiscardMany: (files: GitFileStatus[]) => void;
|
||||
onPatch: (file: GitFileStatus, staged: boolean) => void;
|
||||
onStageAll: () => void;
|
||||
onUnstageAll: () => void;
|
||||
@@ -34,6 +35,7 @@
|
||||
onStage = () => {},
|
||||
onUnstage = () => {},
|
||||
onDiscard = () => {},
|
||||
onDiscardMany = () => {},
|
||||
onPatch = () => {},
|
||||
onStageAll = () => {},
|
||||
onUnstageAll = () => {},
|
||||
@@ -125,6 +127,21 @@
|
||||
onUnstage(targets);
|
||||
}
|
||||
|
||||
// Discard mirrors the stage/unstage target selection: if the clicked row is
|
||||
// part of the current multi-selection, the whole selection (filtered to the
|
||||
// relevant lane) is discarded; otherwise just that one file.
|
||||
function discardStagedFromFile(file: GitFileStatus) {
|
||||
const targets = selectedUnstageTargets(file);
|
||||
if (targets.length === 0) return;
|
||||
onDiscard(targets, true);
|
||||
}
|
||||
|
||||
function discardUnstagedFromFile(file: GitFileStatus) {
|
||||
const targets = selectedStageTargets(file);
|
||||
if (targets.length === 0) return;
|
||||
onDiscard(targets, false);
|
||||
}
|
||||
|
||||
let hasUnstaged = $derived(changedFiles.some((f) => f.unstaged !== null));
|
||||
let hasStaged = $derived(changedFiles.some((f) => f.staged !== null));
|
||||
let selectedCount = $derived(changedFiles.filter((f) => selectedStatusPaths.has(fileKey(f))).length);
|
||||
@@ -173,6 +190,16 @@
|
||||
<Undo2 size={14} aria-hidden="true" />
|
||||
Unstage all
|
||||
</button>
|
||||
<button
|
||||
class="btn-sm danger"
|
||||
type="button"
|
||||
onclick={() => onDiscardMany(changedFiles)}
|
||||
disabled={isBusy || changedFiles.length === 0}
|
||||
title="Discard all changes"
|
||||
>
|
||||
<RotateCcw size={14} aria-hidden="true" />
|
||||
Discard all
|
||||
</button>
|
||||
{#if selectedCount > 1}
|
||||
<span class="status-selection-count">{selectedCount} selected</span>
|
||||
<button
|
||||
@@ -195,6 +222,16 @@
|
||||
<Undo2 size={14} aria-hidden="true" />
|
||||
Unstage selected
|
||||
</button>
|
||||
<button
|
||||
class="btn-sm danger"
|
||||
type="button"
|
||||
onclick={() => onDiscardMany(selectedFiles())}
|
||||
disabled={isBusy || selectedCount === 0}
|
||||
title="Discard changes in selected files"
|
||||
>
|
||||
<RotateCcw size={14} aria-hidden="true" />
|
||||
Discard selected
|
||||
</button>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
@@ -241,9 +278,9 @@
|
||||
<FileDiff size={14} aria-hidden="true" />
|
||||
Details
|
||||
</button>
|
||||
<button class="btn-sm" type="button" onclick={() => onDiscard(file, true)} disabled={isBusy} title="Discard staged changes">
|
||||
<button class="btn-sm" type="button" onclick={() => discardStagedFromFile(file)} disabled={isBusy || unstageTargets.length === 0} title={unstageTargets.length > 1 ? `Discard staged changes in ${unstageTargets.length} selected files` : "Discard staged changes"}>
|
||||
<RotateCcw size={14} aria-hidden="true" />
|
||||
Discard
|
||||
{unstageTargets.length > 1 ? `Discard ${unstageTargets.length}` : "Discard"}
|
||||
</button>
|
||||
{:else}
|
||||
<span class="quiet">No staged change</span>
|
||||
@@ -267,9 +304,9 @@
|
||||
<FileDiff size={14} aria-hidden="true" />
|
||||
Details
|
||||
</button>
|
||||
<button class="btn-sm" type="button" onclick={() => onDiscard(file, false)} disabled={isBusy} title="Discard unstaged changes">
|
||||
<button class="btn-sm" type="button" onclick={() => discardUnstagedFromFile(file)} disabled={isBusy || stageTargets.length === 0} title={stageTargets.length > 1 ? `Discard unstaged changes in ${stageTargets.length} selected files` : "Discard unstaged changes"}>
|
||||
<RotateCcw size={14} aria-hidden="true" />
|
||||
Discard
|
||||
{stageTargets.length > 1 ? `Discard ${stageTargets.length}` : "Discard"}
|
||||
</button>
|
||||
{:else}
|
||||
<span class="quiet">No unstaged change</span>
|
||||
@@ -310,8 +347,8 @@
|
||||
display: grid;
|
||||
place-items: center;
|
||||
background:
|
||||
radial-gradient(circle at 50% 38%, rgba(137, 92, 255, 0.16), transparent 55%),
|
||||
rgba(8, 9, 16, 0.58);
|
||||
radial-gradient(circle at 50% 38%, rgba(111, 140, 255, 0.1), transparent 55%),
|
||||
rgba(7, 10, 16, 0.62);
|
||||
backdrop-filter: blur(4px);
|
||||
animation: status-panel-overlay-in 120ms ease;
|
||||
}
|
||||
@@ -323,13 +360,13 @@
|
||||
gap: 12px;
|
||||
width: min(300px, calc(100% - 32px));
|
||||
padding: 26px 28px 26px;
|
||||
border: 1px solid rgba(160, 124, 255, 0.24);
|
||||
border: 1px solid rgba(90, 111, 154, 0.28);
|
||||
border-radius: 16px;
|
||||
background:
|
||||
linear-gradient(180deg, rgba(23, 26, 43, 0.9), rgba(12, 15, 27, 0.92)),
|
||||
linear-gradient(180deg, rgba(23, 29, 43, 0.92), rgba(12, 17, 27, 0.94)),
|
||||
var(--color-surface-raised);
|
||||
color: var(--color-ink);
|
||||
box-shadow: 0 18px 44px rgba(0, 0, 0, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.06);
|
||||
box-shadow: 0 18px 44px rgba(0, 0, 0, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.05);
|
||||
}
|
||||
|
||||
.status-panel-overlay-mark {
|
||||
@@ -344,7 +381,7 @@
|
||||
.status-panel-overlay-halo {
|
||||
position: absolute;
|
||||
inset: 6px;
|
||||
border: 1px solid rgba(151, 118, 255, 0.24);
|
||||
border: 1px solid rgba(111, 140, 255, 0.22);
|
||||
border-radius: 22px;
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
@@ -353,7 +390,7 @@
|
||||
}
|
||||
.status-panel-overlay-halo.halo-two {
|
||||
inset: 16px;
|
||||
border-color: rgba(255, 109, 38, 0.26);
|
||||
border-color: rgba(77, 182, 214, 0.24);
|
||||
animation: status-panel-overlay-halo-breathe 2.4s ease-in-out infinite reverse;
|
||||
}
|
||||
|
||||
@@ -371,16 +408,16 @@
|
||||
stroke-linecap: round;
|
||||
stroke-dasharray: 165;
|
||||
stroke-dashoffset: 165;
|
||||
filter: drop-shadow(0 0 6px rgba(151, 118, 255, 0.55));
|
||||
filter: drop-shadow(0 0 6px rgba(77, 182, 214, 0.32));
|
||||
animation: status-panel-overlay-trace-draw 2.6s ease-in-out infinite;
|
||||
}
|
||||
.status-panel-overlay-traces .trace-main { stroke: #9b70ff; }
|
||||
.status-panel-overlay-traces .trace-main { stroke: #6f8cff; }
|
||||
.status-panel-overlay-traces .trace-branch {
|
||||
stroke: #ff6d26;
|
||||
stroke: #4db6d6;
|
||||
animation-delay: 0.28s;
|
||||
}
|
||||
.status-panel-overlay-traces .trace-cut {
|
||||
stroke: rgba(255, 255, 255, 0.42);
|
||||
stroke: rgba(177, 186, 208, 0.42);
|
||||
stroke-dasharray: 128;
|
||||
stroke-dashoffset: 128;
|
||||
animation-delay: 0.55s;
|
||||
@@ -394,7 +431,7 @@
|
||||
object-fit: contain;
|
||||
filter:
|
||||
drop-shadow(0 8px 12px rgba(0, 0, 0, 0.5))
|
||||
drop-shadow(0 0 10px rgba(151, 118, 255, 0.28));
|
||||
drop-shadow(0 0 10px rgba(77, 182, 214, 0.2));
|
||||
animation: status-panel-overlay-icon-float 2.4s ease-in-out infinite;
|
||||
}
|
||||
|
||||
@@ -415,15 +452,15 @@
|
||||
height: 4px;
|
||||
overflow: hidden;
|
||||
border-radius: 999px;
|
||||
background: rgba(151, 118, 255, 0.14);
|
||||
background: rgba(111, 140, 255, 0.14);
|
||||
}
|
||||
.status-panel-overlay-bar span {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
width: 46%;
|
||||
border-radius: inherit;
|
||||
background: linear-gradient(90deg, transparent, #9b70ff 40%, #ff6d26 74%, transparent);
|
||||
box-shadow: 0 0 12px rgba(255, 109, 38, 0.32);
|
||||
background: linear-gradient(90deg, transparent, #6f8cff 40%, #4db6d6 74%, transparent);
|
||||
box-shadow: 0 0 12px rgba(77, 182, 214, 0.26);
|
||||
animation: status-panel-overlay-bar-slide 1.35s ease-in-out infinite;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,9 @@ import type {
|
||||
GitCommit,
|
||||
GitCommitComparison,
|
||||
GitRepositoryFile,
|
||||
RebaseCommit,
|
||||
RebasePlanItem,
|
||||
ReflogEntry,
|
||||
GitSearchHit,
|
||||
GitStash,
|
||||
GitStatus,
|
||||
@@ -306,6 +309,26 @@ export function rebaseAbort(path: string): Promise<GitStatus> {
|
||||
return invoke<GitStatus>("rebase_abort", { path });
|
||||
}
|
||||
|
||||
export function listInteractiveRebaseCommits(path: string, base: string): Promise<RebaseCommit[]> {
|
||||
return invoke<RebaseCommit[]>("list_interactive_rebase_commits", { path, base });
|
||||
}
|
||||
|
||||
export function startInteractiveRebase(
|
||||
path: string,
|
||||
base: string,
|
||||
plan: RebasePlanItem[],
|
||||
): Promise<GitStatus> {
|
||||
return invoke<GitStatus>("start_interactive_rebase", { path, base, plan });
|
||||
}
|
||||
|
||||
export function listReflog(path: string, limit = 250): Promise<ReflogEntry[]> {
|
||||
return invoke<ReflogEntry[]>("list_reflog", { path, limit });
|
||||
}
|
||||
|
||||
export function restoreReflogEntry(path: string, commit: string, branch: string): Promise<GitStatus> {
|
||||
return invoke<GitStatus>("restore_reflog_entry", { path, commit, branch });
|
||||
}
|
||||
|
||||
export function listRepositoryFiles(path: string): Promise<GitRepositoryFile[]> {
|
||||
return invoke<GitRepositoryFile[]>("list_repository_files", { path });
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ export type FileStatusKind =
|
||||
export type CommitAiPhase = "idle" | "loading" | "ready" | "error";
|
||||
export type CommitAiProvider = "local" | "openai" | "anthropic" | "custom";
|
||||
export type CommitAiLocalProfile = "fast" | "balanced" | "detailed";
|
||||
export type AppTheme = "system" | "light" | "dark";
|
||||
|
||||
export interface CommitAiStatus {
|
||||
phase: CommitAiPhase;
|
||||
@@ -197,6 +198,31 @@ export interface GitBlameResult {
|
||||
lines: GitBlameLine[];
|
||||
}
|
||||
|
||||
export type RebaseAction = "pick" | "reword" | "squash" | "fixup" | "drop";
|
||||
|
||||
export interface RebaseCommit {
|
||||
hash: string;
|
||||
short_hash: string;
|
||||
summary: string;
|
||||
author_name: string;
|
||||
date: string;
|
||||
}
|
||||
|
||||
export interface RebasePlanItem {
|
||||
hash: string;
|
||||
action: RebaseAction;
|
||||
message: string | null;
|
||||
}
|
||||
|
||||
export interface ReflogEntry {
|
||||
hash: string;
|
||||
short_hash: string;
|
||||
selector: string;
|
||||
action: string;
|
||||
author_name: string;
|
||||
date: string;
|
||||
}
|
||||
|
||||
export interface StoredCredential {
|
||||
username: string;
|
||||
password: string;
|
||||
|
||||
+17
@@ -3,12 +3,29 @@ import { mount } from "svelte";
|
||||
import App from "./App.svelte";
|
||||
import "./app.css";
|
||||
|
||||
const THEME_KEY = "gitlite.theme.v1";
|
||||
const target = document.getElementById("app");
|
||||
|
||||
if (!target) {
|
||||
throw new Error("App target element was not found.");
|
||||
}
|
||||
|
||||
try {
|
||||
const storedTheme = localStorage.getItem(THEME_KEY);
|
||||
const preference = storedTheme === "light" || storedTheme === "dark" || storedTheme === "system"
|
||||
? storedTheme
|
||||
: "system";
|
||||
const resolved = preference === "system" && window.matchMedia("(prefers-color-scheme: light)").matches
|
||||
? "light"
|
||||
: preference === "system"
|
||||
? "dark"
|
||||
: preference;
|
||||
document.documentElement.dataset.themePreference = preference;
|
||||
document.documentElement.dataset.theme = resolved;
|
||||
} catch {
|
||||
// Storage is best-effort; the CSS system theme fallback still applies.
|
||||
}
|
||||
|
||||
const app = mount(App, { target });
|
||||
|
||||
export default app;
|
||||
|
||||
Reference in New Issue
Block a user