HouYunFei Codex commited on
Commit ·
0fe1661
1
Parent(s): c17cbca
fix image history deletion and scrolling
Browse filesCo-Authored-By: Codex <noreply@openai.com>
- web/src/app/image/page.tsx +8 -8
- web/src/app/layout.tsx +2 -2
web/src/app/image/page.tsx
CHANGED
|
@@ -603,16 +603,13 @@ function ImagePageContent({ isAdmin }: { isAdmin: boolean }) {
|
|
| 603 |
}
|
| 604 |
const nextTurn = {
|
| 605 |
...turn,
|
|
|
|
| 606 |
promptDeleted: part === "prompt" ? true : turn.promptDeleted,
|
| 607 |
resultsDeleted: part === "results" ? true : turn.resultsDeleted,
|
| 608 |
status: part === "results" && turn.status === "generating" ? "error" as const : turn.status,
|
| 609 |
images:
|
| 610 |
part === "results"
|
| 611 |
-
? turn.images.map((image) =>
|
| 612 |
-
image.status === "loading"
|
| 613 |
-
? { ...image, status: "error" as const, error: "生成结果已删除" }
|
| 614 |
-
: image,
|
| 615 |
-
)
|
| 616 |
: turn.images,
|
| 617 |
};
|
| 618 |
return nextTurn.promptDeleted && nextTurn.resultsDeleted ? null : nextTurn;
|
|
@@ -760,7 +757,7 @@ function ImagePageContent({ isAdmin }: { isAdmin: boolean }) {
|
|
| 760 |
const handleReuseTurnConfig = useCallback(async (conversationId: string, turnId: string) => {
|
| 761 |
const conversation = conversationsRef.current.find((item) => item.id === conversationId);
|
| 762 |
const turn = conversation?.turns.find((item) => item.id === turnId);
|
| 763 |
-
if (!conversation || !turn) {
|
| 764 |
return;
|
| 765 |
}
|
| 766 |
|
|
@@ -964,7 +961,7 @@ function ImagePageContent({ isAdmin }: { isAdmin: boolean }) {
|
|
| 964 |
async (conversationId: string, turnId: string) => {
|
| 965 |
const conversation = conversationsRef.current.find((item) => item.id === conversationId);
|
| 966 |
const sourceTurn = conversation?.turns.find((turn) => turn.id === turnId);
|
| 967 |
-
if (!conversation || !sourceTurn) {
|
| 968 |
return;
|
| 969 |
}
|
| 970 |
|
|
@@ -1013,6 +1010,9 @@ function ImagePageContent({ isAdmin }: { isAdmin: boolean }) {
|
|
| 1013 |
if (turn.id !== turnId) {
|
| 1014 |
return turn;
|
| 1015 |
}
|
|
|
|
|
|
|
|
|
|
| 1016 |
|
| 1017 |
const images = turn.images.map((image) =>
|
| 1018 |
image.id === imageId
|
|
@@ -1115,7 +1115,7 @@ function ImagePageContent({ isAdmin }: { isAdmin: boolean }) {
|
|
| 1115 |
|
| 1116 |
return (
|
| 1117 |
<>
|
| 1118 |
-
<section className="mx-auto grid min-h-0
|
| 1119 |
<div className="hidden h-full min-h-0 border-r border-stone-200/70 pr-3 lg:block">
|
| 1120 |
<ImageSidebar
|
| 1121 |
conversations={conversations}
|
|
|
|
| 603 |
}
|
| 604 |
const nextTurn = {
|
| 605 |
...turn,
|
| 606 |
+
prompt: part === "prompt" ? "" : turn.prompt,
|
| 607 |
promptDeleted: part === "prompt" ? true : turn.promptDeleted,
|
| 608 |
resultsDeleted: part === "results" ? true : turn.resultsDeleted,
|
| 609 |
status: part === "results" && turn.status === "generating" ? "error" as const : turn.status,
|
| 610 |
images:
|
| 611 |
part === "results"
|
| 612 |
+
? turn.images.map((image) => ({ id: image.id, status: "error" as const, error: "生成结果已删除" }))
|
|
|
|
|
|
|
|
|
|
|
|
|
| 613 |
: turn.images,
|
| 614 |
};
|
| 615 |
return nextTurn.promptDeleted && nextTurn.resultsDeleted ? null : nextTurn;
|
|
|
|
| 757 |
const handleReuseTurnConfig = useCallback(async (conversationId: string, turnId: string) => {
|
| 758 |
const conversation = conversationsRef.current.find((item) => item.id === conversationId);
|
| 759 |
const turn = conversation?.turns.find((item) => item.id === turnId);
|
| 760 |
+
if (!conversation || !turn || !turn.prompt.trim()) {
|
| 761 |
return;
|
| 762 |
}
|
| 763 |
|
|
|
|
| 961 |
async (conversationId: string, turnId: string) => {
|
| 962 |
const conversation = conversationsRef.current.find((item) => item.id === conversationId);
|
| 963 |
const sourceTurn = conversation?.turns.find((turn) => turn.id === turnId);
|
| 964 |
+
if (!conversation || !sourceTurn || !sourceTurn.prompt.trim()) {
|
| 965 |
return;
|
| 966 |
}
|
| 967 |
|
|
|
|
| 1010 |
if (turn.id !== turnId) {
|
| 1011 |
return turn;
|
| 1012 |
}
|
| 1013 |
+
if (!turn.prompt.trim()) {
|
| 1014 |
+
return turn;
|
| 1015 |
+
}
|
| 1016 |
|
| 1017 |
const images = turn.images.map((image) =>
|
| 1018 |
image.id === imageId
|
|
|
|
| 1115 |
|
| 1116 |
return (
|
| 1117 |
<>
|
| 1118 |
+
<section className="mx-auto grid h-[calc(100dvh-6.5rem)] min-h-0 w-full max-w-[1380px] grid-cols-1 gap-2 overflow-hidden px-0 pb-[calc(env(safe-area-inset-bottom)+0.5rem)] sm:h-[calc(100dvh-5.25rem)] sm:gap-3 sm:px-3 sm:pb-6 lg:grid-cols-[240px_minmax(0,1fr)]">
|
| 1119 |
<div className="hidden h-full min-h-0 border-r border-stone-200/70 pr-3 lg:block">
|
| 1120 |
<ImageSidebar
|
| 1121 |
conversations={conversations}
|
web/src/app/layout.tsx
CHANGED
|
@@ -31,8 +31,8 @@ export default function RootLayout({
|
|
| 31 |
}}
|
| 32 |
>
|
| 33 |
<Toaster position="top-center" richColors offset={48} />
|
| 34 |
-
<main className="h-screen overflow-hidden bg-[radial-gradient(circle_at_top_left,_rgba(255,255,255,0.92),_rgba(245,239,231,0.96)_42%,_rgba(240,235,227,0.99)_100%)] px-4 pt-0 pb-2 text-stone-900 sm:px-6 sm:pt-2 lg:px-8">
|
| 35 |
-
<div className="mx-auto box-border flex h-
|
| 36 |
<TopNav />
|
| 37 |
{children}
|
| 38 |
</div>
|
|
|
|
| 31 |
}}
|
| 32 |
>
|
| 33 |
<Toaster position="top-center" richColors offset={48} />
|
| 34 |
+
<main className="min-h-screen overflow-x-hidden bg-[radial-gradient(circle_at_top_left,_rgba(255,255,255,0.92),_rgba(245,239,231,0.96)_42%,_rgba(240,235,227,0.99)_100%)] px-4 pt-0 pb-2 text-stone-900 sm:px-6 sm:pt-2 lg:px-8">
|
| 35 |
+
<div className="mx-auto box-border flex min-h-screen max-w-[1440px] flex-col gap-2 pt-[env(safe-area-inset-top)] sm:gap-5 sm:pt-0">
|
| 36 |
<TopNav />
|
| 37 |
{children}
|
| 38 |
</div>
|