startDapHubFlow method

Future<void> startDapHubFlow()

Settings → DAP / Hub: view the live hub snapshot (url, agent name, connection state), set the hub url or the agent name (persisted through AgentCliConfig.onDapHubConfigChanged — the hub client's ~/.dap/config.json read-modify-write, so channels and invites survive), test the connection, or write the hub: false plugin opt-out into .fah/packages.yaml. Loops until the pick is cancelled or done.

Implementation

Future<void> startDapHubFlow() async {
  await _refreshDapHubSnapshot();
  for (;;) {
    final snapshot = _dapHubSnapshot;
    final picked = await _pickOption('dap / hub', [
      ('view', 'View current config', 'url, agent name, connection state'),
      ('url', 'Set hub URL', snapshot?.url ?? 'not configured'),
      ('name', 'Set agent name', snapshot?.name ?? 'not set'),
      (
        'test',
        'Test connection',
        (snapshot?.connected ?? false)
            ? 'currently connected'
            : 'not connected',
      ),
      (
        'optout',
        'Opt out of the hub plugin',
        'writes hub: false to .fah/packages.yaml',
      ),
      ('done', 'Done', ''),
    ]);
    switch (picked) {
      case null:
      case 'done':
        return;
      case 'view':
        _printDapHubConfig();
      case 'url':
        await _editDapHubValue(isUrl: true);
      case 'name':
        await _editDapHubValue(isUrl: false);
      case 'test':
        await _refreshDapHubSnapshot();
        _printDapHubConnection();
      case 'optout':
        await _writeDapHubOptOut();
    }
  }
}