Skip to content

Commit 25d5a51

Browse files
authored
隐藏会话和提示注入设置 (#14)
1 parent 1868577 commit 25d5a51

8 files changed

Lines changed: 41 additions & 79 deletions

File tree

ui/desktop/src/components/settings/SettingsView.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ describe('SettingsView', () => {
7575

7676
expect(screen.queryByTestId('settings-local-inference-tab')).not.toBeInTheDocument();
7777
expect(screen.queryByTestId('settings-mesh-tab')).not.toBeInTheDocument();
78+
expect(screen.queryByTestId('settings-sharing-tab')).not.toBeInTheDocument();
7879
expect(screen.getByText('Models section')).toBeInTheDocument();
7980
});
8081
});

ui/desktop/src/components/settings/SettingsView.tsx

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,13 @@ import { ScrollArea } from '../ui/scroll-area';
22
import { Tabs, TabsContent, TabsList, TabsTrigger } from '../ui/tabs';
33
import { View, ViewOptions } from '../../utils/navigationUtils';
44
import ModelsSection from './models/ModelsSection';
5-
import SessionSharingSection from './sessions/SessionSharingSection';
6-
import ExternalBackendSection from './app/ExternalBackendSection';
75
import AppSettingsSection from './app/AppSettingsSection';
86
import ConfigSettings from './config/ConfigSettings';
97
import PromptsSettingsSection from './PromptsSettingsSection';
108
import { ExtensionConfig } from '../../api';
119
import { MainPanelLayout } from '../Layout/MainPanelLayout';
12-
import {
13-
Bot,
14-
Share2,
15-
Monitor,
16-
MessageSquare,
17-
FileText,
18-
Keyboard,
19-
} from 'lucide-react';
10+
import { Bot, Monitor, MessageSquare, FileText, Keyboard } from 'lucide-react';
2011
import { useState, useEffect, useRef } from 'react';
21-
import TunnelSection from './tunnel/TunnelSection';
22-
import GatewaySettingsSection from './gateways/GatewaySettingsSection';
23-
import { getTunnelStatus } from '../../api/sdk.gen';
2412
import ChatSettingsSection from './chat/ChatSettingsSection';
2513
import KeyboardShortcutsSection from './keyboard/KeyboardShortcutsSection';
2614
import { CONFIGURATION_ENABLED } from '../../updates';
@@ -40,10 +28,6 @@ const i18n = defineMessages({
4028
id: 'settingsView.tabChat',
4129
defaultMessage: 'Chat',
4230
},
43-
tabSession: {
44-
id: 'settingsView.tabSession',
45-
defaultMessage: 'Session',
46-
},
4731
tabPrompts: {
4832
id: 'settingsView.tabPrompts',
4933
defaultMessage: 'Prompts',
@@ -75,7 +59,6 @@ export default function SettingsView({
7559
viewOptions: SettingsViewOptions;
7660
}) {
7761
const [activeTab, setActiveTab] = useState('models');
78-
const [tunnelDisabled, setTunnelDisabled] = useState(false);
7962
const hasTrackedInitialTab = useRef(false);
8063
const intl = useIntl();
8164

@@ -92,14 +75,12 @@ export default function SettingsView({
9275
update: 'app',
9376
models: 'models',
9477
modes: 'chat',
95-
sharing: 'sharing',
9678
styles: 'chat',
9779
tools: 'chat',
9880
app: 'app',
9981
chat: 'chat',
10082
prompts: 'prompts',
10183
keyboard: 'keyboard',
102-
gateway: 'sharing',
10384
};
10485

10586
const targetTab = sectionToTab[viewOptions.section];
@@ -116,16 +97,6 @@ export default function SettingsView({
11697
}
11798
}, [activeTab]);
11899

119-
useEffect(() => {
120-
getTunnelStatus()
121-
.then(({ data }) => {
122-
setTunnelDisabled(data?.state === 'disabled');
123-
})
124-
.catch(() => {
125-
setTunnelDisabled(false);
126-
});
127-
}, []);
128-
129100
useEffect(() => {
130101
const handleKeyDown = (event: KeyboardEvent) => {
131102
if (event.key === 'Escape' && !event.defaultPrevented) {
@@ -172,14 +143,6 @@ export default function SettingsView({
172143
<MessageSquare className="h-4 w-4" />
173144
{intl.formatMessage(i18n.tabChat)}
174145
</TabsTrigger>
175-
<TabsTrigger
176-
value="sharing"
177-
className="flex gap-2"
178-
data-testid="settings-sharing-tab"
179-
>
180-
<Share2 className="h-4 w-4" />
181-
{intl.formatMessage(i18n.tabSession)}
182-
</TabsTrigger>
183146
<TabsTrigger
184147
value="prompts"
185148
className="flex gap-2"
@@ -218,22 +181,6 @@ export default function SettingsView({
218181
<ChatSettingsSection sessionId={viewOptions.sessionId} />
219182
</TabsContent>
220183

221-
<TabsContent
222-
value="sharing"
223-
className="mt-0 focus-visible:outline-none focus-visible:ring-0"
224-
>
225-
<div className="space-y-8 pb-8">
226-
<SessionSharingSection />
227-
<ExternalBackendSection />
228-
{!tunnelDisabled && (
229-
<div className="space-y-4">
230-
<TunnelSection />
231-
<GatewaySettingsSection />
232-
</div>
233-
)}
234-
</div>
235-
</TabsContent>
236-
237184
<TabsContent
238185
value="prompts"
239186
className="mt-0 focus-visible:outline-none focus-visible:ring-0"
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* @vitest-environment jsdom
3+
*/
4+
import { render, screen } from '@testing-library/react';
5+
import { describe, expect, it, vi } from 'vitest';
6+
import ChatSettingsSection from './ChatSettingsSection';
7+
import { IntlTestWrapper } from '../../../i18n/test-utils';
8+
9+
vi.mock('../mode/ModeSection', () => ({
10+
ModeSection: () => <div>Mode section</div>,
11+
}));
12+
13+
vi.mock('../dictation/DictationSettings', () => ({
14+
DictationSettings: () => <div>Dictation settings</div>,
15+
}));
16+
17+
vi.mock('./SpellcheckToggle', () => ({
18+
SpellcheckToggle: () => <div>Spellcheck toggle</div>,
19+
}));
20+
21+
vi.mock('../response_styles/ResponseStylesSection', () => ({
22+
ResponseStylesSection: () => <div>Response styles section</div>,
23+
}));
24+
25+
describe('ChatSettingsSection', () => {
26+
it('hides project hints and prompt injection settings from ApeCloud builds', () => {
27+
render(<ChatSettingsSection />, { wrapper: IntlTestWrapper });
28+
29+
expect(screen.getByText('Mode section')).toBeInTheDocument();
30+
expect(screen.queryByText('Project Hints (.goosehints)')).not.toBeInTheDocument();
31+
expect(screen.queryByText('Enable Prompt Injection Detection')).not.toBeInTheDocument();
32+
});
33+
});

ui/desktop/src/components/settings/chat/ChatSettingsSection.tsx

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { ModeSection } from '../mode/ModeSection';
22
import { DictationSettings } from '../dictation/DictationSettings';
3-
import { SecurityToggle } from '../security/SecurityToggle';
43
import { ResponseStylesSection } from '../response_styles/ResponseStylesSection';
5-
import { GoosehintsSection } from './GoosehintsSection';
64
import { SpellcheckToggle } from './SpellcheckToggle';
75
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '../../ui/card';
86
import { defineMessages, useIntl } from '../../../i18n';
@@ -41,12 +39,6 @@ export default function ChatSettingsSection({ sessionId }: { sessionId?: string
4139
</CardContent>
4240
</Card>
4341

44-
<Card className="pb-2 rounded-lg">
45-
<CardContent className="px-2">
46-
<GoosehintsSection />
47-
</CardContent>
48-
</Card>
49-
5042
<Card className="pb-2 rounded-lg">
5143
<CardContent className="px-2">
5244
<DictationSettings />
@@ -64,11 +56,6 @@ export default function ChatSettingsSection({ sessionId }: { sessionId?: string
6456
</CardContent>
6557
</Card>
6658

67-
<Card className="pb-2 rounded-lg">
68-
<CardContent className="px-2">
69-
<SecurityToggle />
70-
</CardContent>
71-
</Card>
7259
</div>
7360
);
7461
}

ui/desktop/src/components/settings/chat/GoosehintsModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const i18n = defineMessages({
2525
helpText1: {
2626
id: 'goosehintsModal.helpText1',
2727
defaultMessage:
28-
'.goosehints is a text file used to provide additional context about your project and improve the communication with Goose.',
28+
'.goosehints is a text file used to provide additional context about your project and improve the communication with ApeMind.',
2929
},
3030
helpText2: {
3131
id: 'goosehintsModal.helpText2',

ui/desktop/src/components/settings/chat/GoosehintsSection.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const i18n = defineMessages({
1212
description: {
1313
id: 'goosehintsSection.description',
1414
defaultMessage:
15-
"Configure your project's .goosehints file to provide additional context to Goose",
15+
"Configure your project's .goosehints file to provide additional context to ApeMind",
1616
},
1717
configure: {
1818
id: 'goosehintsSection.configure',

ui/desktop/src/i18n/messages/en.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1353,7 +1353,7 @@
13531353
"defaultMessage": ".goosehints file found at: {filePath}"
13541354
},
13551355
"goosehintsModal.helpText1": {
1356-
"defaultMessage": ".goosehints is a text file used to provide additional context about your project and improve the communication with Goose."
1356+
"defaultMessage": ".goosehints is a text file used to provide additional context about your project and improve the communication with ApeMind."
13571357
},
13581358
"goosehintsModal.helpText2": {
13591359
"defaultMessage": "Please make sure {bold} extension is enabled in the extensions page. This extension is required to use .goosehints. You'll need to restart your session for .goosehints updates to take effect."
@@ -1380,7 +1380,7 @@
13801380
"defaultMessage": "Configure"
13811381
},
13821382
"goosehintsSection.description": {
1383-
"defaultMessage": "Configure your project's .goosehints file to provide additional context to Goose"
1383+
"defaultMessage": "Configure your project's .goosehints file to provide additional context to ApeMind"
13841384
},
13851385
"goosehintsSection.title": {
13861386
"defaultMessage": "Project Hints (.goosehints)"
@@ -4184,9 +4184,6 @@
41844184
"settingsView.tabPrompts": {
41854185
"defaultMessage": "Prompts"
41864186
},
4187-
"settingsView.tabSession": {
4188-
"defaultMessage": "Session"
4189-
},
41904187
"settingsView.title": {
41914188
"defaultMessage": "Settings"
41924189
},

ui/desktop/src/i18n/messages/zh-CN.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,7 +1302,7 @@
13021302
"defaultMessage": "已找到 .goosehints 文件:{filePath}"
13031303
},
13041304
"goosehintsModal.helpText1": {
1305-
"defaultMessage": ".goosehints 是一个文本文件,用于为你的项目提供额外上下文,改善与 Goose 的沟通。"
1305+
"defaultMessage": ".goosehints 是一个文本文件,用于为你的项目提供额外上下文,改善与 ApeMind 的沟通。"
13061306
},
13071307
"goosehintsModal.helpText2": {
13081308
"defaultMessage": "请确认已在扩展页面启用 {bold} 扩展。此扩展是使用 .goosehints 所必需的。你需要重启会话,.goosehints 的更新才会生效。"
@@ -1329,7 +1329,7 @@
13291329
"defaultMessage": "配置"
13301330
},
13311331
"goosehintsSection.description": {
1332-
"defaultMessage": "配置项目的 .goosehints 文件,为 Goose 提供额外上下文"
1332+
"defaultMessage": "配置项目的 .goosehints 文件,为 ApeMind 提供额外上下文"
13331333
},
13341334
"goosehintsSection.title": {
13351335
"defaultMessage": "项目提示(.goosehints)"
@@ -4097,9 +4097,6 @@
40974097
"settingsView.tabPrompts": {
40984098
"defaultMessage": "提示词"
40994099
},
4100-
"settingsView.tabSession": {
4101-
"defaultMessage": "会话"
4102-
},
41034100
"settingsView.title": {
41044101
"defaultMessage": "设置"
41054102
},

0 commit comments

Comments
 (0)