@steerable/agent-shell-web 0.6.19 → 0.6.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/package.json +15 -8
  2. package/vite.base.d.ts +7 -0
  3. package/vite.base.js +83 -0
  4. package/src/brand.test.ts +0 -22
  5. package/src/components/AgentSidebar.test.tsx +0 -791
  6. package/src/components/ChatHeader.test.tsx +0 -230
  7. package/src/components/LocalLlmSettingsModal.test.tsx +0 -372
  8. package/src/components/chat/ApprovalModal.test.tsx +0 -83
  9. package/src/components/chat/AskUserModalHost.test.tsx +0 -176
  10. package/src/components/chat/AskUserQuestionMenu.test.tsx +0 -190
  11. package/src/components/chat/AssistantMessage.test.tsx +0 -68
  12. package/src/components/chat/ChatInput.test.tsx +0 -609
  13. package/src/components/chat/ExecPolicyPicker.test.tsx +0 -26
  14. package/src/components/chat/Markdown.test.tsx +0 -170
  15. package/src/components/chat/ModelPicker.test.tsx +0 -149
  16. package/src/components/chat/SessionTreeModal.test.tsx +0 -161
  17. package/src/components/chat/TaskOutcomeCards.test.tsx +0 -97
  18. package/src/components/chat/TaskPanelModal.test.tsx +0 -198
  19. package/src/components/chat/TaskProcessPanel.test.tsx +0 -111
  20. package/src/components/chat/TurnProcessGroup.test.tsx +0 -161
  21. package/src/components/chat/elapsed.test.ts +0 -42
  22. package/src/components/chat/executed-actions-model.test.ts +0 -134
  23. package/src/components/chat/orchestration-children-model.test.ts +0 -115
  24. package/src/components/chat/turn-timeline.test.ts +0 -97
  25. package/src/components/chat/useChatTasks.test.ts +0 -136
  26. package/src/components/settings/AgentsSettingsPanel.test.tsx +0 -229
  27. package/src/components/settings/InsightsSettingsPanel.test.tsx +0 -132
  28. package/src/components/settings/LlmSettingsPanel.test.tsx +0 -461
  29. package/src/components/settings/ModelIdCombobox.test.tsx +0 -88
  30. package/src/components/settings/SecuritySettingsPanel.test.tsx +0 -122
  31. package/src/components/settings/SkillsSettingsPanel.test.tsx +0 -62
  32. package/src/components/settings/WebSearchSettingsPanel.test.tsx +0 -90
  33. package/src/components/settings/compat-flags-model.test.ts +0 -71
  34. package/src/components/settings/llm-vendors.test.ts +0 -171
  35. package/src/components/settings/model-capabilities.test.ts +0 -88
  36. package/src/components/settings/preset-choice-model.test.ts +0 -96
  37. package/src/hooks/useChatsAndAgents.test.ts +0 -165
  38. package/src/lib/attachments.test.ts +0 -127
  39. package/src/lib/chat-title.test.ts +0 -53
  40. package/src/lib/chat-transport.test.ts +0 -282
  41. package/src/lib/date-groups.test.ts +0 -62
  42. package/src/lib/demo-flag.test.ts +0 -17
  43. package/src/lib/electron-bridge.test.ts +0 -54
  44. package/src/lib/exec-policy.test.ts +0 -71
  45. package/src/lib/http-bridge.test.ts +0 -283
  46. package/src/lib/insights.test.ts +0 -56
  47. package/src/lib/local-api.test.ts +0 -353
  48. package/src/lib/pending-first-message.test.ts +0 -17
  49. package/src/lib/slash-sources.test.ts +0 -161
  50. package/src/pages/AgentPage.test.tsx +0 -627
  51. package/src/pages/SettingsPage.test.tsx +0 -102
  52. package/vite.base.ts +0 -94
