LCOV - code coverage report
Current view: top level - dashql-app/src/session - session_connection_detach.tsx Coverage Total Hit
Test: DashQL 915828b Lines: 66.7 % 9 6
Test Date: 2026-11-06 19:30:32

            Line data    Source code
       1              : import * as React from 'react';
       2              : import * as core from '@ankoh/dashql-core';
       3              : 
       4              : import { useEmbeddedConnection } from '../connections/embedded_connection.js';
       5              : import { DETACH_CONNECTION, scriptConnectionOf } from './scripts/session_scripts.js';
       6              : import { useConnectionScriptsDispatch } from './scripts/session_scripts_registry.js';
       7              : 
       8              : /// Detach a connection from the sessions
       9              : export type ConnectionDetach = (dql: core.DashQL, connectionId: string) => Promise<void>;
      10              : 
      11              : /// Detach a connection from every session whose next script would merely run on it.
      12              : ///
      13              : /// Sessions without scripts hold the embedded Hyper again. Sessions with scripts on the connection
      14              : /// keep it, see DETACH_CONNECTION.
      15            1 : export function useDetachConnection(): ConnectionDetach {
      16            1 :     const resolveEmbeddedConnection = useEmbeddedConnection();
      17            1 :     const scriptsDispatch = useConnectionScriptsDispatch();
      18            1 :     return React.useCallback(async (dql: core.DashQL, connectionId: string) => {
      19            0 :         const embedded = resolveEmbeddedConnection(dql);
      20            0 :         if (embedded.connectionId === connectionId) return;
      21            0 :         await scriptsDispatch(connectionId, { type: DETACH_CONNECTION, value: { from: connectionId, into: scriptConnectionOf(embedded) } });
      22            1 :     }, [resolveEmbeddedConnection, scriptsDispatch]);
      23            1 : }
        

Generated by: LCOV version 2.0-1