Skip to content

feat(dashboard): global Auto-Dream on/off switch on the Memory tab#6194

Merged
houko merged 2 commits into
mainfrom
feat/6188-auto-dream-global-toggle
Jun 19, 2026
Merged

feat(dashboard): global Auto-Dream on/off switch on the Memory tab#6194
houko merged 2 commits into
mainfrom
feat/6188-auto-dream-global-toggle

Conversation

@houko

@houko houko commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #6188. The Memory → Auto-Dream tab exposed the global Auto-Dream state only as a read-only badge, with inline copy telling users to edit config.toml under [auto_dream] to flip it. The per-agent enroll toggles already existed, so the gap was specifically the global master switch.

Changes

  • crates/librefang-api/dashboard/src/pages/Memory/tabs/AutoDreamTab.tsx
    • Replace the read-only <Badge> with an interactive checkbox toggle (reusing the per-agent enroll styling), wired to the existing useSetConfigValue({ path: "auto_dream.enabled" }) mutation. The auto_dream. prefix is already on the config-set writable allowlist, so no backend change is needed.
    • The handler additionally invalidates autoDreamKeys.all — which useSetConfigValue does not — so the badge and the per-agent "Dream now" buttons (which key off the global flag) reflect the new state immediately rather than after the 15s poll.
  • src/locales/{en,zh,uk}.json — new keys (auto_dream_global_toggle_title, auto_dream_global_on_ok, auto_dream_global_off_ok) and reworded auto_dream_desc_inline to drop the "edit config.toml" clause.
  • src/pages/Memory/index.test.tsx — vitest case asserting a click dispatches mutate({ path: "auto_dream.enabled", value: true }).

Dashboard-only; no Rust/kernel/schema change. The flag is read live by the kernel each consolidation tick, so the toggle takes effect without a restart even though POST /api/config/set conservatively classes the [auto_dream] struct as restart-required.

Verification

$ pnpm typecheck   # tsc --noEmit — clean
$ pnpm exec vitest run src/pages/Memory/index.test.tsx
  Test Files  1 passed (1)
       Tests  8 passed (8)
$ pnpm exec eslint src/pages/Memory/tabs/AutoDreamTab.tsx src/pages/Memory/index.test.tsx   # clean
$ pnpm build   # ✓ built in 751ms

Note

The global flag is also editable via the generic ConfigPage form (auto_dream in the "memory" group); this PR only adds the convenience switch on the Memory → Auto-Dream tab where the issue screenshot points, and does not move or duplicate the ConfigPage field.

@github-actions github-actions Bot added size/M 50-249 lines changed has-conflicts PR has merge conflicts that need resolution area/docs Documentation and guides labels Jun 18, 2026
Evan and others added 2 commits June 18, 2026 16:37
The Memory -> Auto-Dream tab only exposed a read-only status badge and told
users to edit config.toml under [auto_dream] to flip the global switch. Per
agent enroll toggles already existed, so the gap was specifically the master
switch.

Replace the badge with an interactive toggle wired to the existing
POST /api/config/set endpoint (auto_dream.enabled is on the writable
allowlist). The handler additionally invalidates autoDreamKeys -- which
useSetConfigValue does not -- so the badge and the per-agent Dream now buttons
reflect the new global state immediately instead of after the 15s poll. The
flag is read live by the kernel each consolidation tick, so the toggle takes
effect without a restart.

i18n keys added to en/zh/uk; vitest coverage added for the toggle dispatching
the config-set mutation.

Closes #6188
… hook

Move the global Auto-Dream toggle from useSetConfigValue with an onSuccess
callback in the component into a dedicated useSetAutoDreamGlobalEnabled hook
in mutations/autoDream.ts. This matches the pattern of useTriggerAutoDream,
useAbortAutoDream, and useSetAutoDreamEnabled, all of which own their
autoDreamKeys.all invalidation inside the hook rather than at the call site.

The component's onChange handler now uses mutateAsync with try/catch, consistent
with onTrigger/onAbort/onToggle in the same file. The 9-line comment block that
explained the workaround is removed — it is no longer needed.
@houko
houko force-pushed the feat/6188-auto-dream-global-toggle branch from 5ee0748 to f7b87e0 Compare June 18, 2026 07:37
@github-actions github-actions Bot added ready-for-review PR is ready for maintainer review no-rust-required This task does not require Rust knowledge and removed has-conflicts PR has merge conflicts that need resolution labels Jun 18, 2026
@houko
houko merged commit ae2f256 into main Jun 19, 2026
33 checks passed
@houko
houko deleted the feat/6188-auto-dream-global-toggle branch June 19, 2026 04:38
GQAdonis pushed a commit to GQAdonis/librefang that referenced this pull request Jun 19, 2026
Merge upstream/main into the BossFang fork; origin/main was 15 commits behind.

Notable upstream changes:
- librefang#6225 scope the compaction-summary banner to the compacted session (adds canonical_sessions.compacted_summary_session_id).
- librefang#6196 deny WASM fs_write to the audit anchor via a capability deny-list.
- librefang#6226 / librefang#6227 add agent label and exit-reason metrics to the agent loop.
- librefang#6215 context-window usage indicator + honest quota-error classification.
- librefang#6217 per-instance sidecar secrets so each agent owns its own handle.
- librefang#6194 global Auto-Dream on/off switch on the Memory tab.
- librefang#6211 / librefang#6214 / librefang#6212 token/context cap fixes; librefang#6208 refuse to delete the active prompt version.
- librefang#6218 browser_tools.rs ToolError migration; librefang#6203 launchctl let-binding build fix; librefang#6224 docs dep bumps; librefang#6193 drop five orphaned email deps.

Conflict resolution:
- deny.toml: keep our RUSTSEC-2025-0141 (bincode 2.0.x) ignore entry (take ours).
- deny.toml: ignore three pre-existing unmaintained advisories newly tripped by the RustSec DB (all transitive via the UAR provider chain, none introduced by this merge): RUSTSEC-2024-0384 (instant), RUSTSEC-2024-0436 (paste), RUSTSEC-2025-0119 (number_prefix).

BossFang preservation (SurrealDB schema parity for upstream SQLite v46 / librefang#6225):
- Add crates/librefang-storage/src/migrations/sql/032_canonical_sessions_compacted_summary_session_id.surql declaring the new field on the SCHEMAFULL canonical_sessions table (SCHEMAFULL silently drops undefined fields on write), registered as version 32 in migrations/mod.rs.
- migrate/sqlite_to_surreal.rs: copy the new column so a SQLite to SurrealDB migration preserves the owning-session pointer rather than dropping it.
- backends/surreal_session.rs: preserve compacted_summary_session_id across canonical appends, since the upsert replaces the whole record.
- Cargo.lock: pick up the workspace version bump (beta.19 to beta.20) the merge introduced.

Verification:
- cargo check --workspace --lib — clean.
- cargo check -p librefang-storage -p librefang-memory -p librefang-uar-spec — clean.
- cargo test -p librefang-storage migration — ok (migration ordering / SurrealDB-3 flexible-syntax invariants).
- cargo test -p librefang-memory --lib session — 50 passed (incl. upstream's store_llm_summary round-trip test).
- cargo clippy -p librefang-storage -p librefang-memory — clean.
- python3 scripts/enforce-branding.py --check — clean; Tauri desktop audit and URL-drift scan both clean.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/docs Documentation and guides no-rust-required This task does not require Rust knowledge ready-for-review PR is ready for maintainer review size/M 50-249 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UI 页面 增加自动梦境开关

2 participants