Skip to content

Commit c72c0c6

Browse files
committed
fix
1 parent 5ff0005 commit c72c0c6

File tree

4 files changed

+35
-1
lines changed

4 files changed

+35
-1
lines changed

packages/web/public/locales/translation/en.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ chat:
3232
show_system_prompt: Show system prompt
3333
system_prompt: System Prompt
3434
title: Chat
35+
view_prompt_examples: View Prompt Examples
3536
common:
3637
cancel: Cancel
3738
clear: Clear

packages/web/public/locales/translation/ja.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ chat:
3030
show_system_prompt: システムプロンプトの表示
3131
system_prompt: システムプロンプト
3232
title: チャット
33+
view_prompt_examples: プロンプト例を見る
3334
common:
3435
cancel: キャンセル
3536
clear: クリア

packages/web/src/components/PromptList.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ type Props = BaseProps & {
3232
systemContextId: string,
3333
title: string
3434
) => Promise<void>;
35+
forceExpand: number | null;
3536
};
3637

3738
const PromptList: React.FC<Props> = (props) => {
@@ -42,11 +43,29 @@ const PromptList: React.FC<Props> = (props) => {
4243
// PromptList is fixed for use on the chat page
4344
const { getModelId } = useChat('/chat');
4445
const modelId = getModelId();
46+
const [previousForceExpanded, setPreviousForceExpanded] = useState<
47+
number | null
48+
>(null);
4549

4650
const prompter = useMemo(() => {
4751
return getPrompter(modelId);
4852
}, [modelId]);
4953

54+
useEffect(() => {
55+
if (
56+
props.forceExpand !== null &&
57+
previousForceExpanded !== props.forceExpand
58+
) {
59+
setPreviousForceExpanded(props.forceExpand);
60+
setExpanded(true);
61+
}
62+
}, [
63+
props.forceExpand,
64+
previousForceExpanded,
65+
setPreviousForceExpanded,
66+
setExpanded,
67+
]);
68+
5069
// To access the upper setExpanded, nest the component
5170
const Item: React.FC<PromptListItem> = (props) => {
5271
const onClickPrompt = useCallback(() => {

packages/web/src/pages/ChatPage.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ const ChatPage: React.FC = () => {
157157
>(undefined);
158158
const [showSetting, setShowSetting] = useState(false);
159159
const { t } = useTranslation();
160+
const [forceExpandPromptList, setForceExpandPromptList] = useState<
161+
number | null
162+
>(null);
160163

161164
useEffect(() => {
162165
// On the conversation history page, do not change the system prompt even if the model is changed
@@ -433,12 +436,21 @@ const ChatPage: React.FC = () => {
433436
</div>
434437

435438
{((isEmpty && !loadingMessages) || loadingMessages) && (
436-
<div className="relative flex h-[calc(100vh-13rem)] flex-col items-center justify-center">
439+
<div className="relative flex h-[calc(100vh-13rem)] flex-col items-center justify-center gap-y-4">
437440
<BedrockIcon
438441
className={`fill-gray-400 ${
439442
loadingMessages ? 'animate-pulse' : ''
440443
}`}
441444
/>
445+
446+
<Button
447+
className="text-sm"
448+
outlined
449+
onClick={() => {
450+
setForceExpandPromptList(Math.random());
451+
}}>
452+
{t('chat.view_prompt_examples')}
453+
</Button>
442454
</div>
443455
)}
444456

@@ -557,6 +569,7 @@ const ChatPage: React.FC = () => {
557569
systemContextList={systemContextList as SystemContext[]}
558570
onClickDeleteSystemContext={onClickDeleteSystemContext}
559571
onClickUpdateSystemContext={onClickUpdateSystemContext}
572+
forceExpand={forceExpandPromptList}
560573
/>
561574
)}
562575

0 commit comments

Comments
 (0)