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

            Line data    Source code
       1              : import * as React from 'react';
       2              : 
       3              : import { useConnectionRegistryStore } from '../connections/connection_registry.js';
       4              : import { useReplaceConnection } from './session_connection_replace.js';
       5              : 
       6              : /// Merge connections into a target connection
       7              : export type ConnectionMerge = (targetId: string, sourceIds: readonly string[]) => Promise<void>;
       8              : 
       9              : /// Merge connections that describe the same database into one.
      10              : ///
      11              : /// Each merged connection is replaced with the target, see useReplaceConnection: its sessions move to the
      12              : /// target first, the merged connection is removed once no session uses it.
      13            1 : export function useMergeConnections(): ConnectionMerge {
      14            1 :     const registryStore = useConnectionRegistryStore();
      15            1 :     const replaceConnection = useReplaceConnection();
      16              : 
      17            1 :     return React.useCallback(async (targetId: string, sourceIds: readonly string[]) => {
      18            1 :         for (const sourceId of sourceIds) {
      19            1 :             if (!registryStore.current.connections.has(targetId)) return;
      20            1 :             await replaceConnection(sourceId, targetId);
      21            1 :         }
      22            1 :     }, [registryStore, replaceConnection]);
      23            1 : }
        

Generated by: LCOV version 2.0-1