Skip to content

Commit 0bfe779

Browse files
committed
feat: ignore repeated clicks on active tabs/nodes and fix active highlight sync
1 parent d38ba58 commit 0bfe779

4 files changed

Lines changed: 27 additions & 9 deletions

File tree

anycode/App.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,26 +113,28 @@ const App: React.FC = () => {
113113
}, [editors.flushAllPendingChanges]);
114114

115115
useEffect(() => {
116-
if (!editors.activeFileId) {
117-
return;
118-
}
119-
120116
fileTree.setActiveNode(editors.activeFileId);
121117
}, [editors.activeFileId, fileTree.setActiveNode]);
122118

123119
useEffect(() => {
124120
if (!editors.activeFileId) {
121+
fileTree.clearFileSelection();
125122
return;
126123
}
127124

128125
const node = fileTree.findNodeByPath(fileTree.fileTree, editors.activeFileId);
129-
if (!node || node.isSelected) {
126+
if (!node) {
127+
fileTree.clearFileSelection();
128+
return;
129+
}
130+
131+
if (node.isSelected) {
130132
return;
131133
}
132134

133135
fileTree.selectNode(node.id);
134136
}, [editors.activeFileId, fileTree.fileTree,
135-
fileTree.findNodeByPath, fileTree.selectNode]);
137+
fileTree.findNodeByPath, fileTree.selectNode, fileTree.clearFileSelection]);
136138

137139
useEffect(() => {
138140
saveItem('terminals', terminals.terminals);
@@ -158,6 +160,7 @@ const App: React.FC = () => {
158160
const handleSelectFile = useEvent((fileId: string) => {
159161
const paneId = resolveEditorPaneId();
160162
if (!paneId) return;
163+
if (editors.activeFileId === fileId) return;
161164
editors.setActiveFileId(fileId, paneId);
162165
});
163166

anycode/components/TreeNodeComponent.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ const TreeNodeComponentImpl: React.FC<TreeNodeComponentProps> = ({
5959

6060
const handleNameClick = (e: React.MouseEvent) => {
6161
e.stopPropagation();
62+
if (isActive) return;
6263
onActivate(node.id);
6364

6465
if (node.type === 'file') {
@@ -80,6 +81,7 @@ const TreeNodeComponentImpl: React.FC<TreeNodeComponentProps> = ({
8081
if (e.button !== 0) {
8182
return;
8283
}
84+
if (isActive) return;
8385
onActivate(node.id);
8486
};
8587

anycode/components/agent/AcpMessage.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120
background-color: rgba(127, 127, 127, 0.18);
121121
border: 1px solid var(--theme-border, var(--border-color, #333));
122122
color: inherit;
123+
overflow: scroll;
123124
}
124125

125126
.acp-message-markdown pre {

anycode/components/toolbar/Toolbar.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ export const Toolbar = ({
3636
<div
3737
key={file.id}
3838
className={`tab ${activeFileId === file.id ? 'active' : ''}`}
39-
onClick={() => onSelectFile(file.id)}
39+
onClick={() => {
40+
if (activeFileId !== file.id) {
41+
onSelectFile(file.id);
42+
}
43+
}}
4044
>
4145
<span className="tab-filename" title={file.id}> {file.name} </span>
4246
<button
@@ -54,7 +58,11 @@ export const Toolbar = ({
5458
<div
5559
key={`toolbar-terminal-${terminal.id}`}
5660
className={`tab tab-terminal ${activeTerminalIndex === index ? 'active' : ''}`}
57-
onClick={() => onSelectTerminal(index)}
61+
onClick={() => {
62+
if (activeTerminalIndex !== index) {
63+
onSelectTerminal(index);
64+
}
65+
}}
5866
>
5967
<span className="tab-filename">{`term:${terminal.name}`}</span>
6068
<button
@@ -72,7 +80,11 @@ export const Toolbar = ({
7280
<div
7381
key={`toolbar-agent-${session.agentId}`}
7482
className={`tab tab-agent ${activeAgentId === session.agentId ? 'active' : ''}`}
75-
onClick={() => onSelectAgent(session.agentId)}
83+
onClick={() => {
84+
if (activeAgentId !== session.agentId) {
85+
onSelectAgent(session.agentId);
86+
}
87+
}}
7688
>
7789
<span className="tab-filename">{`${session.agentName || session.agentId}`}</span>
7890
<button

0 commit comments

Comments
 (0)