@@ -1,102 +0,0 @@
1
- import { cleanup, fireEvent, render, screen } from '@testing-library/react';
2
- import { MemoryRouter } from 'react-router-dom';
3
- import { afterEach, describe, expect, it, vi } from 'vitest';
4
-
5
- const { save } = vi.hoisted(() => ({ save: vi.fn(async () => {}) }));
6
-
7
- vi.mock('@/lib/electron-bridge', () => ({
8
- isElectron: () => true,
9
- }));
10
-
11
- vi.mock('@/components/settings/LlmSettingsPanel', async () => {
12
- const react = await import('react');
13
- return {
14
- LlmSettingsPanel: react.forwardRef(function MockLlm(
15
- props: { onSaveUiChange?: (ui: { saving: boolean; savedOk: boolean; loading: boolean }) => void },
16
- ref,
17
- ) {
18
- react.useImperativeHandle(ref, () => ({ save }));
19
- react.useEffect(() => {
20
- props.onSaveUiChange?.({ saving: false, savedOk: false, loading: false });
21
- }, [props.onSaveUiChange]);
22
- return <div data-testid="llm-panel" />;
23
- }),
24
- };
25
- });
26
-
27
- vi.mock('@/components/settings/InsightsSettingsPanel', () => ({
28
- InsightsSettingsPanel: () => null,
29
- }));
30
- vi.mock('@/components/settings/TelemetrySettingsPanel', () => ({
31
- TelemetrySettingsPanel: () => null,
32
- }));
33
- vi.mock('@/components/settings/UsagePanel', () => ({
34
- UsagePanel: () => null,
35
- }));
36
- vi.mock('@/components/settings/WebSearchSettingsPanel', () => ({
37
- WebSearchSettingsPanel: () => null,
38
- }));
39
- vi.mock('@/components/settings/SecuritySettingsPanel', () => ({
40
- SecuritySettingsPanel: () => null,
41
- }));
42
- vi.mock('@/components/settings/SkillsSettingsPanel', () => ({
43
- SkillsSettingsPanel: () => null,
44
- }));
45
- vi.mock('@/components/settings/McpSettingsPanel', () => ({
46
- McpSettingsPanel: () => null,
47
- }));
48
- vi.mock('@/components/settings/AgentsSettingsPanel', () => ({
49
- AgentsSettingsPanel: () => null,
50
- }));
51
-
52
- const { SettingsPage } = await import('./SettingsPage');
53
-
54
- function renderSettings(search = '') {
55
- return render(
56
- <MemoryRouter initialEntries={[`/settings${search}`]}>
57
- <SettingsPage />
58
- </MemoryRouter>,
59
- );
60
- }
61
-
62
- afterEach(() => {
63
- cleanup();
64
- save.mockClear();
65
- });
66
-
67
- describe('SettingsPage header save', () => {
68
- it('saves LLM settings from the general settings header', () => {
69
- renderSettings();
70
- fireEvent.click(screen.getByTestId('settings-header-save'));
71
- expect(save).toHaveBeenCalledTimes(1);
72
- });
73
-
74
- it('does not show the header save on skills, MCP, or agents pages', () => {
75
- const skills = renderSettings('?section=skills');
76
- expect(screen.queryByTestId('settings-header-save')).toBeNull();
77
- skills.unmount();
78
- const mcp = renderSettings('?section=mcp');
79
- expect(screen.queryByTestId('settings-header-save')).toBeNull();
80
- mcp.unmount();
81
- renderSettings('?section=agents');
82
- expect(screen.queryByTestId('settings-header-save')).toBeNull();
83
- });
84
-
85
- it('orders general sections by how often they are used', () => {
86
- renderSettings();
87
- expect(screen.getByRole('heading', { name: '帮助改进产品' })).toBeTruthy();
88
- expect(
89
- [...document.querySelectorAll('[data-testid^="settings-section-"]')].map(
90
- (el) => el.getAttribute('data-testid'),
91
- ),
92
- ).toEqual([
93
- 'settings-section-llm',
94
- 'settings-section-web-search',
95
- 'settings-section-usage',
96
- 'settings-section-diagnose',
97
- 'settings-section-security',
98
- 'settings-section-insights',
99
- 'settings-section-telemetry',
100
- ]);
101
- });
102
- });
package/vite.base.ts DELETED
@@ -1,94 +0,0 @@
1
- /**
2
- * 产品 web 构建的共享 vite 配置工厂(2.3)。
3
- *
4
- * 每个产品(products/<id>/web/)有自己的 vite 入口:index.html +
5
- * main.tsx(静态注册本产品的包渲染层贡献)+ vite.config.ts(调本工厂)。
6
- * 产品的编译单元只含自己的包——未激活包代码不进 bundle,不依赖树摇
7
- * 正确性(物理隔离与 node 侧对称)。
8
- *
9
- * Electron 加载产物时走 file:// 协议,必须用相对路径,否则资源 404。
10
- * dev server 跑在固定端口,主进程的 IS_DEV 分支 loadURL('http://localhost:5173')。
11
- */
12
- import { defineConfig } from 'vite';
13
- import react from '@vitejs/plugin-react';
14
- import tailwindcss from '@tailwindcss/vite';
15
- import path from 'node:path';
16
- import { fileURLToPath } from 'node:url';
17
- import { existsSync, readFileSync } from 'node:fs';
18
-
19
- const HERE = path.dirname(fileURLToPath(import.meta.url));
20
-
21
- export interface ProductViteConfigOptions {
22
- /** 产品目录(products/<id>/web 的上一级…即 products/<id>)。 */
23
- productDir: string;
24
- /** 产品 flavor(决定品牌 define 与激活包集合)。 */
25
- flavor: string;
26
- }
27
-
28
- export function createProductViteConfig(options: ProductViteConfigOptions) {
29
- const { productDir, flavor } = options;
30
- const repoRoot = path.resolve(productDir, '../..');
31
- // shell 渲染层源码锚到本包自身(3.2 起住在框架仓库
32
- // packages/agent-shell/web/src),产品经 `@/` 别名引用。
33
- const webSrcDir = path.resolve(HERE, 'src');
34
- const readJson = (p: string) => JSON.parse(readFileSync(p, 'utf8'));
35
-
36
- // 产品品牌(3.1):product.json 的 brand 字段优先(无包产品的品牌
37
- // 来源);否则取激活包 pack.json 的 brand(0.3g 机制,读
38
- // products/manifest.json 的 flavor→包映射,第一个带 brand 的包)。
39
- // 都没有则用 shell 中性默认(Agent Shell)。
40
- const productJsonPath = path.join(productDir, 'product.json');
41
- const product = existsSync(productJsonPath) ? readJson(productJsonPath) : {};
42
- const manifest = readJson(path.join(repoRoot, 'products/manifest.json'));
43
- let packBrand: Record<string, string> | null = null;
44
- for (const packId of manifest.flavors?.[flavor] ?? []) {
45
- const pack = readJson(path.join(repoRoot, 'packages', `pack-${packId}`, 'pack.json'));
46
- if (pack.brand) {
47
- packBrand = pack.brand;
48
- break;
49
- }
50
- }
51
- const brand = product.brand ?? packBrand;
52
-
53
- return defineConfig({
54
- // root 默认取 config 文件所在目录(products/<id>/web)。
55
- base: './',
56
- plugins: [react(), tailwindcss()],
57
- define: {
58
- // 显式 define 让 flavor 条件在构建期可静态折叠。
59
- 'import.meta.env.VITE_APP_FLAVOR': JSON.stringify(flavor),
60
- // 品牌 define:产品/包声明覆盖 shell 中性默认(Agent Shell)。
61
- // logo 不走 define——资产必须静态 import 才进 bundle,由包 web 模块
62
- // 在注册时经 setBrandLogoUrl 注入(本包 src/brand.ts)。
63
- 'import.meta.env.VITE_BRAND_NAME': JSON.stringify(brand?.displayName ?? 'Steerable Shell'),
64
- 'import.meta.env.VITE_BRAND_TAGLINE': JSON.stringify(brand?.tagline ?? '一款本地桌面 AI 伙伴'),
65
- 'import.meta.env.VITE_DEFAULT_AGENT_ID': JSON.stringify(brand?.defaultAgentId ?? 'local-assistant'),
66
- },
67
- resolve: {
68
- alias: {
69
- // shell 渲染层源码(产品入口与包 web 模块都以 `@/` 引用它)。
70
- '@': webSrcDir,
71
- },
72
- },
73
- // 静态资产(favicon 等中性默认)随 shell web 包分发;产品可在自己的
74
- // web root 放 public/ 覆盖(vite 不合并双 publicDir——需要产品级资产
75
- // 时在产品 vite.config 里显式覆盖本字段)。
76
- publicDir: path.resolve(HERE, 'public'),
77
- server: {
78
- port: 5173,
79
- strictPort: true,
80
- host: '127.0.0.1',
81
- // 产品 root 在 products/<id>/web;shell 渲染层源码在框架仓库
82
- // (3.2 起经 file: 依赖符号链接)——两个根都放行。
83
- fs: { allow: [repoRoot, path.resolve(webSrcDir, '..')] },
84
- },
85
- build: {
86
- // 产物落在产品目录:products/<id>/web/dist(打包期被 electron-builder
87
- // 映射为包内 web-dist/)。
88
- outDir: 'dist',
89
- emptyOutDir: true,
90
- sourcemap: true,
91
- target: 'chrome120',
92
- },
93
- });
94
- }