@@ -729,11 +729,18 @@ ${sysPrompt}` }], max_tokens: 20, temperature: 0.2 }) });
729729 return null ;
730730 }
731731} ;
732- const threadRow = ( t ) => `<div class="relative flex items-center gap-2 px-3 py-2 ${ t . pinned ? "bg-yellow-50" : "" } "><button data-open-thread="${ t . id } " data-type="${ t . type || "thread" } " class="flex-1 text-left truncate flex items-center gap-2">${ t . type === "folder" ? '<i data-lucide="folder" class="h-4 w-4"></i>' : "" } ${ t . pinned ? "📌 " : "" } ${ esc ( t . title || "Untitled" ) } ${ t . status === "modified" ? "*" : t . status === "new" ? "+" : "" } </button><button data-thread-menu="${ t . id } " class="h-8 w-8 rounded hover:bg-gray-100 flex items-center justify-center" title="More"><i data-lucide="more-horizontal" class="h-4 w-4"></i></button></div>` ;
732+ const threadRow = ( t ) => {
733+ const icon = t . type === "folder" ? "folder" : t . type === "file" ? "file-text" : "" ;
734+ return `<div class="relative flex items-center gap-2 px-3 py-2 ${ t . pinned ? "bg-yellow-50" : "" } "><button data-open-thread="${ t . id } " data-type="${ t . type || "thread" } " class="flex-1 text-left truncate flex items-center gap-2">${ icon ? `<i data-lucide="${ icon } " class="h-4 w-4"></i>` : "" } ${ t . pinned ? "📌 " : "" } ${ esc ( t . title || "Untitled" ) } ${ t . status === "modified" ? "*" : t . status === "new" ? "+" : "" } </button>${ t . type === "file" ? "" : `<button data-thread-menu="${ t . id } " class="h-8 w-8 rounded hover:bg-gray-100 flex items-center justify-center" title="More"><i data-lucide="more-horizontal" class="h-4 w-4"></i></button>` } </div>` ;
735+ } ;
733736let sortedThreads = [ ] , isAddingThreads = false ;
734737const THREAD_PAGE_SIZE = 50 ;
735738async function renderThreads ( ) {
736- sortedThreads = [ ...THREAD . list ] . filter ( ( t ) => t . status !== "deleted" ) . sort ( ( a , b ) => b . pinned - a . pinned || b . updatedAt - a . updatedAt ) ;
739+ sortedThreads = [ ...THREAD . list ] . filter ( ( t ) => t . status !== "deleted" ) . sort ( ( a , b ) => {
740+ if ( a . type === "file" && b . type !== "file" ) return - 1 ;
741+ if ( a . type !== "file" && b . type === "file" ) return 1 ;
742+ return b . pinned - a . pinned || b . updatedAt - a . updatedAt ;
743+ } ) ;
737744 el . threadList . innerHTML = sortedThreads . slice ( 0 , THREAD_PAGE_SIZE ) . map ( threadRow ) . join ( "" ) ;
738745 el . threadList . scrollTop = 0 ;
739746 isAddingThreads = false ;
@@ -765,6 +772,21 @@ $(el.threadList).on("click", async (e) => {
765772 const openBtn = e . target . closest ( "[data-open-thread]" ) , menuBtn = e . target . closest ( "[data-thread-menu]" ) ;
766773 if ( openBtn ) {
767774 const id = openBtn . getAttribute ( "data-open-thread" ) , type = openBtn . getAttribute ( "data-type" ) ;
775+ if ( type === "file" ) {
776+ const u2 = el . threadRepoInput . value . trim ( ) ;
777+ if ( u2 . startsWith ( "gh://" ) ) {
778+ const info = parseGhUrl ( u2 ) ;
779+ try {
780+ await navigator . clipboard . writeText ( `${ info . owner } /${ info . repo } /${ id } ` ) ;
781+ const old = openBtn . innerHTML ;
782+ openBtn . innerHTML = '<i data-lucide="check" class="h-4 w-4 text-green-500"></i> Copied Path' ;
783+ icons ( ) ;
784+ setTimeout ( ( ) => ( openBtn . innerHTML = old , icons ( ) ) , 1200 ) ;
785+ } catch {
786+ }
787+ }
788+ return ;
789+ }
768790 if ( type === "folder" ) {
769791 const u2 = el . threadRepoInput . value . trim ( ) ;
770792 el . threadRepoInput . value = u2 + ( u2 . endsWith ( "/" ) ? "" : "/" ) + id ;
@@ -1427,6 +1449,7 @@ const pullThreads = async () => {
14271449 } else {
14281450 THREAD . list = items . map ( ( i ) => {
14291451 if ( i . type === "dir" ) return { id : i . name , title : i . name , type : "folder" , updatedAt : 0 } ;
1452+ if ( i . type === "file" && i . name . endsWith ( ".md" ) ) return { id : i . path , title : i . name , type : "file" , updatedAt : 0 } ;
14301453 const d = deserializeThreadName ( i . name ) ;
14311454 return d ? { ...d , status : "synced" } : null ;
14321455 } ) . filter ( Boolean ) ;
0 commit comments