@@ -6,6 +6,7 @@ import * as Stream from "effect/Stream";
66import * as NodeSqliteClient from "@t3tools/shared/nodeSqliteClient" ;
77import { makeThreadFind } from "./ThreadFind.ts" ;
88import type {
9+ OrchestrationV2ThreadLinkMetadata ,
910 OrchestrationV2SearchThreadInput ,
1011 OrchestrationV2SearchThreadResult ,
1112 OrchestrationV2ThreadHistoryPage ,
@@ -562,6 +563,9 @@ export interface ProjectionStoreV2Shape {
562563 threadId ?: ThreadId ,
563564 ) => Effect . Effect < ReadonlyArray < ProjectionThreadPullRequests > , ProjectionStoreV2Error > ;
564565 /** Titles of the given threads that exist, archived ones included. */
566+ readonly getThreadLinkMetadata : (
567+ threadIds : ReadonlyArray < ThreadId > ,
568+ ) => Effect . Effect < Record < ThreadId , OrchestrationV2ThreadLinkMetadata > , ProjectionStoreV2Error > ;
565569 readonly getThreadTitles : (
566570 threadIds : ReadonlyArray < ThreadId > ,
567571 ) => Effect . Effect < Record < ThreadId , string > , ProjectionStoreV2Error > ;
@@ -7306,6 +7310,24 @@ export const layer: Layer.Layer<ProjectionStoreV2, never, SqlClient.SqlClient> =
73067310 } ) ) ;
73077311 } , Effect . mapError ( shellSnapshotReadError ) ) ;
73087312
7313+ const getThreadLinkMetadata = Effect . fn ( "ProjectionStore.getThreadLinkMetadata" ) ( function * (
7314+ threadIds : ReadonlyArray < ThreadId > ,
7315+ ) {
7316+ if ( threadIds . length === 0 ) return { } ;
7317+ const rows = yield * sql < {
7318+ readonly thread_id : ThreadId ;
7319+ readonly title : string ;
7320+ readonly project_id : ProjectId ;
7321+ } > `
7322+ SELECT thread_id, title, project_id
7323+ FROM orchestration_v2_projection_threads
7324+ WHERE deleted_at IS NULL AND thread_id IN ${ sql . in ( threadIds ) }
7325+ ` ;
7326+ return Object . fromEntries (
7327+ rows . map ( ( row ) => [ row . thread_id , { title : row . title , projectId : row . project_id } ] ) ,
7328+ ) ;
7329+ } , Effect . mapError ( shellSnapshotReadError ) ) ;
7330+
73097331 const getThreadTitles = Effect . fn ( "ProjectionStore.getThreadTitles" ) ( function * (
73107332 threadIds : ReadonlyArray < ThreadId > ,
73117333 ) {
@@ -7485,6 +7507,7 @@ export const layer: Layer.Layer<ProjectionStoreV2, never, SqlClient.SqlClient> =
74857507 getSettlementCandidates : readOnReader ( getSettlementCandidates ) ,
74867508 getThreadsWithPullRequests : readOnReader ( getThreadsWithPullRequests ) ,
74877509 getThreadTitles : readOnReader ( getThreadTitles ) ,
7510+ getThreadLinkMetadata : readOnReader ( getThreadLinkMetadata ) ,
74887511 getThreadWorktreePaths : readOnReader ( getThreadWorktreePaths ) ,
74897512 getOpenRemoteDelegatedTasks : getOpenRemoteDelegatedTasks . pipe ( NodeSqliteClient . readOnly ) ,
74907513 getThreadProjection : readOnReader ( getThreadProjection ) ,
0 commit comments