Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion packages/app-expo/src/screens/BookChatScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,8 @@ export function BookChatScreen({ route, navigation }: Props) {
return convertToMessageV2(activeThread.messages);
}, [activeThread]);

const activeCurrentMessage = activeThread?.id === currentMessage?.threadId ? currentMessage : null;
const activeCurrentMessage =
activeThread?.id === currentMessage?.threadId ? currentMessage : null;
const allMessages = useMemo(
() => mergeMessagesWithStreaming(messagesV2, activeCurrentMessage, isStreaming),
[activeCurrentMessage, isStreaming, messagesV2],
Expand Down Expand Up @@ -526,6 +527,14 @@ export function BookChatScreen({ route, navigation }: Props) {
</View>

<View style={s.content}>
{selectedText?.trim() ? (
<View style={s.selectionContext} accessibilityLabel="Selected text context">
<Text style={s.selectionContextLabel}>{t("chat.selectedText", "选中文本")}</Text>
<Text style={s.selectionContextText} numberOfLines={4}>
“{selectedText.trim()}”
</Text>
</View>
) : null}
<View style={s.content}>
{allMessages.length > 0 ? (
<MessageList
Expand Down Expand Up @@ -661,6 +670,28 @@ const makeStyles = (
justifyContent: "center",
},
content: { flex: 1 },
selectionContext: {
marginHorizontal: layout.isTabletLandscape ? 20 : 12,
marginTop: 8,
marginBottom: 4,
paddingHorizontal: 12,
paddingVertical: 9,
borderRadius: radius.md,
borderLeftWidth: 3,
borderLeftColor: colors.primary,
backgroundColor: withOpacity(colors.muted, 0.72),
},
selectionContextLabel: {
fontSize: fs.xs,
fontWeight: fw.semibold,
color: colors.primary,
marginBottom: 3,
},
selectionContextText: {
fontSize: fs.sm,
lineHeight: 19,
color: colors.foreground,
},
emptyContainer: {
flex: 1,
justifyContent: "center",
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/i18n/locales/en/chat.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"askPlaceholder": "Ask about your books...",
"askBookPlaceholder": "Ask about your book...",
"askAboutQuote": "Ask about the selected text...",
"selectedText": "Selected text",
"suggestions": {
"summarizeReading": "Summarize my recent reading",
"analyzeArguments": "Analyze key arguments",
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/i18n/locales/zh/chat.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"askPlaceholder": "输入你的问题...",
"askBookPlaceholder": "关于这本书的问题...",
"askAboutQuote": "关于选中的文本提问...",
"selectedText": "选中文本",
"suggestions": {
"summarizeReading": "总结我最近的阅读",
"analyzeArguments": "分析核心论点",
Expand Down