mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
Improve mobile UX for message actions and scroll button; add revert message filtering
This commit is contained in:
1 parent
3a01ca9356
commit
1ae8ed81b2
5 files changed
+25
-11
No files matched your search
@@ -2,6 +2,7 @@ import { memo, useState, useRef, useEffect } from 'react'
|
||||
import { Send, X, Pencil, Loader2 } from 'lucide-react'
|
||||
import { useRefreshMessage } from '@/hooks/useRemoveMessage'
|
||||
import { useUIState } from '@/stores/uiStateStore'
|
||||
import { useMobile } from '@/hooks/useMobile'
|
||||
|
||||
interface EditableUserMessageProps {
|
||||
opcodeUrl: string
|
||||
@@ -129,6 +130,8 @@ export const ClickableUserMessage = memo(function ClickableUserMessage({
|
||||
onClick,
|
||||
isEditable
|
||||
}: ClickableUserMessageProps) {
|
||||
const isMobile = useMobile()
|
||||
|
||||
if (!isEditable) {
|
||||
return (
|
||||
<div className="text-sm whitespace-pre-wrap break-words">
|
||||
@@ -144,7 +147,7 @@ export const ClickableUserMessage = memo(function ClickableUserMessage({
|
||||
title="Click to edit and resend"
|
||||
>
|
||||
<span className="flex-1">{content}</span>
|
||||
<Pencil className="w-4 h-4 flex-shrink-0 mt-0.5 text-muted-foreground opacity-50 group-hover/edit:opacity-100 group-hover/edit:text-primary transition-all" />
|
||||
<Pencil className={`w-4 h-4 flex-shrink-0 mt-0.5 text-muted-foreground transition-all ${isMobile ? 'opacity-100' : 'opacity-50 group-hover/edit:opacity-100 group-hover/edit:text-primary'}`} />
|
||||
</button>
|
||||
)
|
||||
})
|
||||
@@ -1,6 +1,7 @@
|
||||
import { memo } from 'react'
|
||||
import { X, RefreshCw, Loader2 } from 'lucide-react'
|
||||
import { useRemoveMessage, useRefreshMessage } from '@/hooks/useRemoveMessage'
|
||||
import { useMobile } from '@/hooks/useMobile'
|
||||
import type { MessageWithParts } from '@/api/types'
|
||||
|
||||
interface MessageActionButtonsProps {
|
||||
@@ -26,6 +27,7 @@ export const MessageActionButtons = memo(function MessageActionButtons({
|
||||
model,
|
||||
agent
|
||||
}: MessageActionButtonsProps) {
|
||||
const isMobile = useMobile()
|
||||
const removeMessage = useRemoveMessage({ opcodeUrl, sessionId, directory })
|
||||
const refreshMessage = useRefreshMessage({ opcodeUrl, sessionId, directory })
|
||||
|
||||
@@ -56,7 +58,7 @@ export const MessageActionButtons = memo(function MessageActionButtons({
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity">
|
||||
<div className={`flex items-center gap-1 ${isMobile ? 'opacity-100' : 'opacity-0 group-hover:opacity-100'} transition-opacity`}>
|
||||
<button
|
||||
onClick={handleRemove}
|
||||
disabled={isLoading}
|
||||
|
||||
@@ -549,7 +549,7 @@ export const PromptInput = forwardRef<PromptInputHandle, PromptInputProps>(funct
|
||||
<div className="flex items-center gap-1.5 md:gap-2 flex-shrink-0">
|
||||
<button
|
||||
onClick={onScrollToBottom}
|
||||
className={`p-1.5 md:p-2 rounded-lg bg-muted hover:bg-muted-foreground/20 text-muted-foreground hover:text-foreground transition-colors border border-transparent dark:border-white/30 ${showScrollButton ? 'border-foreground/30 visible' : 'invisible'}`}
|
||||
className={`p-1.5 md:p-2 rounded-lg bg-muted hover:bg-muted-foreground/20 text-muted-foreground hover:text-foreground transition-all duration-200 active:scale-95 hover:scale-105 shadow-md shadow-blue-500/20 hover:shadow-blue-500/30 border border-blue-500/30 hover:border-blue-500 dark:border-blue-400/30 dark:hover:border-blue-400 ring-1 ring-blue-500/20 hover:ring-blue-500/30 ${showScrollButton ? 'visible' : 'invisible'}`}
|
||||
title="Scroll to bottom"
|
||||
>
|
||||
<ChevronDown className="w-5 h-5" />
|
||||
|
||||
@@ -2,6 +2,7 @@ import { memo } from 'react'
|
||||
import { X, RefreshCw, Loader2 } from 'lucide-react'
|
||||
import { useUndoMessage } from '@/hooks/useUndoMessage'
|
||||
import { useRefreshMessage } from '@/hooks/useRemoveMessage'
|
||||
import { useMobile } from '@/hooks/useMobile'
|
||||
|
||||
interface UserMessageActionButtonsProps {
|
||||
opcodeUrl: string
|
||||
@@ -26,6 +27,7 @@ export const UserMessageActionButtons = memo(function UserMessageActionButtons({
|
||||
model,
|
||||
agent
|
||||
}: UserMessageActionButtonsProps) {
|
||||
const isMobile = useMobile()
|
||||
const undoMessage = useUndoMessage({
|
||||
opcodeUrl,
|
||||
sessionId,
|
||||
@@ -55,7 +57,7 @@ export const UserMessageActionButtons = memo(function UserMessageActionButtons({
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity">
|
||||
<div className={`flex items-center gap-1 ${isMobile ? 'opacity-100' : 'opacity-0 group-hover:opacity-100'} transition-opacity`}>
|
||||
<button
|
||||
onClick={handleRefresh}
|
||||
disabled={isLoading}
|
||||
|
||||
@@ -23,7 +23,7 @@ import { usePermissionRequests } from "@/hooks/usePermissionRequests";
|
||||
import { useAutoScroll } from "@/hooks/useAutoScroll";
|
||||
import { useSwipeBack } from "@/hooks/useMobile";
|
||||
import { useTTS } from "@/hooks/useTTS";
|
||||
import { useEffect, useRef, useCallback } from "react";
|
||||
import { useEffect, useRef, useCallback, useMemo } from "react";
|
||||
import { MessageSkeleton } from "@/components/message/MessageSkeleton";
|
||||
import { exportSession, downloadMarkdown } from "@/lib/exportSession";
|
||||
import { showToast } from "@/lib/toast";
|
||||
@@ -67,8 +67,20 @@ export function SessionDetail() {
|
||||
|
||||
const repoDirectory = repo?.fullPath;
|
||||
|
||||
const { data: messages, isLoading: messagesLoading } = useMessages(opcodeUrl, sessionId, repoDirectory);
|
||||
const { data: rawMessages, isLoading: messagesLoading } = useMessages(opcodeUrl, sessionId, repoDirectory);
|
||||
const { data: sessions } = useSessions(opcodeUrl, repoDirectory);
|
||||
const { data: session, isLoading: sessionLoading } = useSession(
|
||||
opcodeUrl,
|
||||
sessionId,
|
||||
repoDirectory,
|
||||
);
|
||||
|
||||
const messages = useMemo(() => {
|
||||
if (!rawMessages) return undefined
|
||||
const revertMessageID = session?.revert?.messageID
|
||||
if (!revertMessageID) return rawMessages
|
||||
return rawMessages.filter(msg => msg.info.id < revertMessageID)
|
||||
}, [rawMessages, session?.revert?.messageID]);
|
||||
|
||||
const { scrollToBottom } = useAutoScroll({
|
||||
containerRef: messageContainerRef,
|
||||
@@ -77,11 +89,6 @@ export function SessionDetail() {
|
||||
onScrollStateChange: setShowScrollButton
|
||||
});
|
||||
|
||||
const { data: session, isLoading: sessionLoading } = useSession(
|
||||
opcodeUrl,
|
||||
sessionId,
|
||||
repoDirectory,
|
||||
);
|
||||
const { isConnected, isReconnecting } = useSSE(opcodeUrl, repoDirectory);
|
||||
const { currentPermission, pendingCount, isFromDifferentSession, dismissPermission } = usePermissionRequests(sessionId);
|
||||
const abortSession = useAbortSession(opcodeUrl, repoDirectory, sessionId);
|
||||
|
||||
Reference in new issue
Block a user