mirror of
https://github.com/RuoJi6/ARTEX.git
synced 2026-11-13 06:03:49 +08:00
fix: finding agent chat tests and IME enter
Test: (cd web && node --test src/lib/finding-agent-chat.test.cjs) Build: ARTEX_SKIP_NPM_CI=1 ./build.sh
This commit is contained in:
1 parent
8f9d981bdc
commit
69eab0c033
3 files changed
+17
-7
No files matched your search
@@ -14,6 +14,7 @@ import { ScrollArea } from "@/components/ui/scroll-area";
|
||||
import { Sheet, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle } from "@/components/ui/sheet";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import { api, openSSE } from "@/lib/api";
|
||||
import { shouldSubmitOnKey, useChatSendMode } from "@/lib/chat-send-mode";
|
||||
import type { Activity, Finding } from "@/lib/types";
|
||||
|
||||
import {
|
||||
@@ -69,6 +70,7 @@ export function FindingAgentChatDrawer({ finding }: FindingAgentChatDrawerProps)
|
||||
const [sending, setSending] = React.useState(false);
|
||||
const [running, setRunning] = React.useState(false);
|
||||
const [stopping, setStopping] = React.useState(false);
|
||||
const sendMode = useChatSendMode();
|
||||
const [taskAvailable, setTaskAvailable] = React.useState<boolean | null>(null);
|
||||
const [unavailableReason, setUnavailableReason] = React.useState("");
|
||||
const eventSourceRef = React.useRef<EventSource | null>(null);
|
||||
@@ -250,10 +252,9 @@ export function FindingAgentChatDrawer({ finding }: FindingAgentChatDrawerProps)
|
||||
value={input}
|
||||
onChange={(event) => setInput(event.target.value)}
|
||||
onKeyDown={(event) => {
|
||||
if (event.key === "Enter" && !event.shiftKey) {
|
||||
event.preventDefault();
|
||||
void send();
|
||||
}
|
||||
if (!shouldSubmitOnKey(event, sendMode)) return;
|
||||
event.preventDefault();
|
||||
void send();
|
||||
}}
|
||||
disabled={!canAskFindingAgent(finding) || taskAvailable !== true || sending || running}
|
||||
placeholder={running ? "主 Agent 正在运行…" : "描述复现现象或继续提问…"}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { mentionToken } from "@/lib/chat-mentions";
|
||||
import type { Finding } from "@/lib/types";
|
||||
import { mentionToken } from "../lib/chat-mentions";
|
||||
import type { Finding } from "../lib/types";
|
||||
|
||||
type FindingContextFields = Finding & {
|
||||
url?: string;
|
||||
|
||||
@@ -1,10 +1,19 @@
|
||||
const assert = require("node:assert/strict");
|
||||
const { createRequire } = require("node:module");
|
||||
const test = require("node:test");
|
||||
|
||||
// Keep the tests runnable on Node 20, which does not load TypeScript natively.
|
||||
const requireFromTest = createRequire(__filename);
|
||||
requireFromTest("ts-node").register({
|
||||
transpileOnly: true,
|
||||
compilerOptions: { module: "CommonJS", moduleResolution: "Node10" },
|
||||
});
|
||||
|
||||
const {
|
||||
buildFindingAgentContextMessage,
|
||||
canAskFindingAgent,
|
||||
findingAgentUnavailableReason,
|
||||
} = require("../components/finding-agent-chat.ts");
|
||||
} = requireFromTest("../components/finding-agent-chat.ts");
|
||||
|
||||
const finding = (overrides = {}) => ({
|
||||
id: "42",
|
||||
|
||||
Reference in new issue
Block a user