@dyyz1993/create-agent 2.0.0 → 2.1.0
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.
- package/package.json +1 -1
- package/src/commands/create.ts +31 -31
- package/src/commands/workspace.ts +112 -105
- package/src/lib/copy.ts +24 -1
- package/templates/agent/electron/main.js +46 -0
- package/templates/agent/electron/preload.js +5 -0
- package/templates/agent/electron-builder.json +40 -0
- package/templates/agent/eslint.config.mjs +17 -2
- package/templates/agent/package.json +69 -3
- package/templates/agent/src/__tests__/hybrid-mode.test.ts +126 -0
- package/templates/agent/src/__tests__/server-config-security.test.ts +55 -0
- package/templates/agent/src/bun/index.ts +96 -41
- package/templates/agent/src/bun/three.d.ts +1 -0
- package/templates/agent/src/gateway/__tests__/ws-handler-token.test.ts +118 -0
- package/templates/agent/src/gateway/http-routes.ts +1 -1
- package/templates/agent/src/gateway/ws-handler.ts +84 -56
- package/templates/agent/src/mainview/App.tsx +29 -26
- package/templates/agent/src/mainview/__tests__/i18n/i18n.test.ts +1 -0
- package/templates/agent/src/mainview/__tests__/setup.ts +32 -29
- package/templates/agent/src/mainview/__tests__/theme-variables.test.ts +36 -0
- package/templates/agent/src/mainview/components/chat/ChatPanel.tsx +88 -88
- package/templates/agent/src/mainview/components/common/ErrorBoundary.tsx +1 -58
- package/templates/agent/src/mainview/components/common/LanguageSwitcher.tsx +1 -0
- package/templates/agent/src/mainview/components/common/ThemeToggle.tsx +1 -0
- package/templates/agent/src/mainview/components/feed/FeedPanel.tsx +232 -210
- package/templates/agent/src/mainview/components/file-preview/VirtualizedCodeView.tsx +105 -81
- package/templates/agent/src/mainview/components/search/SearchPanel.tsx +427 -378
- package/templates/agent/src/mainview/components/todo/TodoPanel.tsx +149 -122
- package/templates/agent/src/mainview/hooks/use-input-history.ts +70 -61
- package/templates/agent/src/mainview/lib/api-client.ts +179 -172
- package/templates/agent/src/mainview/main.tsx +4 -10
- package/templates/agent/src/mainview/stores/use-feed-store.ts +107 -107
- package/templates/agent/src/mainview/utils/drop-handler.ts +114 -115
- package/templates/agent/src/server-config.ts +34 -32
- package/templates/agent/src/server.ts +42 -54
- package/templates/agent/src/shared/handlers/__tests__/chat-concurrency.test.ts +127 -0
- package/templates/agent/src/shared/handlers/__tests__/handler-isolation.test.ts +244 -0
- package/templates/agent/src/shared/handlers/bash.ts +65 -65
- package/templates/agent/src/shared/handlers/chat.ts +189 -155
- package/templates/agent/src/shared/handlers/debug.ts +12 -0
- package/templates/agent/src/shared/handlers/feed.ts +31 -32
- package/templates/agent/src/shared/handlers/git.ts +286 -243
- package/templates/agent/src/shared/handlers/index.ts +1 -0
- package/templates/agent/src/shared/handlers/rules.ts +31 -31
- package/templates/agent/src/shared/handlers/todo.ts +31 -31
- package/templates/agent/src/shared/http-routes.ts +250 -0
- package/templates/agent/src/shared/lib/__tests__/web-server.test.ts +190 -0
- package/templates/agent/src/shared/lib/bash-security.ts +43 -43
- package/templates/agent/src/shared/lib/logger.ts +117 -95
- package/templates/agent/src/shared/lib/web-server.ts +128 -0
- package/templates/agent/src/shared/modules/debug.ts +8 -0
- package/templates/agent/src/shared/rpc-schema.ts +16 -3
- package/templates/agent/test-upload.txt +0 -0
- package/templates/agent/tsconfig.ipc.json +14 -0
- package/templates/agent/tsconfig.json +13 -3
- package/templates/chat/eslint.config.mjs +15 -2
- package/templates/chat/package.json +13 -2
- package/templates/chat/src/__tests__/hybrid-mode.test.ts +125 -0
- package/templates/chat/src/__tests__/server-config-security.test.ts +55 -0
- package/templates/chat/src/__tests__/server-config.test.ts +46 -44
- package/templates/chat/src/bun/index.ts +94 -44
- package/templates/chat/src/bun/three.d.ts +1 -0
- package/templates/chat/src/gateway/http-routes.ts +1 -1
- package/templates/chat/src/gateway/ws-handler.ts +84 -56
- package/templates/chat/src/mainview/App.tsx +6 -0
- package/templates/chat/src/mainview/__tests__/i18n/i18n.test.ts +1 -0
- package/templates/chat/src/mainview/__tests__/theme-variables.test.ts +36 -0
- package/templates/chat/src/mainview/components/common/LanguageSwitcher.tsx +1 -0
- package/templates/chat/src/mainview/components/common/ThemeToggle.tsx +1 -0
- package/templates/chat/src/mainview/hooks/use-input-history.ts +70 -61
- package/templates/chat/src/mainview/lib/api-client.ts +180 -156
- package/templates/chat/src/mainview/lib/rpc-cache.ts +84 -0
- package/templates/chat/src/mainview/main.tsx +10 -6
- package/templates/chat/src/server-config.ts +33 -31
- package/templates/chat/src/server.ts +42 -60
- package/templates/chat/src/shared/handlers/chat.ts +196 -162
- package/templates/chat/src/shared/handlers/debug.ts +12 -0
- package/templates/chat/src/shared/handlers/index.ts +1 -0
- package/templates/chat/src/shared/http-routes.ts +250 -0
- package/templates/chat/src/shared/lib/__tests__/logger.test.ts +92 -0
- package/templates/chat/src/shared/lib/logger.ts +108 -95
- package/templates/chat/src/shared/lib/web-server.ts +128 -0
- package/templates/chat/src/shared/modules/debug.ts +8 -0
- package/templates/chat/src/shared/rpc-schema.ts +3 -2
- package/templates/chat/test-upload.txt +0 -0
- package/templates/chat/tsconfig.ipc.json +14 -0
- package/templates/chat/tsconfig.json +12 -2
- package/templates/general/eslint.config.mjs +15 -2
- package/templates/general/package.json +13 -2
- package/templates/general/src/__tests__/hybrid-mode.test.ts +125 -0
- package/templates/general/src/__tests__/server-config-security.test.ts +55 -0
- package/templates/general/src/__tests__/server-config.test.ts +46 -44
- package/templates/general/src/bun/index.ts +94 -44
- package/templates/general/src/bun/three.d.ts +1 -0
- package/templates/general/src/gateway/http-routes.ts +1 -1
- package/templates/general/src/gateway/ws-handler.ts +84 -56
- package/templates/general/src/mainview/__tests__/i18n/i18n.test.ts +1 -0
- package/templates/general/src/mainview/__tests__/theme-variables.test.ts +36 -0
- package/templates/general/src/mainview/components/common/LanguageSwitcher.tsx +1 -0
- package/templates/general/src/mainview/components/common/ThemeToggle.tsx +1 -0
- package/templates/general/src/mainview/components/feed/FeedPanel.tsx +241 -219
- package/templates/general/src/mainview/components/file-preview/VirtualizedCodeView.tsx +101 -81
- package/templates/general/src/mainview/components/layout/AppLayout.tsx +6 -0
- package/templates/general/src/mainview/components/search/SearchPanel.tsx +429 -378
- package/templates/general/src/mainview/hooks/use-input-history.ts +70 -61
- package/templates/general/src/mainview/lib/api-client.ts +180 -156
- package/templates/general/src/mainview/lib/rpc-cache.ts +84 -0
- package/templates/general/src/mainview/main.tsx +10 -6
- package/templates/general/src/mainview/stores/use-feed-store.ts +107 -107
- package/templates/general/src/mainview/utils/drop-handler.ts +114 -115
- package/templates/general/src/server-config.ts +33 -31
- package/templates/general/src/server.ts +42 -60
- package/templates/general/src/shared/handlers/__tests__/chat.test.ts +165 -160
- package/templates/general/src/shared/handlers/chat.ts +189 -155
- package/templates/general/src/shared/handlers/debug.ts +12 -0
- package/templates/general/src/shared/handlers/feed.ts +38 -40
- package/templates/general/src/shared/handlers/git.ts +286 -243
- package/templates/general/src/shared/handlers/index.ts +1 -0
- package/templates/general/src/shared/http-routes.ts +250 -0
- package/templates/general/src/shared/lib/__tests__/logger.test.ts +92 -0
- package/templates/general/src/shared/lib/logger.ts +117 -95
- package/templates/general/src/shared/lib/web-server.ts +128 -0
- package/templates/general/src/shared/modules/debug.ts +8 -0
- package/templates/general/src/shared/rpc-schema.ts +12 -2
- package/templates/general/test-upload.txt +0 -0
- package/templates/general/tsconfig.ipc.json +14 -0
- package/templates/general/tsconfig.json +12 -2
- package/templates/shared/__tests__/cors-security.test.ts +165 -0
- package/templates/shared/__tests__/file-path-security.test.ts +260 -0
- package/templates/shared/__tests__/http-routes.test.ts +174 -0
- package/templates/shared/__tests__/logger.test.ts +186 -0
- package/templates/shared/components/ErrorBoundary.tsx +59 -0
- package/templates/shared/env.d.ts +11 -0
- package/templates/shared/http-routes.ts +250 -0
- package/templates/shared/logger.ts +129 -0
- package/templates/shared/test-upload.txt +0 -0
- package/templates/shared/vite-base.config.ts +92 -0
- package/templates/shared/vitest-base.config.ts +42 -0
- package/templates/agent/eslint-plugin-rpc/index.js +0 -50
- package/templates/agent/eslint-plugin-rpc/package.json +0 -6
- package/templates/agent/eslint-plugin-rpc/rules/module-file-naming.js +0 -99
- package/templates/agent/eslint-plugin-rpc/rules/no-bare-method.js +0 -78
- package/templates/agent/eslint-plugin-rpc/rules/no-direct-register.js +0 -65
- package/templates/agent/eslint-plugin-rpc/rules/no-hardcoded-strings.js +0 -69
- package/templates/agent/eslint-plugin-rpc/rules/require-api-client.js +0 -58
- package/templates/agent/eslint-plugin-rpc/rules/require-typed-register.js +0 -78
- package/templates/agent/eslint-plugin-rpc/rules/schema-merge-only.js +0 -55
- package/templates/chat/eslint-plugin-rpc/index.js +0 -50
- package/templates/chat/eslint-plugin-rpc/package.json +0 -6
- package/templates/chat/eslint-plugin-rpc/rules/module-file-naming.js +0 -99
- package/templates/chat/eslint-plugin-rpc/rules/no-bare-method.js +0 -78
- package/templates/chat/eslint-plugin-rpc/rules/no-direct-register.js +0 -65
- package/templates/chat/eslint-plugin-rpc/rules/no-hardcoded-strings.js +0 -69
- package/templates/chat/eslint-plugin-rpc/rules/require-api-client.js +0 -58
- package/templates/chat/eslint-plugin-rpc/rules/require-typed-register.js +0 -78
- package/templates/chat/eslint-plugin-rpc/rules/schema-merge-only.js +0 -55
- package/templates/general/eslint-plugin-rpc/index.js +0 -50
- package/templates/general/eslint-plugin-rpc/package.json +0 -6
- package/templates/general/eslint-plugin-rpc/rules/module-file-naming.js +0 -99
- package/templates/general/eslint-plugin-rpc/rules/no-bare-method.js +0 -78
- package/templates/general/eslint-plugin-rpc/rules/no-direct-register.js +0 -65
- package/templates/general/eslint-plugin-rpc/rules/no-hardcoded-strings.js +0 -69
- package/templates/general/eslint-plugin-rpc/rules/require-api-client.js +0 -58
- package/templates/general/eslint-plugin-rpc/rules/require-typed-register.js +0 -78
- package/templates/general/eslint-plugin-rpc/rules/schema-merge-only.js +0 -55
|
@@ -5,235 +5,257 @@ import { apiClient } from "../../lib/api-client";
|
|
|
5
5
|
import { useLogStore } from "../../stores/use-log-store";
|
|
6
6
|
import { useConnectionStore } from "../../stores/use-connection-store";
|
|
7
7
|
import { useFeedStore, useEventStreamStore, type SubEventType } from "../../stores/use-feed-store";
|
|
8
|
-
import type { FeedCategory } from "
|
|
8
|
+
import type { FeedCategory } from "@shared/modules/feed";
|
|
9
9
|
|
|
10
10
|
const CATEGORIES: FeedCategory[] = ["tech", "news", "general"];
|
|
11
11
|
const EVENT_TYPES: SubEventType[] = ["feed.update", "chat.message", "timer.tick"];
|
|
12
12
|
const FILTER_PRESETS: Record<SubEventType, string[]> = {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
"feed.update": ["", '{"category":"tech"}', '{"category":"news"}', '{"author":"alice"}'],
|
|
14
|
+
"chat.message": ["", '{"role":"user"}', '{"role":"assistant"}'],
|
|
15
|
+
"timer.tick": ["", '{"channel":"default"}'],
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
const CATEGORY_COLORS: Record<FeedCategory, string> = {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
tech: "bg-blue-600/30 text-blue-300",
|
|
20
|
+
news: "bg-amber-600/30 text-amber-300",
|
|
21
|
+
general: "bg-green-600/30 text-green-300",
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
export function FeedPanel() {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
25
|
+
const { t } = useTranslation();
|
|
26
|
+
const posts = useFeedStore((s) => s.posts);
|
|
27
|
+
const author = useFeedStore((s) => s.author);
|
|
28
|
+
const category = useFeedStore((s) => s.category);
|
|
29
|
+
const content = useFeedStore((s) => s.content);
|
|
30
|
+
const loading = useFeedStore((s) => s.loading);
|
|
31
|
+
const setAuthor = useFeedStore((s) => s.setAuthor);
|
|
32
|
+
const setCategory = useFeedStore((s) => s.setCategory);
|
|
33
|
+
const setContent = useFeedStore((s) => s.setContent);
|
|
34
|
+
const createPost = useFeedStore((s) => s.createPost);
|
|
35
|
+
const loadPosts = useFeedStore((s) => s.loadPosts);
|
|
36
|
+
const addPost = useFeedStore((s) => s.addPost);
|
|
37
|
+
const addLog = useLogStore((s) => s.addLog);
|
|
38
|
+
const ready = useConnectionStore((s) => s.ready);
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
40
|
+
const entries = useEventStreamStore((s) => s.entries);
|
|
41
|
+
const activeEventType = useEventStreamStore((s) => s.activeEventType);
|
|
42
|
+
const activeFilter = useEventStreamStore((s) => s.activeFilter);
|
|
43
|
+
const subscribed = useEventStreamStore((s) => s.subscribed);
|
|
44
|
+
const setActiveEventType = useEventStreamStore((s) => s.setActiveEventType);
|
|
45
|
+
const setActiveFilter = useEventStreamStore((s) => s.setActiveFilter);
|
|
46
|
+
const handleSubscribe = useEventStreamStore((s) => s.handleSubscribe);
|
|
47
|
+
const handleUnsubscribe = useEventStreamStore((s) => s.handleUnsubscribe);
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
if (!ready) return;
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
let subId: string | null = null;
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
const setup = async () => {
|
|
55
|
+
subId = await apiClient.subscribe(
|
|
56
|
+
"feed.update",
|
|
57
|
+
(payload) => {
|
|
58
|
+
addPost(payload as (typeof posts)[number]);
|
|
59
|
+
},
|
|
60
|
+
{}
|
|
61
|
+
);
|
|
62
|
+
addLog("Subscribed to feed.update (no filter)");
|
|
59
63
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
64
|
+
await loadPosts();
|
|
65
|
+
};
|
|
66
|
+
setup();
|
|
63
67
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
+
return () => {
|
|
69
|
+
if (subId) apiClient.unsubscribe(subId);
|
|
70
|
+
};
|
|
71
|
+
}, [ready, addLog, loadPosts, addPost]);
|
|
68
72
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
73
|
+
return (
|
|
74
|
+
<div className="flex-1 flex flex-col overflow-hidden">
|
|
75
|
+
<div className="px-4 py-2 bg-[var(--color-bg-secondary)] border-b border-[var(--color-border-primary)] flex items-center justify-between flex-shrink-0">
|
|
76
|
+
<h2 className="text-sm font-semibold flex items-center gap-1.5">
|
|
77
|
+
<Rss className="w-4 h-4 text-[var(--color-text-accent)]" />
|
|
78
|
+
{t("feed.title")}
|
|
79
|
+
{posts.length > 0 && (
|
|
80
|
+
<span className="ml-1 px-2 py-0.5 bg-[var(--color-accent)]/30 text-[var(--color-text-accent)] rounded text-[10px]">
|
|
81
|
+
{posts.length}
|
|
82
|
+
</span>
|
|
83
|
+
)}
|
|
84
|
+
</h2>
|
|
85
|
+
</div>
|
|
82
86
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
87
|
+
<div className="flex-1 overflow-y-auto p-4 space-y-4">
|
|
88
|
+
<div className="bg-[var(--color-bg-secondary)] rounded-lg p-3 space-y-2">
|
|
89
|
+
<div className="text-xs font-semibold text-[var(--color-text-tertiary)] uppercase tracking-wider">
|
|
90
|
+
{t("feed.newPost")}
|
|
91
|
+
</div>
|
|
92
|
+
<div className="flex gap-2">
|
|
93
|
+
<input
|
|
94
|
+
type="text"
|
|
95
|
+
value={author}
|
|
96
|
+
onChange={(e) => setAuthor(e.target.value)}
|
|
97
|
+
placeholder={t("feed.authorPlaceholder")}
|
|
98
|
+
className="w-24 px-2 py-1.5 text-xs bg-[var(--color-bg-tertiary)] rounded text-[var(--color-text-primary)] border border-[var(--color-border-secondary)] focus:border-[var(--color-accent)] focus:outline-none"
|
|
99
|
+
/>
|
|
100
|
+
<select
|
|
101
|
+
value={category}
|
|
102
|
+
onChange={(e) => setCategory(e.target.value as FeedCategory)}
|
|
103
|
+
className="px-2 py-1.5 text-xs bg-[var(--color-bg-tertiary)] rounded text-[var(--color-text-primary)] border border-[var(--color-border-secondary)]"
|
|
104
|
+
>
|
|
105
|
+
{CATEGORIES.map((c) => (
|
|
106
|
+
<option key={c} value={c}>
|
|
107
|
+
{c}
|
|
108
|
+
</option>
|
|
109
|
+
))}
|
|
110
|
+
</select>
|
|
111
|
+
</div>
|
|
112
|
+
<div className="flex gap-2">
|
|
113
|
+
<input
|
|
114
|
+
type="text"
|
|
115
|
+
value={content}
|
|
116
|
+
onChange={(e) => setContent(e.target.value)}
|
|
117
|
+
onKeyDown={(e) => e.key === "Enter" && !e.shiftKey && createPost()}
|
|
118
|
+
placeholder={t("feed.postPlaceholder")}
|
|
119
|
+
className="flex-1 px-3 py-1.5 text-xs bg-[var(--color-bg-tertiary)] rounded text-[var(--color-text-primary)] border border-[var(--color-border-secondary)] focus:border-[var(--color-accent)] focus:outline-none"
|
|
120
|
+
/>
|
|
121
|
+
<button
|
|
122
|
+
onClick={createPost}
|
|
123
|
+
disabled={loading || !content.trim()}
|
|
124
|
+
className="px-3 py-1.5 text-xs bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] disabled:opacity-50 rounded transition-colors flex items-center gap-1"
|
|
125
|
+
>
|
|
126
|
+
<Send className="w-3 h-3" />
|
|
127
|
+
{t("feed.post")}
|
|
128
|
+
</button>
|
|
129
|
+
</div>
|
|
130
|
+
</div>
|
|
123
131
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
132
|
+
<div className="bg-[var(--color-bg-secondary)] rounded-lg p-3 space-y-2">
|
|
133
|
+
<div className="text-xs font-semibold text-[var(--color-text-tertiary)] uppercase tracking-wider">
|
|
134
|
+
{t("feed.subscribeWithFilter")}
|
|
135
|
+
</div>
|
|
136
|
+
<div className="flex gap-2 items-center">
|
|
137
|
+
<select
|
|
138
|
+
value={activeEventType}
|
|
139
|
+
onChange={(e) => {
|
|
140
|
+
setActiveEventType(e.target.value as SubEventType);
|
|
141
|
+
setActiveFilter("");
|
|
142
|
+
}}
|
|
143
|
+
className="px-2 py-1.5 text-xs bg-[var(--color-bg-tertiary)] rounded text-[var(--color-text-primary)] border border-[var(--color-border-secondary)]"
|
|
144
|
+
>
|
|
145
|
+
{EVENT_TYPES.map((et) => (
|
|
146
|
+
<option key={et} value={et}>
|
|
147
|
+
{et}
|
|
148
|
+
</option>
|
|
149
|
+
))}
|
|
150
|
+
</select>
|
|
151
|
+
<input
|
|
152
|
+
type="text"
|
|
153
|
+
value={activeFilter}
|
|
154
|
+
onChange={(e) => setActiveFilter(e.target.value)}
|
|
155
|
+
placeholder={t("feed.filterPlaceholder")}
|
|
156
|
+
className="flex-1 px-2 py-1.5 text-xs bg-[var(--color-bg-tertiary)] rounded text-[var(--color-text-primary)] border border-[var(--color-border-secondary)] focus:border-[var(--color-accent)] focus:outline-none font-mono"
|
|
157
|
+
/>
|
|
158
|
+
{!subscribed ? (
|
|
159
|
+
<button
|
|
160
|
+
onClick={handleSubscribe}
|
|
161
|
+
className="px-3 py-1.5 text-xs bg-green-600 hover:bg-green-700 rounded transition-colors whitespace-nowrap"
|
|
162
|
+
>
|
|
163
|
+
{t("feed.subscribe")}
|
|
164
|
+
</button>
|
|
165
|
+
) : (
|
|
166
|
+
<button
|
|
167
|
+
onClick={handleUnsubscribe}
|
|
168
|
+
className="px-3 py-1.5 text-xs bg-red-600 hover:bg-red-700 rounded transition-colors whitespace-nowrap"
|
|
169
|
+
>
|
|
170
|
+
{t("feed.unsubscribe")}
|
|
171
|
+
</button>
|
|
172
|
+
)}
|
|
173
|
+
</div>
|
|
174
|
+
<div className="flex gap-1 flex-wrap">
|
|
175
|
+
{FILTER_PRESETS[activeEventType].map((preset) => (
|
|
176
|
+
<button
|
|
177
|
+
key={preset}
|
|
178
|
+
onClick={() => setActiveFilter(preset)}
|
|
179
|
+
className={`px-2 py-0.5 text-[10px] rounded border transition-colors ${
|
|
180
|
+
activeFilter === preset
|
|
181
|
+
? "border-[var(--color-accent)] bg-[var(--color-accent)]/30 text-[var(--color-text-accent)]"
|
|
182
|
+
: "border-[var(--color-border-secondary)] text-[var(--color-text-tertiary)] hover:text-[var(--color-text-secondary)]"
|
|
183
|
+
}`}
|
|
184
|
+
>
|
|
185
|
+
{preset || t("feed.noFilter")}
|
|
186
|
+
</button>
|
|
187
|
+
))}
|
|
188
|
+
</div>
|
|
189
|
+
</div>
|
|
178
190
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
191
|
+
{entries.length > 0 && (
|
|
192
|
+
<div className="bg-[var(--color-bg-secondary)] rounded-lg p-3 space-y-2">
|
|
193
|
+
<div className="flex items-center justify-between">
|
|
194
|
+
<div className="text-xs font-semibold text-[var(--color-text-tertiary)] uppercase tracking-wider">
|
|
195
|
+
{t("feed.eventStream")}
|
|
196
|
+
</div>
|
|
197
|
+
{subscribed && (
|
|
198
|
+
<span className="px-1.5 py-0.5 bg-green-600/30 text-green-400 rounded text-[10px] animate-pulse">
|
|
199
|
+
{t("feed.live")}
|
|
200
|
+
</span>
|
|
201
|
+
)}
|
|
202
|
+
</div>
|
|
203
|
+
<div className="max-h-48 overflow-y-auto space-y-1">
|
|
204
|
+
{entries.slice(-20).map((entry) => (
|
|
205
|
+
<div
|
|
206
|
+
key={entry.id}
|
|
207
|
+
className="bg-[var(--color-bg-tertiary)] rounded px-2 py-1.5 text-[11px] font-mono"
|
|
208
|
+
>
|
|
209
|
+
<div className="flex items-center gap-2 text-[var(--color-text-tertiary)]">
|
|
210
|
+
<span className="text-[var(--color-text-accent)]">{entry.eventType}</span>
|
|
211
|
+
<span className="text-[10px]">
|
|
212
|
+
{Object.keys(entry.filter).length > 0
|
|
213
|
+
? `filter: ${JSON.stringify(entry.filter)}`
|
|
214
|
+
: t("feed.noFilter")}
|
|
215
|
+
</span>
|
|
216
|
+
<span className="text-[10px] ml-auto">
|
|
217
|
+
{new Date(entry.timestamp).toLocaleTimeString()}
|
|
218
|
+
</span>
|
|
219
|
+
</div>
|
|
220
|
+
<pre className="text-cyan-300 mt-0.5 whitespace-pre-wrap break-all">
|
|
221
|
+
{JSON.stringify(entry.payload, null, 0)}
|
|
222
|
+
</pre>
|
|
223
|
+
</div>
|
|
224
|
+
))}
|
|
225
|
+
</div>
|
|
226
|
+
</div>
|
|
227
|
+
)}
|
|
213
228
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
229
|
+
{posts.length === 0 ? (
|
|
230
|
+
<div className="flex items-center justify-center py-8 text-[var(--color-text-placeholder)] text-xs">
|
|
231
|
+
{t("feed.noPostsYet")}
|
|
232
|
+
</div>
|
|
233
|
+
) : (
|
|
234
|
+
<div className="space-y-2">
|
|
235
|
+
{posts
|
|
236
|
+
.slice()
|
|
237
|
+
.reverse()
|
|
238
|
+
.map((post) => (
|
|
239
|
+
<div key={post.id} className="bg-[var(--color-bg-secondary)] rounded-lg p-3">
|
|
240
|
+
<div className="flex items-center gap-2 mb-1">
|
|
241
|
+
<span className="text-xs font-medium text-[var(--color-text-primary)]">
|
|
242
|
+
{post.author}
|
|
243
|
+
</span>
|
|
244
|
+
<span
|
|
245
|
+
className={`px-1.5 py-0.5 rounded text-[10px] ${CATEGORY_COLORS[post.category]}`}
|
|
246
|
+
>
|
|
247
|
+
{post.category}
|
|
248
|
+
</span>
|
|
249
|
+
<span className="text-[10px] text-[var(--color-text-placeholder)] ml-auto">
|
|
250
|
+
{new Date(post.timestamp).toLocaleTimeString()}
|
|
251
|
+
</span>
|
|
252
|
+
</div>
|
|
253
|
+
<div className="text-xs text-[var(--color-text-secondary)]">{post.content}</div>
|
|
254
|
+
</div>
|
|
255
|
+
))}
|
|
256
|
+
</div>
|
|
257
|
+
)}
|
|
258
|
+
</div>
|
|
259
|
+
</div>
|
|
260
|
+
);
|
|
239
261
|
}
|