feat(web): preview generated images in right panel #6029
Closedkyzer1023(GitHub profile, opens in a new tab)wants to merge 4 commits into
main fromrefs/pull/6029/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- apps/server/src/assets/GeneratedImageResolver.ts lines 34 to 35OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +15,21 @@15+ return null;16+ }17+ const data = payload.data;18+ if (!Predicate.isObject(data) || !Predicate.hasProperty(data, "item")) {19+ return null;20+ }21+ const item = data.item;22+ if (23+ !Predicate.isObject(item) ||24+ !Predicate.hasProperty(item, "type") ||25+ item.type !== "imageGeneration" ||26+ !Predicate.hasProperty(item, "status") ||27+ item.status !== "completed" ||28+ !Predicate.hasProperty(item, "savedPath") ||29+ !Predicate.isString(item.savedPath)30+ ) {31+ return null;32+ }33+34+ const savedPath = item.savedPath.trim();35+ return savedPath.length > 0 ? savedPath : null;apps/server/src/assets/AssetAccess.ts line 521Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -444,3 +517,4 @@444517 const decodedPath = decodeRelativePath(relativePath);445518 if (decodedPath === null) return null;446519 const path = yield* Path.Path;520+ if (claims.kind === "generated-image") {
- apps/server/src/ws.ts lines 1843 to 1846OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -1830,3 +1833,14 @@18301833 if (input.resource._tag === "attachment") {18311834 return yield* issueAssetUrl({ resource: input.resource });18321835 }1836+ if (input.resource._tag === "generated-image") {1837+ const resource = input.resource;1838+ const thread = yield* projectionSnapshotQuery1839+ .getThreadDetailById(resource.threadId)1840+ .pipe(1841+ Effect.mapError(1842+ (cause) =>1843+ new AssetGeneratedImageInspectionError({1844+ resource,1845+ cause,1846+ }),
- apps/web/src/components/chat/GeneratedImagePanel.tsx line 16Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +1,15 @@1+import type { EventId, ScopedThreadRef } from "@t3tools/contracts";2+import { useState } from "react";3+4+import { useAssetUrlState } from "~/assets/assetUrls";5+6+export function GeneratedImagePanel(props: {7+ readonly threadRef: ScopedThreadRef;8+ readonly activityId: EventId;9+ readonly name: string;10+}) {11+ const assetUrl = useAssetUrlState(props.threadRef.environmentId, {12+ _tag: "generated-image",13+ threadId: props.threadRef.threadId,14+ activityId: props.activityId,15+ });@@ -1832 +1835,21 @@18321835 }1836+ if (input.resource._tag === "generated-image") {1837+ const resource = input.resource;1838+ const thread = yield* projectionSnapshotQuery1839+ .getThreadDetailById(resource.threadId)1840+ .pipe(1841+ Effect.mapError(1842+ (cause) =>1843+ new AssetGeneratedImageInspectionError({1844+ resource,1845+ cause,1846+ }),1847+ ),1848+ );1849+ const generatedImagePath = Option.isSome(thread)1850+ ? findGeneratedImagePath(thread.value.activities, resource.activityId)1851+ : null;1852+ if (!generatedImagePath) {1853+ return yield* new AssetGeneratedImageNotFoundError({ resource });1854+ }1855+ return yield* issueAssetUrl({ resource, generatedImagePath });
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.




Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
fbe09c53-9883-4eaa-a1b9-3f675e01037bYou can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share