From c2c55eb8205a4cd520c9a080e5f0b3a09040b857 Mon Sep 17 00:00:00 2001 From: Pabloader Date: Mon, 23 Mar 2026 21:39:21 +0000 Subject: [PATCH] Format system prompt --- .../assets/chat-sidebar.module.css | 15 ++++ .../assets/settings-modal.module.css | 31 +++++++ .../components/character-editor.tsx | 29 ++++++- .../storywriter/components/chat-sidebar.tsx | 36 ++++++--- .../components/location-editor.tsx | 29 ++++++- src/games/storywriter/contexts/state.tsx | 11 +++ src/games/storywriter/utils/llm.ts | 33 ++++++++ src/games/storywriter/utils/prompt.ts | 81 ++++++++++++++++++- 8 files changed, 246 insertions(+), 19 deletions(-) diff --git a/src/games/storywriter/assets/chat-sidebar.module.css b/src/games/storywriter/assets/chat-sidebar.module.css index 27b5df3..68da165 100644 --- a/src/games/storywriter/assets/chat-sidebar.module.css +++ b/src/games/storywriter/assets/chat-sidebar.module.css @@ -188,6 +188,21 @@ } } +.stopButton { + padding: 8px 16px; + font-size: 13px; + font-weight: bold; + color: var(--bg); + background: var(--error, #f44336); + border: none; + border-radius: 4px; + cursor: pointer; + + &:hover { + background: #d32f2f; + } +} + .clearButton { padding: 8px 16px; font-size: 12px; diff --git a/src/games/storywriter/assets/settings-modal.module.css b/src/games/storywriter/assets/settings-modal.module.css index 5a4906d..952f2a4 100644 --- a/src/games/storywriter/assets/settings-modal.module.css +++ b/src/games/storywriter/assets/settings-modal.module.css @@ -56,6 +56,37 @@ } } +.tabs { + display: flex; + border-bottom: 1px solid var(--border); + padding: 0 20px; + gap: 8px; +} + +.tab { + display: flex; + align-items: center; + gap: 6px; + padding: 12px 16px; + background: transparent; + border: none; + border-bottom: 2px solid transparent; + color: var(--text-muted); + cursor: pointer; + font-size: 14px; + transition: all 0.2s; + + &:hover { + color: var(--text); + background: var(--bg-hover); + } + + &.active { + color: var(--accent); + border-bottom-color: var(--accent); + } +} + .content { flex: 1; overflow-y: auto; diff --git a/src/games/storywriter/components/character-editor.tsx b/src/games/storywriter/components/character-editor.tsx index 00858a4..2050f2e 100644 --- a/src/games/storywriter/components/character-editor.tsx +++ b/src/games/storywriter/components/character-editor.tsx @@ -1,12 +1,14 @@ import { useAppState, type Character } from "../contexts/state"; import { useState } from "preact/hooks"; import styles from '../assets/character-editor.module.css'; +import LLM from "../utils/llm"; export const CharacterEditor = () => { - const { currentStory, dispatch } = useAppState(); + const { currentStory, dispatch, connection, model } = useAppState(); const [newNickname, setNewNickname] = useState>({}); const [newRelation, setNewRelation] = useState>({}); const [showDeleteConfirm, setShowDeleteConfirm] = useState(null); + const [generatingShortDesc, setGeneratingShortDesc] = useState(null); if (!currentStory) { return null; @@ -99,6 +101,23 @@ export const CharacterEditor = () => { setNewRelation({ ...newRelation, [characterId]: { ...current, [field]: value } }); }; + const handleGenerateShortDescription = async (characterId: string) => { + if (!connection || !model) return; + + const character = currentStory.characters.find(c => c.id === characterId); + if (!character || !character.description.trim()) return; + + setGeneratingShortDesc(characterId); + try { + const shortDesc = await LLM.summarize(connection, model.id, character.description, 'sentence'); + handleEditCharacter(characterId, 'shortDescription', shortDesc.trim()); + } catch (error) { + console.error('Failed to generate short description:', error); + } finally { + setGeneratingShortDesc(null); + } + }; + return (
@@ -167,8 +186,12 @@ export const CharacterEditor = () => {
Short Description -