feat(ui,agent,core): UI tokens, comparison primitive, provider pool - #164
Merged
Conversation
- Introduce ComparisonCommands as the sole write primitive for comparison symbols (list / create / remove / clear), with @tool decorated methods registered directly on the primitive - Move Tool registry to foundation/agent/chartToolRegistry.ts, broaden decorator return type to allow sync primitives - Chart, ChartDataManager, ChartController delegate to ComparisonCommands; remove ChartDataManager.addComparisonSymbol/removeComparisonSymbol - Add toolHosts to ChartAgentController for bridge target resolution - Bridge resolves primitive tool targets via toolHosts with fallback to agent - Add comparisonCommands.test.ts + update related tests - Add docs/design/comparison-command-boundary.md - Filed #162 for pre-existing mock technical debt Closes #162
Both hand-written doubles mirrored the full ChartController interface, so every core interface change forced stub churn and produced TS2740/TS2322. The angular double now declares only the members KLineChartComponent consumes, constrained by Partial<ChartController>; the vue double keeps its controllable signals but is no longer typed as the full interface. Both drop the unused agent field. Add a shared minimal ChartAgentController double and replace the partial 'as ChartAgentController' casts in browser-agent-bridge tests, which surfaced two previously hidden required fields (selectedKLineBars, drawing labels). Closes #162
Agent 调用 comparison_create 报 this.primarySpec is not a function:bridge 用工具名(comparison_create)在宿主上查找方法,但原语方法名是 create,查找落空后回退到 Agent facade,导致 this 绑定错误。 @tool 装饰时自动记录真实方法名与函数引用并暴露 owns(host);bridge 据此按函数身份认领原语宿主,未命中原语时归属 facade。补充 core 与 vue 回归测试并同步设计文档。
BaseModal now paints one agent-surface background and lets the header/tabs/body/footer inherit it instead of each region setting its own. Dropdown defaults the trigger border to agent-border and moves trigger hover/focus and menu background to agent tokens, applied globally. IndicatorSelector surfaces (indicator cards, search box, view-tabs) move to agent-input and view-tabs gains a sliding active thumb. AgentSettingsDialog rewrites the profile list, adds an animated tab underline, and themes inputs, triggers and buttons on agent tokens. The color preset theme selector moves out of ColorPresetPanel into BaseModal's #tabs slot as an underline Tab, with ColorPresetPanel now receiving editingTheme as a controlled prop.
…write primitive comparison_create now resolves the real instrument against the active market-data sources via an injected resolveInstrument, so exchange/id/params come from the provider catalog instead of being inherited from the primary symbol; source restricts the lookup. It throws named KLineChartError codes (COMPARISON_NO_PRIMARY / INSTRUMENT_NOT_FOUND / COMPARISON_DUPLICATE) with actionable messages so the Agent can self-correct, while the programmatic add(SymbolSpec) keeps the boolean contract and preserves full spec fields. The primitive registers the spec into the symbol catalog before writing symbols, so UI and Agent no longer patch state around the call. The comparison percent axis is now model-driven (renderer + pane projection), removing the UI forcePercentAxis/registerSymbols workaround in KLineChart.
Agent runtime moved to @363045841yyt/klinechart-agent-runtime, and chart-native agent tools now register through core's @tool registry. Mark the package deprecated via the package.json deprecated field, README notice and @deprecated JSDoc on the entrypoints; it stays for backward compatibility until removal.
Split the generic UI roles out of colors.agent into colors.ui (background/surface/card/input/hover/border/text/accent + status colors) and keep only agent-specific roles in colors.agent (userMessage/launcher*/backdrop/panelShadow). CSS consumers move from --klc-color-agent-<generic> to --klc-color-ui-*, so shared chrome no longer carries an agent-specific name. Add shared BaseButton and BaseTabs and route every BaseModal footer plus the settings/agent tabs through them, so button and tab styling is defined once instead of copied per dialog. Preview DebugControls and the chart-surface chrome (TopToolbar, LeftToolbar, PaneHeaderOverlay, CanvasToolbar, RangeSelectionExport, DrawingStyleToolbar, WatchlistPanel, KLineChart) move off chart tokens and hardcoded accents onto ui tokens. Fix undefined vars found during the audit: --klc-color-agent-error -> --klc-color-ui-danger-text and --klc-color-primary -> --klc-color-ui-accent (dropping the hardcoded fallbacks). BREAKING CHANGE: generic --klc-color-agent-* CSS variables are renamed to --klc-color-ui-*; only user-message, launcher-*, backdrop and panel-shadow keep the agent prefix.
Add colors.ui.controlBackground (same value as the ui.hover / watchlist selected fill) and emit --klc-color-ui-control-background, so the Dropdown trigger and text inputs share one control fill instead of ad-hoc chart tokens. Apply it to the Dropdown trigger (keeping the --dropdown-trigger-background override) and to the text inputs in AlertRuleForm, IndicatorParams, AggregationSourceDialog, BatchStockDialog, IndicatorSelector, RangeSelectionExport and the KLineChart label editor.
The symbol and compare popovers duplicated teleport, positioning, outside-click close, the tab bar and the search row (plus ~200 lines of near-identical CSS). Extract SymbolPopover: it owns those concerns, exposes #tabs and #body slots, and carries one theme-token style (ui-surface/border/text/muted/accent, 360px, radius 8). SymbolSelector and CompareSymbolSelector now consume it. Their chips adopt the Dropdown trigger look (28px, radius 8, ui-control-background, hover ui-border-strong) and their list/selected styles move onto ui tokens.
Add a compact size=sm variant to BaseButton and render the TopToolbar back button through it with the tabler arrow-left icon, replacing the bespoke button styles.
BaseModal title, subtitle and close button now consume ui tokens, and the subheader divider is dropped. The IndicatorParams dialog switches to ui tokens and tabler icons (info/minus/plus).
View tabs become an accent segmented control sized by --view-tab-count, the search box and card active/focus states switch to ui tokens, and the card hover lift is dropped.
Place a 清除 button left of 确认 that turns off every active indicator through the existing toggle event; it is hidden in replace mode and disabled when nothing is selected.
The dropdown selected option and the open-source credit names still used non-theme colors (chart selection-stroke / a hardcoded blue), so they stayed blue across themes. Dropdown now uses ui-accent and its remaining chart tokens map to ui tokens; credit items keep the hover background but no longer recolor the text.
开发期调试日志会在每次 resize 时打印,无实际用途且污染控制台。
工具设置页的原生 button/checkbox 各自复制样式且未走 ui token 主题;改用 BaseButton 与 ToggleSwitch 统一主题色、hover 与禁用态。运行按钮文案精简为「运行」并统一字号。
Add rename/delete for saved Provider configurations with hover actions in the settings dialog, and rebuild the cross-Provider model pool around one shared CRUD class. Previously both the settings store and the bridge performed read-modify-write on the same pool array, so persistence and validation were duplicated. Atomic add/remove methods make the bridge the single writer and let the dialog toggle pool membership directly; the whole-array saveProviderModelPool contract method is removed. Provider profile and model pool storage now cache in memory and persist only when state changes, instead of parsing and serializing localStorage on every read. Retry keeps one run input per session rather than one per run, removing unbounded growth of the run-input map, and profile name validation is reported inside the naming dialog. Tests: browser-agent-bridge, agent-provider-settings-store, fake-agent-bridge, agent-workbench-shell.
- Remove LEGACY_PROVIDER_SETTINGS_VERSIONS check and v1 protocol upgrade - Remove getProfileConnection helper, use profile.connection directly - Write connection alongside settings in BrowserProviderSettingsStore.write - Improve profile actions hover/focus UX with absolute positioning
computeMaxScrollLeftWithVisibleData now snaps max scroll to the physical K-line grid (b504766), so the last bar's left edge aligns to the plot origin instead of reserving a single trailing pixel. Update the stale hardcoded values; the tests' intent (last bar stays visible, trailing slots allowed) is unchanged.
Provider settings now persist on field blur and require an active Profile, and the timeline renders .run-status only when a run has usage or an active/undoable turn. Update agent-workspace tests to create a profile, blur to persist, close the dialog explicitly, and assert the stopped run via the composer stop button.
errors-help.ts enforces a hint for every KLineChartErrorCode via its Record type, so the build failed after COMPARISON_NO_PRIMARY and COMPARISON_DUPLICATE were added to the taxonomy. Add the missing hints.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概述
将
feat/agent分支的 22 个提交合并到main,共 84 个文件(+3162 / -2414),涵盖四块工作。1. UI 语义 Token 统一(破坏性)
refactor(ui)!: unify UI chrome on semantic ui tokens:弹窗、下拉、标签页、指标选择器、品种选择器统一迁移到语义 token,杜绝局部硬编码颜色。BaseButton、BaseTabs、SegmentedTabs、SymbolPopover,替换各处重复实现。2. 对比品种统一写原语
ComparisonCommands(packages/core/src/engine/data/comparisonCommands.ts)作为对比品种唯一写入口,统一create/remove/clear/list。@Tool直接标注原语方法,向 Agent 暴露comparison_create/comparison_remove/comparisons_clear/comparisons_list;UI 与 Agent 共用同一实例。resolveInstrument,并在解析失败/重复/缺主品种时抛出具名KLineChartError(COMPARISON_NO_PRIMARY/INSTRUMENT_NOT_FOUND/COMPARISON_DUPLICATE)。docs/design/comparison-command-boundary.md。3. Agent Provider / 模型池
agent-provider-settings-store.ts+ 独立 Pinia 容器)。ai-runtime标记废弃,迁移到agent-runtime。4. 视口右侧边缘像素对齐
computeMaxScrollLeftWithVisibleData吸附物理 K 线网格,使最大滚动位置对齐最后一根 K 线左缘,修复右侧边缘像素对齐。破坏性变更
refactor(ui)!将 UI chrome 统一到语义 token,旧样式/DOM 约定不再保证兼容;下游若直接依赖旧类名或结构需迁移。测试
pnpm test:packages全绿:core 212、agent-runtime 8、vue 18、react 1、angular 1、ai-runtime 8(ui-schema、desktop-electron 无测试)。packages/vueagent-workspace.test.ts失败:provider 改为 Profile + 失焦持久化流程,.run-summary已重构为.run-status。