Skip to content

feat(panorama): custom linked agents on the config panorama — eighth control records, hot reload on change; fix the overlay apply chain for agent-link settings - #90

Merged
LiminCode merged 2 commits into
mainfrom
records-control
Nov 20, 2026
Merged

LiminCode merged 2 commits into
mainfrom
records-control

Conversation

@LiminCode

Copy link
Copy Markdown
Owner

Summary

PR-C of the M4 agent-link move (design memo .scratch/config-panorama/m4-agent-link-design.md §5, local): custom linked agents (agent_link.custom_agents, a list of {key, name, path}) can now be edited on the config panorama instead of by hand in config.json, and a change takes effect while the fish runs. The settings table gains its eighth control, records (a small table with typed columns, add/remove rows, one Save for the whole table), the "本机联动" group declares custom_agents with it under Advanced, and AgentLinkManager.apply_config reconciles the configured list with the running CustomAgentMonitors: new ones are created and wired, removed ones stopped and dropped, a changed path rebuilds the monitor, a changed name just renames. The per-agent on/off switch stays in the right-click menu as before.

What changed and why

  • pet/settings_table.py: CONTROLS += ("records",), Setting.fields (((field_id, text_key), …)), commit_policy on_finish for records, _type_error (list of dicts whose declared fields are strings), _as_stored (each field stripped, fully empty rows dropped — any other difference such as a lowercased key or a defaulted name is the feature's normalize and therefore rejected), _fits, validate (records need fields, only records have them). custom_agents moves from _AGENT_LINK_ELSEWHERE into the link_win group (advanced).
  • pet/panorama/settings_api.py: describe adds fields: [{id, title}] to every row (empty for the other controls).
  • pet/panorama/page/form.js: draws the table (<table class="frecords">, one text input per cell, × per row, "加一行", then the usual Save / Revert), keeps the draft as an array of objects copied from the current value on first edit, and stores rows the same way the server does; app.css styles; render.PAGE_KEYS + panorama.ui.form_add_row / form_delete_row.
  • pet/agent_link.py: _sync_custom_agents(agent_cfg) runs at the top of apply_config; the monitor→manager signal wiring is now a table (_MONITOR_SIGNALS) used by _connect_monitor / _disconnect_monitor so a hot-added monitor is wired exactly like the constructor does and a removed one is unwired before deleteLater; CustomAgentMonitor.events_path keeps the configured string for the comparison. The "needs a restart" comment is gone.
  • pet/app.py (second commit): _apply_external_config_change now applies the shared AgentLinkManager itself (idempotent; the legacy topology's per-window chain may call it again). Found on the real machine, see below: under the overlay topology there is no PetWindow, so agent-link settings changed on the panorama (channel toggles since feat(panorama): move Claude Code link, session fish and recent chats settings to the config panorama; menu keeps switches only #83, custom agents here) never reached apply_config until a restart.
  • pet/locale/zh.json, en.json: group row title/hint and the three column titles.
  • Docs: docs/settings-and-menu.md (the records control; custom_agents is edited in link_win and hot-applies), docs/config-panorama.md (eight controls), docs/agent-link-protocol.md (declare on the panorama; config.json still accepted), CHANGELOG.md.
  • Tests: tests/test_custom_agents_records.py (new, 3: description + write path incl. the four rejected shapes and two type errors; the page table under QJSEngine — draw, add + edit + save as dicts, delete → [], an untouched added row is not a change; manager hot reload — rename in place, path change rebuilds and restarts, add registers without starting, remove stops and drops, built-ins untouched; the external-config apply chain calls the shared manager even with no pet window); test_settings_table.py (records control rules; link_win now holds custom_agents); test_settings_write_path.py (fields in the description).

Performance

  • _sync_custom_agents is a dict comparison over at most 8 entries, run once per apply_config (startup and each settings change); no new timers, threads or file I/O beyond what a CustomAgentMonitor already does when it starts.
  • The page: one more branch in control(); the table re-renders on add/remove only (cell edits use the existing per-row refresh). form.js 11.0 KB (was 9.6 KB), app.css +5 lines.
  • Description payload: one fields list per row (empty for seven of the eight controls).

Real-machine run

  1. Pet restarted from this branch (pid 10504, 00:00:24; both link channels report their hooks present, no ERROR).
  2. Page: a standalone PanoramaService from this branch over the real config (real probes, settings writable, apply chain empty) opened at /#<token>&settings=link_win in the built-in browser. The 本机联动 form opened on focus; Advanced showed the table with headers 标识 / 显示名 / 事件文件, "加一行" and Save. Added a row (demo_hot / Demo Hot / a scratch .jsonl path) and saved → status "已保存,已经生效", config.json then held exactly that row. Changed the key to Bad Key and saved → status "有几项没存上,见下面标红的", the row red with "肥鱼不认这个值…", config unchanged. Revert restored demo_hot; × then Save → "已保存", custom_agents: [].
  3. Hot reload through the fish's own channel: the settings-process command file asked the running fish to open the panorama at link_win (log: 收到设置进程指令 → 打开配置全景(link_win), 配置全景服务已启动:http://127.0.0.1:10207). The user added a row on that page. The write landed (配置全景:改了设置 link_win(custom_agents)) but no 已登记 line followed, and the Cursor toggle the user flipped on the same page had not started or stopped its monitor either: under the overlay topology PetInstance.win is None, so the 各窗 refresh_pet_settings → sync_optional_services → apply_config chain that _apply_external_config_change relied on never runs (a gap since feat(panorama): move Claude Code link, session fish and recent chats settings to the config panorama; menu keeps switches only #83 — every agent-link setting edited on the panorama waited for a restart). Fixed in the second commit (see below); pet restarted from the branch (pid 58996), the panorama reopened the same way, and the user removed the row: 配置全景:改了设置 link_win(custom_agents) at 00:10:51.255, 自定义联动 Agent [demo_hot] 已移除 at 00:10:51.370, config.json back to custom_agents: [], no ERROR. (Writes from the standalone service in step 2 do not reach the running fish by design: its config-file watcher is only installed while a settings process runs.)

Tests

Red first: tests/test_custom_agents_records.py failed on records not being a control, fields missing from the description, the page drawing a textarea, and apply_config leaving a removed agent's monitor in place; the three updated expectations (records commits on finish, custom_agents in link_win, fields in the description) failed before the change. Affected families (settings, panorama, agent link, i18n, architecture, docs discipline, config domains, feature gating, menus): 1212 passed, 3 skipped, 1 failure = the known baseline test_compact_ai_provider_controls_stay_inside_their_setting_row. ruff check pet tests and git diff --check clean. Full suite not run: no config migration (the key and its cleaner are unchanged), no new threads, no platform dispatch change; the manager change is covered by the hot-reload test and the existing agent-link family.

Docs

  • CHANGELOG.md: one line (user-visible change)
  • Topic doc under docs/ updated (settings-and-menu.md, config-panorama.md, agent-link-protocol.md)
  • ADR: not needed (one more control in the settings table; ADR 0014 already decides that settings live on the panorama)

🤖 Generated with Claude Code

LiminCode and others added 2 commits November 20, 2026 00:03
…格),custom_agents 改了热生效

- settings_table:CONTROLS 加 records,Setting.fields 声明列;_type_error / _as_stored / _fits / validate 认它(每字段去空白、
  全空行不要,其余差别交给功能的 normalize → rejected);custom_agents 进 link_win 组(高级),不再 not_editable
- settings_api.describe 多给 fields;form.js 画记录表(加行 / 删行 / 整表保存,草稿是一组对象);app.css;字表(加一行 / 删掉这一行、
  标识 / 显示名 / 事件文件)
- agent_link:apply_config 先 _sync_custom_agents(新增的建并接信号、删掉的停并断开移除、改路径的重建、只改名的换名);
  监视器信号接线抽成 _connect_monitor / _disconnect_monitor;CustomAgentMonitor 记 events_path 原样
- docs:settings-and-menu(records、custom_agents 去哪改)、config-panorama(八种控件)、agent-link-protocol、CHANGELOG

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@LiminCode
LiminCode merged commit e82f3cf into main Nov 20, 2026
0 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant