mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-12 01:00:54 +00:00
* feat(terminal): add Directory Picker context chip * fix(terminal): bind directory reads to the exact SSH session * fix(terminal): follow manually changed working directories * fix(terminal): isolate cwd updates and gate local platform support * docs(terminal): research Directory Picker cross-platform follow-up * fix(terminal): confirm OSC 7 navigation and reset picker loading * fix(terminal): preserve active shell OSC 7 during directory refresh * test(terminal): retain cross-session OSC 7 submission guard --------- Co-authored-by: Joseph Hau <hexart@gmail.com>
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import { useCallback } from 'react';
|
|
import { STORAGE_KEY_COMPOSE_BAR_HEIGHT } from '../../infrastructure/config/storageKeys';
|
|
import { useStoredNumber } from './useStoredNumber';
|
|
|
|
export const COMPOSE_BAR_HEIGHT_DEFAULT = 144;
|
|
export const COMPOSE_BAR_HEIGHT_MIN = 104;
|
|
export const COMPOSE_BAR_HEIGHT_MAX = 360;
|
|
|
|
const HEIGHT_CLAMP = { min: COMPOSE_BAR_HEIGHT_MIN, max: COMPOSE_BAR_HEIGHT_MAX };
|
|
|
|
function clampHeight(height: number): number {
|
|
return Math.max(HEIGHT_CLAMP.min, Math.min(HEIGHT_CLAMP.max, height));
|
|
}
|
|
|
|
/** Persisted compose bar height; call `persist` on mouseup after a drag. */
|
|
export function useComposeBarHeight() {
|
|
const [height, setHeight, persist] = useStoredNumber(
|
|
STORAGE_KEY_COMPOSE_BAR_HEIGHT,
|
|
COMPOSE_BAR_HEIGHT_DEFAULT,
|
|
HEIGHT_CLAMP,
|
|
);
|
|
|
|
const setClampedHeight = useCallback(
|
|
(next: number | ((prev: number) => number)) => {
|
|
setHeight((prev) => {
|
|
const raw = typeof next === 'function' ? next(prev) : next;
|
|
return clampHeight(raw);
|
|
});
|
|
},
|
|
[setHeight],
|
|
);
|
|
|
|
return [height, setClampedHeight, persist] as const;
|
|
}
|