-
Notifications
You must be signed in to change notification settings - Fork 1
fix(): refine activity plan with serviceflow #495
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ import React, { | |
| Fragment, | ||
| useContext, | ||
| useMemo, | ||
| useRef, | ||
| useState, | ||
| } from "react"; | ||
| import { initializeI18n } from "@next-core/i18n"; | ||
|
|
@@ -40,6 +41,7 @@ export function ActivityPlan({ task }: ActivityPlanProps) { | |
| const { flowMap, setActiveDetail } = useContext(TaskContext); | ||
| const { toggleAutoScroll } = useContext(StreamContext); | ||
| const flow = flowMap?.get(task.id); | ||
| const toggleRef = useRef<ReturnType<typeof setTimeout> | null>(null); | ||
|
|
||
| return ( | ||
| <ActivityPlanContext.Provider value={{ collapsed }}> | ||
|
|
@@ -71,6 +73,12 @@ export function ActivityPlan({ task }: ActivityPlanProps) { | |
| onClick={() => { | ||
| setCollapsed((prev) => !prev); | ||
| toggleAutoScroll(false); | ||
| if (toggleRef.current) { | ||
| clearTimeout(toggleRef.current); | ||
| } | ||
| toggleRef.current = setTimeout(() => { | ||
| toggleAutoScroll(true); | ||
| }, 100); | ||
| }} | ||
|
Comment on lines
73
to
82
|
||
| > | ||
| {t(K.SHOW_PROCESS)} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import { i18n } from "@next-core/i18n"; | ||
|
|
||
| export enum K { | ||
| ASK_USER_TIPS = "ASK_USER_TIPS", | ||
| } | ||
|
|
||
| const en: Locale = { | ||
| [K.ASK_USER_TIPS]: | ||
| "Elevo will continue after the activity 【{{ name }}】 provides additional information.", | ||
| }; | ||
|
|
||
| const zh: Locale = { | ||
| [K.ASK_USER_TIPS]: "Elevo将会在活动【{{ name }}】补充信息后继续执行。", | ||
| }; | ||
|
|
||
| export const NS = "bricks/ai-portal/AskUser"; | ||
|
|
||
| export const locales = { en, zh }; | ||
|
|
||
| export const t = i18n.getFixedT(null, NS); | ||
|
|
||
| type Locale = { [k in K]: string } & { | ||
| [k in K as `${k}_plural`]?: string; | ||
| }; |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,11 +1,18 @@ | ||||||||||||||||||||||||||||||||||
| import React, { useCallback, useContext, useEffect, useState } from "react"; | ||||||||||||||||||||||||||||||||||
| import React, { | ||||||||||||||||||||||||||||||||||
| useCallback, | ||||||||||||||||||||||||||||||||||
| useContext, | ||||||||||||||||||||||||||||||||||
| useEffect, | ||||||||||||||||||||||||||||||||||
| useRef, | ||||||||||||||||||||||||||||||||||
| useState, | ||||||||||||||||||||||||||||||||||
| } from "react"; | ||||||||||||||||||||||||||||||||||
| import { initializeI18n } from "@next-core/i18n"; | ||||||||||||||||||||||||||||||||||
| import { showDialog, WrappedChatInput, WrappedIcon } from "../bricks"; | ||||||||||||||||||||||||||||||||||
| import { K, locales, NS, t } from "./i18n"; | ||||||||||||||||||||||||||||||||||
| import { TaskContext } from "../TaskContext"; | ||||||||||||||||||||||||||||||||||
| import type { ConversationState } from "../interfaces"; | ||||||||||||||||||||||||||||||||||
| import styles from "./ChatBox.module.css"; | ||||||||||||||||||||||||||||||||||
| import { ICON_STOP } from "../constants"; | ||||||||||||||||||||||||||||||||||
| import { ChatInput } from "../../chat-input"; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| initializeI18n(NS, locales); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
|
|
@@ -51,6 +58,16 @@ export function ChatBox({ | |||||||||||||||||||||||||||||||||
| setTerminating(true); | ||||||||||||||||||||||||||||||||||
| }, [onTerminate]); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| const inputRef = useRef<ChatInput>(null); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| useEffect(() => { | ||||||||||||||||||||||||||||||||||
| if (canChat) { | ||||||||||||||||||||||||||||||||||
| setTimeout(() => { | ||||||||||||||||||||||||||||||||||
| inputRef.current?.focus(); | ||||||||||||||||||||||||||||||||||
| }, 100); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+64
to
+68
|
||||||||||||||||||||||||||||||||||
| if (canChat) { | |
| setTimeout(() => { | |
| inputRef.current?.focus(); | |
| }, 100); | |
| } | |
| let timeoutId: ReturnType<typeof setTimeout> | undefined; | |
| if (canChat) { | |
| timeoutId = setTimeout(() => { | |
| inputRef.current?.focus(); | |
| }, 100); | |
| } | |
| return () => { | |
| if (timeoutId !== undefined) { | |
| clearTimeout(timeoutId); | |
| } | |
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
planMaptype should beMap<string, PlanStep> | nullinstead ofMap<string, any> | nullfor better type safety. ThePlanSteptype is available from../shared/interfaces.