The switcher used to be embedded per page (Flows/Runs/Audit/
Approvals) — invisible on the other five pages and sitting in a
different corner depending on the page (persona review 2026-08-27,
consensus finding). It now lives ONCE in the sidebar, above the
destinations: active project/area always visible, opens the same
menu everywhere, Cmd+P from anywhere. The shell listens to the
workspace, so the sidebar endpoint label can no longer lag a
sealed switch until the next health tick.
Also in this rebuild:
* Stopped sealed areas ask before starting ("Start area X?") —
a context switch must never boot a hub daemon as a click
side-effect; running areas keep switching with one click.
* The switcher tooltip told a wrong scope ("filters this view") —
it now says the choice applies everywhere and stamps new runs.
* The aggregated sealed row explains itself in place (names can
reveal client identities) and links to the Settings toggle
(Settings dialog gained an initialCategory jump).
* The active entry carries a checkmark in the menu.
* The Cmd+K palette knows projects and areas, ranked by recent
use; sealed names honour the privacy setting — while hidden,
the palette offers the guarded picker instead of the names.
* The runs empty state names the active project filter as the
cause ("No runs in project X" + show-all action) instead of
claiming the feature is off.
Tests updated to the anchor and made hermetic (scriptable
projects on the fake hub, sealed-area fake); new coverage for the
checkmark, the why-line, and the start confirmation.
Signed-off-by: flemming-it <stefan.a.flemming@googlemail.com>
55 lines
2.1 KiB
Dart
55 lines
2.1 KiB
Dart
// Workspace display preferences (SidebarPrefs pattern: eager
|
|
// ValueNotifier + SharedPreferences persistence, loaded once at
|
|
// startup).
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
class WorkspacePrefs {
|
|
WorkspacePrefs._();
|
|
|
|
static const _kSealedNamesKey = 'workspace.sealed_names_visible';
|
|
|
|
/// Whether the workspace switcher lists sealed areas with their
|
|
/// names right away. Default FALSE: area names often carry
|
|
/// client/mandate identity, so the switcher shows an aggregated
|
|
/// row ("2 sealed areas") until the operator deliberately
|
|
/// expands it (usertest security finding). The Settings toggle
|
|
/// restores the direct listing for single-operator machines.
|
|
static final ValueNotifier<bool> sealedNamesVisible =
|
|
ValueNotifier(false);
|
|
|
|
static Future<void> load() async {
|
|
final prefs = await SharedPreferences.getInstance();
|
|
sealedNamesVisible.value = prefs.getBool(_kSealedNamesKey) ?? false;
|
|
recentContexts.value =
|
|
prefs.getStringList(_kRecentContextsKey) ?? const [];
|
|
}
|
|
|
|
static Future<void> setSealedNamesVisible(bool value) async {
|
|
sealedNamesVisible.value = value;
|
|
final prefs = await SharedPreferences.getInstance();
|
|
await prefs.setBool(_kSealedNamesKey, value);
|
|
}
|
|
|
|
static const _kRecentContextsKey = 'workspace.recent_contexts';
|
|
static const _kRecentContextsMax = 5;
|
|
|
|
/// Recently chosen switcher values (menu-value scheme: '' /
|
|
/// `p:<slug>` / `s:<slug>`), most recent first. The command
|
|
/// palette ranks matching contexts by this list so a poweruser's
|
|
/// frequent areas surface before the alphabet.
|
|
static final ValueNotifier<List<String>> recentContexts =
|
|
ValueNotifier(const []);
|
|
|
|
/// Record a switcher selection (deduped, capped, persisted).
|
|
static Future<void> recordRecentContext(String value) async {
|
|
final next = [
|
|
value,
|
|
...recentContexts.value.where((v) => v != value),
|
|
].take(_kRecentContextsMax).toList();
|
|
recentContexts.value = next;
|
|
final prefs = await SharedPreferences.getInstance();
|
|
await prefs.setStringList(_kRecentContextsKey, next);
|
|
}
|
|
}
|