Skip to content

Commit 2bdfc69

Browse files
committed
chore: sync pending workspace changes
1 parent 4e66202 commit 2bdfc69

8 files changed

Lines changed: 47 additions & 38 deletions

File tree

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# AGENTS.md
1+
# AGENTS.md test
22

33
This file provides guidance for AI coding agents working with the Anycode codebase.
44

anycode-backend/src/git.rs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ pub enum FileStatus {
1616
Conflict,
1717
}
1818

19-
2019
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
2120
pub struct GitFileStatus {
2221
pub path: String,
@@ -157,10 +156,7 @@ impl GitManager {
157156
.recurse_untracked_dirs(true)
158157
.include_typechange(true);
159158

160-
let head_tree = repo
161-
.head()
162-
.ok()
163-
.and_then(|head| head.peel_to_tree().ok());
159+
let head_tree = repo.head().ok().and_then(|head| head.peel_to_tree().ok());
164160

165161
let diff = repo.diff_tree_to_workdir_with_index(head_tree.as_ref(), Some(&mut opts))?;
166162

@@ -295,7 +291,12 @@ impl GitManager {
295291

296292
let abs_path = repo_root.join(&relative_path).to_string_lossy().to_string();
297293
let next_file = self.status_for_relative_path(&repo, &relative_path).ok()?;
298-
let prev_index = self.status_cache.files.iter().position(|f| f.path == abs_path);
294+
let prev_index = self
295+
.status_cache
296+
.files
297+
.iter()
298+
.position(|f| f.path == abs_path);
299+
299300
let prev_file = prev_index.and_then(|idx| self.status_cache.files.get(idx).cloned());
300301

301302
if prev_file == next_file {
@@ -746,7 +747,11 @@ impl GitManager {
746747
Ok((added, removed))
747748
}
748749

749-
fn status_for_relative_path(&self, repo: &Repository, relative_path: &str) -> Result<Option<GitFileStatus>> {
750+
fn status_for_relative_path(
751+
&self,
752+
repo: &Repository,
753+
relative_path: &str,
754+
) -> Result<Option<GitFileStatus>> {
750755
let repo_root = repo.workdir().unwrap_or(Path::new("."));
751756
let mut opts = StatusOptions::new();
752757
opts.include_untracked(true)
@@ -764,7 +769,9 @@ impl GitManager {
764769
if entry_path != relative_path {
765770
continue;
766771
}
767-
if let Some(file) = Self::status_from_entry(repo_root, entry_path, entry.status(), added, removed) {
772+
if let Some(file) =
773+
Self::status_from_entry(repo_root, entry_path, entry.status(), added, removed)
774+
{
768775
return Ok(Some(file));
769776
}
770777
}

anycode-backend/src/handlers/git_handler.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ pub async fn handle_git_branches(ack: AckSender, state: State<AppState>) {
8888
info!("Received git:branches");
8989
let result = {
9090
let git = state.git_manager.lock().await;
91-
git.list_branches().map(|branches| json!({ "branches": branches }))
91+
git.list_branches()
92+
.map(|branches| json!({ "branches": branches }))
9293
};
9394
send_response(ack, result);
9495
}

anycode-backend/src/handlers/watch_handler.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,10 +264,10 @@ async fn handle_search_update(
264264
return;
265265
}
266266

267-
for (sid, pattern) in searches {
267+
for (_, pattern) in searches {
268268
let cancel = CancellationToken::new();
269269
if let Some(file_result) = search_file_result(path, &pattern, cancel).await {
270-
let _ = socket.to(sid).emit("search:result", &file_result).await;
270+
let _ = socket.emit("search:result", &file_result).await;
271271
}
272272
}
273273
}

anycode/components/Search.tsx

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -475,24 +475,20 @@ const Search = ({ id, focusRequestToken, inputValue, onInputValueChange, onEnter
475475
<span className="search-loading"><span>.</span><span>.</span><span>.</span></span>
476476
</>
477477
)}
478-
{results.length > 0 && (
479-
<>
480-
<button
481-
className="search-button"
482-
onClick={handleExpandAll}
483-
title="Expand all files"
484-
>
485-
<Icons.ChevronDown />
486-
</button>
487-
<button
488-
className="search-button"
489-
onClick={handleCollapseAll}
490-
title="Collapse all files"
491-
>
492-
<Icons.ChevronUp />
493-
</button>
494-
</>
495-
)}
478+
<button
479+
className="search-button"
480+
onClick={handleExpandAll}
481+
title="Expand all files"
482+
>
483+
<Icons.ChevronDown />
484+
</button>
485+
<button
486+
className="search-button"
487+
onClick={handleCollapseAll}
488+
title="Collapse all files"
489+
>
490+
<Icons.ChevronUp />
491+
</button>
496492
</div>
497493
</div>
498494

anycode/components/layout/Layout.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@
189189

190190
.layout .dv-tab.dv-active-tab .dv-default-tab .dv-default-tab-content {
191191
color: #f0f0f0;
192-
text-shadow: 0 0 6px rgba(255, 255, 255, 0.8);
192+
/*text-shadow: 0 0 6px rgba(255, 255, 255, 0.8);*/
193193
}
194194

195195
.layout.dockview-theme-dark .dv-pane-container .dv-pane .dv-pane-header:focus:before,

anycode/components/toolbar/Toolbar.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
}
1010

1111
.tab.active > .tab-filename {
12-
text-shadow: 0 0 6px rgba(255, 255, 255, 0.8)
12+
/*text-shadow: 0 0 6px rgba(255, 255, 255, 0.8)*/
1313
}
1414

1515
.tab.active {

anycode/hooks/useEditors.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ export const useEditors = ({ wsRef, isConnected, diffEnabled, onFileClosed }: Us
141141
const activeEditorPaneIdRef = useRef<string>(DEFAULT_EDITOR_PANE_ID);
142142
const [paneActiveFileIds, setPaneActiveFileIds] = useState<Record<string, string | null>>(() => persistedPaneActiveFileIds);
143143
const paneActiveFileIdsRef = useRef<Record<string, string | null>>(persistedPaneActiveFileIds);
144+
const registeredPaneIdsRef = useRef<Set<string>>(new Set([DEFAULT_EDITOR_PANE_ID]));
144145
const activeFileId = paneActiveFileIds[activeEditorPaneId] ?? null;
145146
const activeFileIdRef = useRef<string | null>(persistedEditorState.activeFileId);
146147

@@ -166,7 +167,7 @@ export const useEditors = ({ wsRef, isConnected, diffEnabled, onFileClosed }: Us
166167

167168
const activeFile = files.find((f) => f.id === activeFileId);
168169
const hasVisibleEditorPane = useCallback(() => (
169-
Object.keys(paneActiveFileIdsRef.current).some((id) => id !== DEFAULT_EDITOR_PANE_ID)
170+
Array.from(registeredPaneIdsRef.current).some((id) => id !== DEFAULT_EDITOR_PANE_ID)
170171
), []);
171172

172173
// Choose the editor pane we should target for an open/select action.
@@ -177,10 +178,12 @@ export const useEditors = ({ wsRef, isConnected, diffEnabled, onFileClosed }: Us
177178
// 4) the only visible editor pane
178179
// 5) the default editor pane as a safe fallback
179180
const resolveTargetPaneId = useCallback((paneId?: string, fileId?: string) => {
180-
const paneEntries = Object.entries(paneActiveFileIdsRef.current);
181+
const registeredPaneIds = registeredPaneIdsRef.current;
182+
const paneEntries = Object.entries(paneActiveFileIdsRef.current)
183+
.filter(([id]) => registeredPaneIds.has(id));
181184
const paneIds = paneEntries.map(([id]) => id);
182185
const visiblePaneIds = paneIds.filter((id) => id !== DEFAULT_EDITOR_PANE_ID);
183-
const isKnownPane = (id: string) => Object.hasOwn(paneActiveFileIdsRef.current, id);
186+
const isKnownPane = (id: string) => registeredPaneIds.has(id);
184187

185188
if (paneId) {
186189
return paneId;
@@ -276,6 +279,7 @@ export const useEditors = ({ wsRef, isConnected, diffEnabled, onFileClosed }: Us
276279
}, [hasVisibleEditorPane, resolveTargetPaneId]);
277280

278281
const registerEditorPane = useCallback((paneId: string) => {
282+
registeredPaneIdsRef.current.add(paneId);
279283
setPaneActiveFileIds((prev) => {
280284
if (Object.hasOwn(prev, paneId)) return prev;
281285
return {
@@ -306,6 +310,7 @@ export const useEditors = ({ wsRef, isConnected, diffEnabled, onFileClosed }: Us
306310
}, [pendingExistingOpenRequest, setActiveFileId]);
307311

308312
const unregisterEditorPane = useCallback((paneId: string) => {
313+
registeredPaneIdsRef.current.delete(paneId);
309314
setReferencesPeekByPane((prev) => {
310315
if (!Object.hasOwn(prev, paneId)) return prev;
311316
const next = { ...prev };
@@ -592,7 +597,6 @@ export const useEditors = ({ wsRef, isConnected, diffEnabled, onFileClosed }: Us
592597

593598
const existingFile = filesRef.current.find((file) => file.id === path);
594599
const targetPaneId = resolveTargetPaneId(paneId, existingFile?.id);
595-
console.log('[openFile]', { path, line, column });
596600

597601
if (existingFile) {
598602
const editor = editorRefs.current.get(existingFile.id);
@@ -903,14 +907,15 @@ export const useEditors = ({ wsRef, isConnected, diffEnabled, onFileClosed }: Us
903907
for (const file of filesRef.current) {
904908
if (!editorStatesRef.current.has(file.id)) {
905909
const content = savedFileContentsRef.current.get(file.id);
906-
if (content === undefined) continue;
910+
if (content === undefined) {
911+
continue;
912+
}
907913

908914
const pendingPosition = pendingPositions.current.get(file.id);
909915
const pendingDiagnostics = diagnosticsRef.current.get(file.id);
910916
const errors = pendingDiagnostics
911917
? pendingDiagnostics.map((d) => ({ line: d.range.start.line, message: d.message }))
912918
: undefined;
913-
914919
const editor = await createEditor(content, file.language, file.id, pendingPosition, errors, file.history);
915920
newEditorStates.set(file.id, editor);
916921
savedFileContentsRef.current.set(file.id, content);

0 commit comments

Comments
 (0)