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.

chg(soup): remove per entity j/k navigation (#2941)

teo69164116621a
diff --git a/js/app/packages/app/component/EntityNavigationIndicator.tsx b/js/app/packages/app/component/EntityNavigationIndicator.tsx
deleted file mode 100644
index c583b53270..0000000000
--- a/js/app/packages/app/component/EntityNavigationIndicator.tsx
+++ /dev/null
@@ -1,73 +0,0 @@
-import { useSoup } from '@app/component/next-soup/soup-context';
-import { useSplitPanelOrThrow } from '@app/component/split-layout/layoutUtils';
-import { DeprecatedIconButton } from '@core/component/DeprecatedIconButton';
-import { TOKENS } from '@core/hotkey/tokens';
-import { getActiveCommandByToken, runCommand } from '@core/hotkey/utils';
-import CaretDown from '@icon/regular/caret-down.svg';
-import CaretUp from '@icon/regular/caret-up.svg';
-import { Show } from 'solid-js';
-
-export const shouldShowEntityNavigation = (
- soup: ReturnType<typeof useSoup>,
- panel: ReturnType<typeof useSplitPanelOrThrow>
-) => {
- const selectedEntity = () => soup.focus.item();
- return (
- panel.handle.referredFrom() === 'list-view' &&
- soup.data()?.length &&
- selectedEntity() &&
- panel.handle.content().type !== 'component' &&
- panel.handle.content().type !== 'project'
- );
-};
-
-const EntityNavigationIndicator = () => {
- const soup = useSoup();
- const panel = useSplitPanelOrThrow();
- const selectedEntityIndex = () => soup.focus.index();
-
- return (
- <Show when={shouldShowEntityNavigation(soup, panel)}>
- <div class="flex gap-1 items-center font-mono text-xs text-ink/50">
- <div>
- [<span class="text-ink">{selectedEntityIndex() + 1}</span>/
- {soup.data()?.length}]
- </div>
- <div class="flex text-ink">
- <DeprecatedIconButton
- size="sm"
- icon={CaretDown}
- tooltip={{
- label: 'Navigate Down',
- hotkeyToken: TOKENS.entity.step.end,
- }}
- disabled={selectedEntityIndex() >= soup.data()!.length - 1}
- theme="current"
- onDeepClick={() => {
- const command = getActiveCommandByToken(TOKENS.entity.step.end);
- if (!command) return;
- runCommand(command);
- }}
- />
- <DeprecatedIconButton
- size="sm"
- icon={CaretUp}
- tooltip={{
- label: 'Navigate Up',
- hotkeyToken: TOKENS.entity.step.start,
- }}
- disabled={selectedEntityIndex() === 0}
- theme="current"
- onDeepClick={() => {
- const command = getActiveCommandByToken(TOKENS.entity.step.start);
- if (!command) return;
- runCommand(command);
- }}
- />
- </div>
- </div>
- </Show>
- );
-};
-
-export default EntityNavigationIndicator;
diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx
index 532ddfbd13..7384f14e01 100644
--- a/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx
@@ -481,7 +481,10 @@ export const SoupViewList = (props: SoupViewListProps) => {
: (props.scopeId ?? panel.splitHotkeyScope);
});
- // Register navigation hotkeys
+ // Register navigation hotkeys on the active list scope (usually the split
+ // scope), but dispose them with the mounted SoupViewList. This keeps j/k
+ // available while the list split is active without leaking into opened blocks
+ // after the list unmounts.
useSoupNavigationHotkeys({
scopeId: scopeId(),
soup,
diff --git a/js/app/packages/app/component/next-soup/soup-view/use-soup-navigation-hotkeys.ts b/js/app/packages/app/component/next-soup/soup-view/use-soup-navigation-hotkeys.ts
index 61f01ed5fb..4fe6626871 100644
--- a/js/app/packages/app/component/next-soup/soup-view/use-soup-navigation-hotkeys.ts
+++ b/js/app/packages/app/component/next-soup/soup-view/use-soup-navigation-hotkeys.ts
@@ -116,7 +116,6 @@ export const useSoupNavigationHotkeys = (
return true;
};
- // Used outside soup view, does not need to be disposed
registerHotkey({
hotkey: ['j'],
scopeId,
@@ -124,7 +123,7 @@ export const useSoupNavigationHotkeys = (
hotkeyToken: TOKENS.entity.step.end,
keyDownHandler: navigateDown,
hide: true,
- });
+ }).withGroup(group);
registerHotkey({
hotkey: ['arrowdown'],
@@ -134,7 +133,6 @@ export const useSoupNavigationHotkeys = (
hide: true,
}).withGroup(group);
- // Used outside soup view, does not need to be disposed
registerHotkey({
hotkey: ['k'],
scopeId,
@@ -142,7 +140,7 @@ export const useSoupNavigationHotkeys = (
description: 'Up',
keyDownHandler: navigateUp,
hide: true,
- });
+ }).withGroup(group);
registerHotkey({
hotkey: ['arrowup'],
diff --git a/js/app/packages/app/component/split-layout/components/SplitHeader.tsx b/js/app/packages/app/component/split-layout/components/SplitHeader.tsx
index c473a412f4..051a4cf5fb 100644
--- a/js/app/packages/app/component/split-layout/components/SplitHeader.tsx
+++ b/js/app/packages/app/component/split-layout/components/SplitHeader.tsx
@@ -1,6 +1,3 @@
-import EntityNavigationIndicator, {
- shouldShowEntityNavigation,
-} from '@app/component/EntityNavigationIndicator';
import { LabelAndHotKey } from '@core/component/Tooltip';
import {
ENABLE_PREVIEW,
@@ -30,7 +27,6 @@ import { SplitLayoutContext, SplitPanelContext } from '../context';
import { canSpotlight } from '../utils/canSpotlight';
import { cn } from '@ui/utils/classname';
import { isListViewID } from '@app/constants/list-views';
-import { useSoup } from '@app/component/next-soup/soup-context';
function SplitBackButton() {
const context = useContext(SplitPanelContext);
@@ -178,16 +174,13 @@ function _SplitControlButtons() {
}
export function SplitHeader(props: { ref: Setter<HTMLDivElement | null> }) {
- const soup = useSoup();
const panel = useContext(SplitPanelContext);
if (!panel)
throw new Error('<SplitHeader> must be used within a <SplitLayout>');
const layout = useContext(SplitLayoutContext);
const shouldShowRightmost = () =>
- !isTouchDevice() &&
- (shouldShowEntityNavigation(soup, panel) ||
- (layout && canSpotlight(layout.manager)));
+ !isTouchDevice() && layout && canSpotlight(layout.manager);
return (
<div
@@ -228,7 +221,6 @@ export function SplitHeader(props: { ref: Setter<HTMLDivElement | null> }) {
'pl-0.5 pr-2 z-annotation-layer relative flex items-center gap-0.5 h-full order-last'
}
>
- <EntityNavigationIndicator />
<SplitSpotlightButton />
</div>
</Show>