Files
pipelines/app/lib/features/settings/settings_page_sections.dart
T
alan 6367cce68a Read chat replies aloud with word highlighting
An assistant reply gets Read aloud beside Copy; while it reads it becomes
Pause/Resume and Stop, one reply at a time app-wide. The spoken word is
highlighted in the rendered reply (across multi-part replies) and the
transcript scrolls only when that word leaves the viewport. Reading stops
when its chat closes or is swapped, another reply starts, or the app goes
to the background. Markdown is spoken as sentences; code blocks are
announced as "Code block.".

Speech goes through a SpeechEngine seam with a flutter_tts implementation
(Android, macOS, web; hidden on Linux) and a fake for tests. Settings has
a Read aloud section: a voice picker grouped by language (device language
first, a sample per voice), a rate slider and reset, saved per device.

flutter_tts has no Swift package, so macOS/iOS gain the CocoaPods
integration (Podfiles with the Runner deployment targets); Android
declares the TTS_SERVICE query. The capture fixture gains ?speech=fake.
2026-11-13 01:29:04 +00:00

235 lines
7.9 KiB
Dart

part of 'settings_screen.dart';
/// The Settings page's sections, in order. Each entry keeps the widgets the
/// former category pages held; a server-backed entry is `lazy`.
extension _SettingsPageSections on _SettingsScreenState {
List<SettingsSection> _pageSections() {
final servers = widget.servers;
return [
SettingsSection(
id: 'interface-size',
title: 'Interface size',
keywords: 'text size scale zoom large small font',
builder: (_) => const SettingsScaleSection(),
),
if (speechController.supported)
const SettingsSection(
id: 'read-aloud',
title: 'Read aloud',
keywords: 'speech voice audio speaking rate read aloud',
builder: _readAloudBuilder,
),
SettingsSection(
id: 'animations',
title: 'Animations',
keywords: 'animation speed motion quick switch',
builder: (_) => SettingsAnimationSection(
controller:
widget.animationSpeed ?? AnimationSpeedController.instance,
),
),
SettingsSection(
id: 'font',
title: fontSectionTitle,
keywords: 'font typeface custom text',
builder: (_) => SettingsFontSection(
controller: widget.fonts ?? AppFontController.instance,
),
),
SettingsSection(
id: 'terminal',
title: 'Terminal',
keywords: 'terminal layout mode split',
builder: (_) => SettingsTerminalSection(
layout: widget.terminalLayout ?? TerminalLayout.instance,
),
),
if (servers != null) ...[
SettingsSection(
id: 'servers',
title: 'Servers',
keywords: 'saved server profile add remove switch address',
builder: (_) => SavedServersSection(connections: servers),
),
SettingsSection(
id: 'managed-connection',
title: 'Connection',
keywords: 'address current reconnect disconnect status',
builder: (_) => ManagedConnectionSection(
client: widget.client,
controller: _controller,
),
),
] else
SettingsSection(
id: 'connection',
title: 'Connection',
keywords: 'server url address connect disconnect reconnect status',
builder: (_) => SettingsConnectionSection(
controller: _controller,
serverUrlField: _serverUrlField,
),
),
if (widget.showSignIn)
SettingsSection(
id: 'sign-in',
title: 'Sign in',
keywords: 'login password web account',
builder: (_) => _single(
'Sign in',
SettingsSignInSection(
endpoint: _endpoint,
onChanged: _reconnectAfterSignIn,
),
),
),
if (widget.showSignIn || kIsWeb)
SettingsSection(
id: 'sign-in-security',
title: 'Sign-in security',
keywords: 'password sessions sign out everywhere revoke weak',
lazy: true,
builder: (_) => _single(
'Sign-in security',
SettingsSecuritySection(
endpoint: _endpoint,
onSignedOut: _reconnectAfterSignIn,
),
),
),
SettingsSection(
id: 'workspace',
title: 'Workspace',
keywords: 'workspace path folder directory server save',
builder: (_) => SettingsWorkspaceSection(
controller: _controller,
workspaceField: _workspaceField,
),
),
if (widget.notifications case final notifications?)
SettingsSection(
id: 'notifications',
title: notificationSectionTitle,
keywords: 'notification permission browser alerts enable',
builder: (_) =>
SettingsNotificationsSection(controller: notifications),
),
if (widget.deliveryService case final service? when service.supported)
SettingsSection(
id: 'device-delivery',
title: deviceDeliveryTitle,
keywords: 'background delivery battery android notifications',
builder: (_) => SettingsDeviceDeliverySection(
bridge: service,
controller: widget.deliveryServiceController,
requestNotificationPermission: widget.notifications == null
? null
: () async {
await widget.notifications!.requestPermission();
},
),
),
SettingsSection(
id: 'phone-notifications',
title: ntfySectionTitle,
keywords: 'ntfy push phone run finished chat needs you',
lazy: true,
builder: (_) => SettingsNtfySection(
gateway: widget.client,
connected:
widget.client.state.kind == transport.ConnectionKind.connected,
),
),
SettingsSection(
id: 'data',
title: 'Data management',
keywords: 'storage retention worktrees cleanup disk usage',
builder: (_) => _single(
'Data management',
SettingsStorageSection(gateway: widget.client),
),
),
SettingsSection(
id: 'server',
title: 'Server',
keywords: 'health cpu memory gpu process stats',
builder: (_) =>
_single('Server', SettingsHealthSection(gateway: widget.client)),
),
if (widget.onOpenSchedules case final open?)
SettingsSection(
id: 'library',
title: 'Library',
keywords: 'schedules saved runs pipelines',
builder: (_) => SettingsGroup(
title: 'Library',
leadingRows: true,
children: [SettingsSchedulesSection(onOpen: open)],
),
),
if (widget.showAndroidDownload)
SettingsSection(
id: 'android-app',
title: 'Android app',
keywords: 'apk download install',
builder: (_) =>
_single('Android app', const SettingsAndroidDownloadSection()),
),
if (widget.showSignIn && appUpdatesSupported)
SettingsSection(
id: 'app-updates',
title: 'App updates',
keywords: 'update version build install',
builder: (_) => _single(
'App updates',
SettingsUpdatesSection(endpoint: _endpoint, servers: servers),
),
)
else if (!widget.showAndroidDownload)
SettingsSection(
id: 'app-updates-managed',
title: 'App updates',
keywords: 'update version build administrator',
builder: (_) => _single(
'App updates',
const Text(
'This installation is updated by its server administrator.',
),
),
),
// Help and about: the walkthrough's "Show the walkthrough" row sits in
// this group beside the keyboard shortcuts.
SettingsSection(
id: 'help',
title: 'Help and about',
keywords: 'keyboard shortcuts help about walkthrough tour guide',
builder: (_) => SettingsGroup(
title: 'Help and about',
leadingRows: true,
children: [
const SettingsKeyboardShortcutsSection(),
SettingsRow(
key: SettingsKeys.showWalkthrough,
leading: const Icon(Icons.school_outlined),
title: const Text('Show the walkthrough'),
subtitle: const Text('Replay the short tour of Pipelines.'),
chevron: true,
enabled: widget.onShowWalkthrough != null,
onTap: widget.onShowWalkthrough,
),
],
),
),
];
}
static Widget _readAloudBuilder(BuildContext _) =>
const SettingsReadAloudSection();
/// A group holding one free-form block (a form, a status with buttons).
Widget _single(String title, Widget child) => SettingsGroup(
title: title,
children: <Widget>[SettingsGroupItem(child: child)],
);
}