Some checks failed
build-packages / resolve bundled mosh-client (push) Has been cancelled
build-packages / resolve bundled et-client (push) Has been cancelled
build-packages / build-macos (push) Has been cancelled
build-packages / build-windows (push) Has been cancelled
build-packages / build-linux-x64 (push) Has been cancelled
build-packages / build-linux-arm64 (push) Has been cancelled
build-packages / release (push) Has been cancelled
build-packages / update Nix release metadata (push) Has been cancelled
build-packages / bump homebrew tap (push) Has been cancelled
test / lint-and-test (push) Has been cancelled
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled
build-et-binaries / build-linux-x64 (push) Has been cancelled
build-et-binaries / build-linux-arm64 (push) Has been cancelled
build-et-binaries / build-macos-universal (push) Has been cancelled
build-et-binaries / build-windows-x64 (push) Has been cancelled
build-et-binaries / release (push) Has been cancelled
57 lines
2.0 KiB
TypeScript
57 lines
2.0 KiB
TypeScript
import type { Snippet } from '../../types';
|
|
|
|
export const COMPOSE_BAR_MIN_HEIGHT = 72;
|
|
export const COMPOSE_BAR_MAX_HEIGHT = 360;
|
|
|
|
export function clampComposeBarHeight(height: number): number {
|
|
return Math.max(COMPOSE_BAR_MIN_HEIGHT, Math.min(COMPOSE_BAR_MAX_HEIGHT, height));
|
|
}
|
|
|
|
export function filterComposeBarSnippets(snippets: Snippet[], query: string): Snippet[] {
|
|
const normalized = query.trim().toLowerCase();
|
|
const filtered = normalized
|
|
? snippets.filter((snippet) => (
|
|
snippet.label.toLowerCase().includes(normalized)
|
|
|| snippet.command.toLowerCase().includes(normalized)
|
|
|| (snippet.package?.toLowerCase().includes(normalized) ?? false)
|
|
))
|
|
: snippets;
|
|
return filtered.slice().sort((a, b) => a.label.localeCompare(b.label));
|
|
}
|
|
|
|
export function buildSnippetIdKey(snippetIds: readonly string[]): string {
|
|
return snippetIds.join('\0');
|
|
}
|
|
|
|
/** Built-in quick commands shown until the user customizes the strip. */
|
|
export const COMPOSE_BAR_BUILTIN_SNIPPETS: Snippet[] = [
|
|
{ id: '__compose_builtin_ls', label: 'ls -la', command: 'ls -la' },
|
|
{ id: '__compose_builtin_df', label: 'df -h', command: 'df -h' },
|
|
{ id: '__compose_builtin_free', label: 'free -h', command: 'free -h' },
|
|
{ id: '__compose_builtin_pwd', label: 'pwd', command: 'pwd' },
|
|
];
|
|
|
|
export const COMPOSE_BAR_BUILTIN_SNIPPET_IDS = COMPOSE_BAR_BUILTIN_SNIPPETS.map((s) => s.id);
|
|
|
|
export const COMPOSE_BAR_DEFAULT_SEED_COUNT = 4;
|
|
|
|
export function resolveComposeBarDefaultSeedIds(snippets: Snippet[]): string[] {
|
|
if (snippets.length > 0) {
|
|
return filterComposeBarSnippets(snippets, '')
|
|
.slice(0, COMPOSE_BAR_DEFAULT_SEED_COUNT)
|
|
.map((snippet) => snippet.id);
|
|
}
|
|
return COMPOSE_BAR_BUILTIN_SNIPPET_IDS.slice(0, COMPOSE_BAR_DEFAULT_SEED_COUNT);
|
|
}
|
|
|
|
export function mergeComposeBarSnippetMap(snippets: Snippet[]): Map<string, Snippet> {
|
|
const map = new Map<string, Snippet>();
|
|
for (const builtin of COMPOSE_BAR_BUILTIN_SNIPPETS) {
|
|
map.set(builtin.id, builtin);
|
|
}
|
|
for (const snippet of snippets) {
|
|
map.set(snippet.id, snippet);
|
|
}
|
|
return map;
|
|
}
|