sh3-core 0.15.3 → 0.15.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,6 +9,7 @@ import type { ConflictsApi } from './conflicts/api';
9
9
  import type { ColorApi } from './color/api';
10
10
  import { type OpenContextMenuOpts, type OpenPaletteOpts } from './actions/listeners';
11
11
  import type { ActiveActionDescriptor } from './actions/types';
12
+ import { type DispatchToTerminalResult } from './shell-shard/dispatch-to-terminal';
12
13
  /**
13
14
  * The process-wide shell singleton exposed to shards and the shell's own
14
15
  * internal code. Provides state zone creation and overlay managers.
@@ -38,6 +39,17 @@ export interface Shell {
38
39
  color: ColorApi;
39
40
  /** Actions facade — rebind keys, query bindings, open menus/palette. */
40
41
  actions: ShellActionsApi;
42
+ /**
43
+ * Dispatch `line` through a Terminal view's normal submit path. Used by
44
+ * views outside a verb context (floating pickers, dialogs) to drive a
45
+ * terminal as if the user had typed the line. Resolves which terminal:
46
+ * focused → sole → fail. Returns synchronously with the routing outcome;
47
+ * the dispatch itself runs fire-and-forget.
48
+ *
49
+ * Mirrors `ShellApi.dispatchToTerminal` (the verb-side surface). Both
50
+ * read the same module-scoped registry of live Terminal.svelte instances.
51
+ */
52
+ dispatchToTerminal(line: string): DispatchToTerminalResult;
41
53
  }
42
54
  /**
43
55
  * API for managing action bindings and triggering menus/palette
@@ -27,6 +27,7 @@ import { openContextMenu as listenersOpenContextMenu, openPalette as listenersOp
27
27
  import { setUserBindings, getLiveDispatcherState, onActiveChange as onActiveChangeState, __notifyActiveChange, } from './actions/state.svelte';
28
28
  import { listActions, onActionsChange } from './actions/registry';
29
29
  import { listActiveFromEntries } from './actions/listActive';
30
+ import { makeDispatchToTerminal } from './shell-shard/dispatch-to-terminal';
30
31
  const shellActions = {
31
32
  async rebind(appId, actionId, shortcut) {
32
33
  await saveUserBinding(appId, actionId, shortcut);
@@ -75,4 +76,5 @@ export const shell = {
75
76
  conflicts: conflictsApi,
76
77
  color: colorApi,
77
78
  actions: shellActions,
79
+ dispatchToTerminal: makeDispatchToTerminal({ headless: false }),
78
80
  };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,46 @@
1
+ /*
2
+ * Targeted coverage for the `shell` runtime singleton's dispatchToTerminal.
3
+ *
4
+ * The wiring is what matters: the singleton must consult the same module-
5
+ * scoped terminal-registry as ShellApi.dispatchToTerminal so a Svelte view
6
+ * (which imports `shell`) and a verb (which receives `vctx.shell`) hit the
7
+ * same set of live Terminal handles. A view import is the only path a
8
+ * picker has — without this, the dispatchToTerminal API is unreachable
9
+ * from the place it was designed to be called.
10
+ */
11
+ import { describe, it, expect, beforeEach, vi } from 'vitest';
12
+ import { shell } from './shellRuntime.svelte';
13
+ import { registerTerminalView, __resetTerminalRegistryForTest, } from './shell-shard/terminal-registry';
14
+ function makeHandle(id, focusStamp = 0, dispatch = vi.fn(async () => undefined)) {
15
+ return {
16
+ id,
17
+ dispatch,
18
+ getFocusStamp: () => focusStamp,
19
+ getMode: () => ({ id: 'sh3', label: 'sh3', transport: 'none', autoRelocate: false, showCwd: true }),
20
+ };
21
+ }
22
+ describe('shell runtime singleton — dispatchToTerminal', () => {
23
+ beforeEach(() => {
24
+ __resetTerminalRegistryForTest();
25
+ });
26
+ it('returns no-terminal when registry is empty', () => {
27
+ const r = shell.dispatchToTerminal('foo');
28
+ expect(r).toMatchObject({ ok: false, error: 'no-terminal', message: 'no terminal open' });
29
+ });
30
+ it('routes through the resolved handle when one is registered', () => {
31
+ const dispatch = vi.fn(async () => undefined);
32
+ registerTerminalView(makeHandle('term-1', 0, dispatch));
33
+ const r = shell.dispatchToTerminal('apps');
34
+ expect(r).toEqual({ ok: true, terminalId: 'term-1' });
35
+ expect(dispatch).toHaveBeenCalledWith('apps');
36
+ });
37
+ it('shares the registry with ShellApi.dispatchToTerminal (same handles, same routing)', () => {
38
+ const dispatch = vi.fn(async () => undefined);
39
+ registerTerminalView(makeHandle('term-shared', 0, dispatch));
40
+ // The singleton is the surface a Svelte view sees; it must hit the
41
+ // same registry as the verb-side ShellApi.
42
+ const r = shell.dispatchToTerminal('hi');
43
+ expect(r).toEqual({ ok: true, terminalId: 'term-shared' });
44
+ expect(dispatch).toHaveBeenCalledWith('hi');
45
+ });
46
+ });
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  /** Auto-generated from package.json — do not edit manually. */
2
- export declare const VERSION = "0.15.3";
2
+ export declare const VERSION = "0.15.4";
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /** Auto-generated from package.json — do not edit manually. */
2
- export const VERSION = '0.15.3';
2
+ export const VERSION = '0.15.4';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sh3-core",
3
- "version": "0.15.3",
3
+ "version": "0.15.4",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"