fix: small reworks on git log sidebar

This commit is contained in:
2026-02-21 22:29:06 +01:00
parent 03e813f1a9
commit 2a83df1962
8 changed files with 174 additions and 4 deletions

View File

@@ -390,6 +390,7 @@ export class PreviewServer {
categorySettings,
page_title: pageContext.pageTitle,
language: pageContext.language,
menu_items: pageContext.menuItems,
pico_stylesheet_href: pageContext.picoStylesheetHref,
html_theme_attribute: pageContext.htmlThemeAttribute,
}, this.postEngine);

View File

@@ -3,9 +3,9 @@
{% render 'partials/head', page_title: page_title, pico_stylesheet_href: pico_stylesheet_href %}
<body>
<main>
<h1>{{ post.title }}</h1>
{% render 'partials/menu', menu_items: menu_items, language: language %}
<article class="single-post" data-template="single-post">
<h1>{{ post.title }}</h1>
{% render 'partials/menu', menu_items: menu_items, language: language %}
<div class="post">{{ post.content | markdown: post.id, canonical_post_path_by_slug, canonical_media_path_by_source_path, language }}</div>
</article>
</main>

View File

@@ -42,7 +42,15 @@
min-height: 0;
}
.git-sidebar-section--changes {
flex: 1 1 50%;
}
.git-sidebar-history {
flex: 0 0 50%;
max-height: 50%;
min-height: 0;
overflow: hidden;
margin-top: 12px;
border-top: 1px solid var(--vscode-editorWidget-border);
padding-top: 8px;
@@ -60,6 +68,8 @@
.git-sidebar-file-list {
display: flex;
flex-direction: column;
flex: 1 1 auto;
min-height: 0;
overflow: auto;
}
@@ -110,8 +120,11 @@
.git-sidebar-history-list {
display: flex;
flex-direction: column;
flex: 1 1 auto;
min-height: 0;
gap: 6px;
padding: 0 12px 8px;
overflow: auto;
}
.git-sidebar-history-legend {

View File

@@ -57,6 +57,7 @@ export const GitSidebar: React.FC = () => {
const commitMessageInputRef = useRef<HTMLInputElement | null>(null);
const statusRefreshInFlightRef = useRef(false);
const remoteRefreshInFlightRef = useRef(false);
const loadRepoStateRequestRef = useRef(0);
const refreshRepoDetails = useCallback(
async (targetProjectPath: string, options?: { background?: boolean; historyLimit?: number }) => {
@@ -189,12 +190,19 @@ export const GitSidebar: React.FC = () => {
}, [activeProject]);
const loadRepoState = useCallback(async () => {
const requestId = ++loadRepoStateRequestRef.current;
const isCurrentRequest = () => requestId === loadRepoStateRequestRef.current;
setLoading(true);
setError(null);
setErrorGuidance([]);
try {
const availability = await window.electronAPI.git.checkAvailability();
if (!isCurrentRequest()) {
return;
}
if (!availability.gitFound) {
setError(tr('gitSidebar.error.gitMissing'));
setIsRepo(false);
@@ -203,6 +211,10 @@ export const GitSidebar: React.FC = () => {
}
const resolvedProjectPath = await resolveProjectPath();
if (!isCurrentRequest()) {
return;
}
setProjectPath(resolvedProjectPath);
if (!resolvedProjectPath) {
@@ -213,14 +225,25 @@ export const GitSidebar: React.FC = () => {
}
const repoState = await window.electronAPI.git.getRepoState(resolvedProjectPath);
if (!isCurrentRequest()) {
return;
}
setIsRepo(repoState.isRepo);
setHasRemote(repoState.hasRemote);
setCurrentBranch(repoState.currentBranch || null);
if (repoState.isRepo) {
await refreshRepoDetails(resolvedProjectPath);
if (!isCurrentRequest()) {
return;
}
if (repoState.hasRemote) {
await refreshRemoteState(resolvedProjectPath);
if (!isCurrentRequest()) {
return;
}
} else {
setRemoteState(null);
setRemoteStateError(null);
@@ -233,6 +256,10 @@ export const GitSidebar: React.FC = () => {
setRemoteStateError(null);
}
} catch {
if (!isCurrentRequest()) {
return;
}
setError(tr('gitSidebar.error.loadRepoStatus'));
setIsRepo(false);
setHasRemote(false);
@@ -242,7 +269,9 @@ export const GitSidebar: React.FC = () => {
setRemoteState(null);
setRemoteStateError(null);
} finally {
setLoading(false);
if (isCurrentRequest()) {
setLoading(false);
}
}
}, [refreshRemoteState, refreshRepoDetails, resolveProjectPath, tr]);
@@ -499,7 +528,7 @@ export const GitSidebar: React.FC = () => {
</div>
)}
<div className="git-sidebar-section">
<div className="git-sidebar-section git-sidebar-section--changes">
<div className="sidebar-section-title">{tr('gitSidebar.openChanges', { count: statusFiles.length })}</div>
<div className="git-sidebar-commit-row">