Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix: switching tabs unsets channel click focus on first click (#71)

gbirmana3266b149725
diff --git a/js/app/packages/app/component/dock/Dock.tsx b/js/app/packages/app/component/dock/Dock.tsx
index d06a413bc4..a4a88ac370 100644
--- a/js/app/packages/app/component/dock/Dock.tsx
+++ b/js/app/packages/app/component/dock/Dock.tsx
@@ -127,22 +127,23 @@ export function Dock() {
</div>
<div class="flex items-stretch border-edge-muted border-t border-r">
- <Show when={isSoupActive()}>
- <IconButton
- icon={IconQuestion}
- theme="clear"
- class="h-full aspect-square"
- tooltip={{
- label: 'Help',
- hotkeyToken: TOKENS.split.showHelpDrawer,
- }}
- onClick={() => {
- const showHelp = activeSoupDrawerCommand();
- if (!showHelp) return;
- runCommand(showHelp);
- }}
- />
- </Show>
+ <IconButton
+ icon={IconQuestion}
+ theme="clear"
+ class="h-full aspect-square"
+ classList={{
+ 'opacity-0 pointer-events-none': !isSoupActive(),
+ }}
+ tooltip={{
+ label: 'Help',
+ hotkeyToken: TOKENS.split.showHelpDrawer,
+ }}
+ onClick={() => {
+ const showHelp = activeSoupDrawerCommand();
+ if (!showHelp) return;
+ runCommand(showHelp);
+ }}
+ />
<Show when={ENABLE_RIGHTHAND_SIDEBAR}>
<IconButton
icon={IconAtom}
diff --git a/js/app/packages/app/component/split-layout/SplitLayout.tsx b/js/app/packages/app/component/split-layout/SplitLayout.tsx
index 447169d764..666581210a 100644
--- a/js/app/packages/app/component/split-layout/SplitLayout.tsx
+++ b/js/app/packages/app/component/split-layout/SplitLayout.tsx
@@ -203,6 +203,7 @@ function createSplitFocusTracker(props: {
// the button in the old split might trigger another focus event and re-active the old split.
let focusTimeout: ReturnType<typeof setTimeout> | undefined;
let activateTimeout: ReturnType<typeof setTimeout> | undefined;
+ let lastProgrammaticActivation = 0;
/** Listens for explicit events from layoutManager that might trigger focus changes */
createEffect(
@@ -226,6 +227,13 @@ function createSplitFocusTracker(props: {
)
);
+ /** Track when splits are programmatically activated */
+ createEffect(
+ on(activeSplitId, () => {
+ lastProgrammaticActivation = Date.now();
+ })
+ );
+
/** Listens for focus changes on the document */
createEffect(
on(activeElement, (element) => {
@@ -240,6 +248,13 @@ function createSplitFocusTracker(props: {
}
activateTimeout = setTimeout(() => {
+ const timeSinceActivation = Date.now() - lastProgrammaticActivation;
+
+ // If a split was just programmatically activated, ignore this focus change
+ if (timeSinceActivation < DEBOUNCE + 50) {
+ return;
+ }
+
activateFocusedSplit(element);
}, DEBOUNCE);
})
diff --git a/js/app/packages/macro-entity/src/components/EntityWithEverything.tsx b/js/app/packages/macro-entity/src/components/EntityWithEverything.tsx
index 1dcef65ca8..a2eaeca95a 100644
--- a/js/app/packages/macro-entity/src/components/EntityWithEverything.tsx
+++ b/js/app/packages/macro-entity/src/components/EntityWithEverything.tsx
@@ -265,6 +265,11 @@ export function EntityWithEverything<
'bg-hover': props.highlighted,
bracket: props.selected,
}}
+ onMouseDown={(e) => {
+ // Prevent focus change on mousedown to avoid split activation flash
+ // The click handler will properly handle navigation
+ e.preventDefault();
+ }}
onMouseOver={(e) => {
if (!didCursorMove(e)) {
return;