@@ -4,39 +4,96 @@ import { Button } from "@hypr/ui/components/ui/button";
44import { Textarea } from "@hypr/ui/components/ui/textarea" ;
55
66import * as main from "../../../../store/tinybase/main" ;
7+ import {
8+ DangerZone ,
9+ ResourceDetailEmpty ,
10+ ResourcePreviewHeader ,
11+ } from "../resource-list" ;
12+
13+ type WebShortcut = {
14+ slug : string ;
15+ title : string ;
16+ description : string ;
17+ category : string ;
18+ targets ?: string [ ] ;
19+ prompt : string ;
20+ } ;
721
822export function ChatShortcutDetailsColumn ( {
9- selectedChatShortcutId,
10- setSelectedChatShortcut,
23+ isWebMode,
24+ selectedMineId,
25+ selectedWebShortcut,
26+ setSelectedMineId,
27+ handleCloneShortcut,
1128} : {
12- selectedChatShortcutId : string | null ;
13- setSelectedChatShortcut : ( id : string | null ) => void ;
29+ isWebMode : boolean ;
30+ selectedMineId : string | null ;
31+ selectedWebShortcut : WebShortcut | null ;
32+ setSelectedMineId : ( id : string | null ) => void ;
33+ handleCloneShortcut : ( shortcut : WebShortcut ) => void ;
1434} ) {
15- if ( ! selectedChatShortcutId ) {
35+ if ( isWebMode ) {
36+ if ( ! selectedWebShortcut ) {
37+ return < ResourceDetailEmpty message = "Select a shortcut to preview" /> ;
38+ }
1639 return (
17- < div className = "h-full flex items-center justify-center" >
18- < p className = "text-sm text-neutral-500" >
19- Select a shortcut to view or edit
20- </ p >
21- </ div >
40+ < WebShortcutPreview
41+ shortcut = { selectedWebShortcut }
42+ onClone = { handleCloneShortcut }
43+ />
2244 ) ;
2345 }
2446
47+ if ( ! selectedMineId ) {
48+ return < ResourceDetailEmpty message = "Select a shortcut to view or edit" /> ;
49+ }
50+
2551 return (
26- < ChatShortcutDetails
27- key = { selectedChatShortcutId }
28- id = { selectedChatShortcutId }
29- setSelectedChatShortcut = { setSelectedChatShortcut }
52+ < ChatShortcutForm
53+ key = { selectedMineId }
54+ id = { selectedMineId }
55+ setSelectedMineId = { setSelectedMineId }
3056 />
3157 ) ;
3258}
3359
34- function ChatShortcutDetails ( {
60+ function WebShortcutPreview ( {
61+ shortcut,
62+ onClone,
63+ } : {
64+ shortcut : WebShortcut ;
65+ onClone : ( shortcut : WebShortcut ) => void ;
66+ } ) {
67+ return (
68+ < div className = "flex flex-col h-full" >
69+ < ResourcePreviewHeader
70+ title = { shortcut . title }
71+ description = { shortcut . description }
72+ category = { shortcut . category }
73+ targets = { shortcut . targets }
74+ onClone = { ( ) => onClone ( shortcut ) }
75+ />
76+
77+ < div className = "flex-1 p-6" >
78+ < h3 className = "text-sm font-medium text-neutral-600 mb-3" >
79+ Prompt Content
80+ </ h3 >
81+ < div className = "p-4 bg-neutral-50 rounded-lg border border-neutral-200" >
82+ < p className = "text-sm text-neutral-700 whitespace-pre-wrap" >
83+ { shortcut . prompt }
84+ </ p >
85+ </ div >
86+ </ div >
87+ </ div >
88+ ) ;
89+ }
90+
91+ function ChatShortcutForm ( {
3592 id,
36- setSelectedChatShortcut ,
93+ setSelectedMineId ,
3794} : {
3895 id : string ;
39- setSelectedChatShortcut : ( id : string | null ) => void ;
96+ setSelectedMineId : ( id : string | null ) => void ;
4097} ) {
4198 const content = main . UI . useCell (
4299 "chat_shortcuts" ,
@@ -70,8 +127,8 @@ function ChatShortcutDetails({
70127
71128 const handleDeleteClick = useCallback ( ( ) => {
72129 handleDelete ( ) ;
73- setSelectedChatShortcut ( null ) ;
74- } , [ handleDelete , setSelectedChatShortcut ] ) ;
130+ setSelectedMineId ( null ) ;
131+ } , [ handleDelete , setSelectedMineId ] ) ;
75132
76133 const hasChanges = localValue !== ( content || "" ) ;
77134
@@ -103,30 +160,12 @@ function ChatShortcutDetails({
103160 </ div >
104161
105162 < div className = "p-6 border-t border-neutral-200" >
106- < div className = "border border-red-200 rounded-lg overflow-hidden" >
107- < div className = "bg-red-50 px-4 py-3 border-b border-red-200" >
108- < h3 className = "text-sm font-semibold text-red-900" > Danger Zone</ h3 >
109- </ div >
110- < div className = "bg-white p-4" >
111- < div className = "flex items-center justify-between" >
112- < div >
113- < p className = "text-sm font-medium text-neutral-900" >
114- Delete this shortcut
115- </ p >
116- < p className = "text-xs text-neutral-500 mt-1" >
117- This action cannot be undone
118- </ p >
119- </ div >
120- < Button
121- onClick = { handleDeleteClick }
122- variant = "destructive"
123- size = "sm"
124- >
125- Delete Shortcut
126- </ Button >
127- </ div >
128- </ div >
129- </ div >
163+ < DangerZone
164+ title = "Delete this shortcut"
165+ description = "This action cannot be undone"
166+ buttonLabel = "Delete Shortcut"
167+ onAction = { handleDeleteClick }
168+ />
130169 </ div >
131170 </ div >
132171 ) ;
0 commit comments