Skip to content

Commit a43394a

Browse files
feat(ui): add structured_doc page graphql types (#4151)
* feat(ui): add structured_doc page graphql types * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent 78dc000 commit a43394a

File tree

7 files changed

+53
-6
lines changed

7 files changed

+53
-6
lines changed

ee/tabby-ui/app/pages/components/page-main.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ export function Page() {
514514
pageId,
515515
titlePrompt: title,
516516
docQuery: {
517-
sourceIds: compact([page?.codeSourceId]),
517+
sourceIds: compact([page?.codeSourceId, 'page']),
518518
content: title,
519519
searchPublic: true
520520
},
@@ -619,7 +619,7 @@ export function Page() {
619619
}
620620
: null,
621621
docQuery: {
622-
sourceIds: compact([codeSourceId]),
622+
sourceIds: compact([codeSourceId, 'page']),
623623
content: titlePrompt,
624624
searchPublic: true
625625
},

ee/tabby-ui/app/pages/lib/query.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ export const createThreadToPageRunSubscription = graphql(/* GraphQL */ `
121121
}
122122
authorAt
123123
}
124+
... on AttachmentPageDoc {
125+
link
126+
title
127+
content
128+
}
124129
}
125130
score
126131
}
@@ -274,6 +279,11 @@ export const createPageRunSubscription = graphql(/* GraphQL */ `
274279
}
275280
authorAt
276281
}
282+
... on AttachmentPageDoc {
283+
link
284+
title
285+
content
286+
}
277287
}
278288
score
279289
}
@@ -383,6 +393,11 @@ export const createPageSectionRunSubscription = graphql(/* GraphQL */ `
383393
}
384394
authorAt
385395
}
396+
... on AttachmentPageDoc {
397+
link
398+
title
399+
content
400+
}
386401
}
387402
score
388403
}

ee/tabby-ui/app/search/components/search.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1037,7 +1037,9 @@ function getSourceInputs(
10371037
if (ctx) {
10381038
sourceIdsForDocQuery = uniq(
10391039
// Compatible with existing user messages
1040-
compact([repositorySourceId, ctx?.codeSourceId].concat(ctx.docSourceIds))
1040+
compact(
1041+
[repositorySourceId, ctx?.codeSourceId, 'page'].concat(ctx.docSourceIds)
1042+
)
10411043
)
10421044
searchPublic = ctx.searchPublic ?? false
10431045
sourceIdForCodeQuery = repositorySourceId || ctx.codeSourceId || undefined

ee/tabby-ui/components/message-markdown/doc-detail-view.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
getAttachmentDocContent,
1111
isAttachmentCommitDoc,
1212
isAttachmentIssueDoc,
13+
isAttachmentPageDoc,
1314
isAttachmentPullDoc,
1415
isAttachmentWebDoc
1516
} from '@/lib/utils'
@@ -51,9 +52,11 @@ export function DocDetailView({
5152
relevantDocument.title
5253
)
5354
const sourceUrl = link ? new URL(link) : null
54-
const author = isAttachmentWebDoc(relevantDocument)
55-
? undefined
56-
: relevantDocument.author
55+
const author =
56+
isAttachmentWebDoc(relevantDocument) ||
57+
isAttachmentPageDoc(relevantDocument)
58+
? undefined
59+
: relevantDocument.author
5760
const score = relevantDocument?.extra?.score
5861

5962
return (

ee/tabby-ui/lib/hooks/use-thread-run.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ const CreateThreadAndRunSubscription = graphql(/* GraphQL */ `
104104
}
105105
authorAt
106106
}
107+
... on MessageAttachmentPageDoc {
108+
link
109+
title
110+
content
111+
}
107112
}
108113
score
109114
}
@@ -205,6 +210,11 @@ const CreateThreadRunSubscription = graphql(/* GraphQL */ `
205210
}
206211
authorAt
207212
}
213+
... on MessageAttachmentPageDoc {
214+
link
215+
title
216+
content
217+
}
208218
}
209219
score
210220
}

ee/tabby-ui/lib/tabby/query.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,11 @@ export const listThreadMessages = graphql(/* GraphQL */ `
465465
}
466466
authorAt
467467
}
468+
... on MessageAttachmentPageDoc {
469+
title
470+
link
471+
content
472+
}
468473
}
469474
codeFileList {
470475
fileList
@@ -663,6 +668,11 @@ export const listPageSections = graphql(/* GraphQL */ `
663668
}
664669
authorAt
665670
}
671+
... on AttachmentPageDoc {
672+
link
673+
title
674+
content
675+
}
666676
}
667677
}
668678
}

ee/tabby-ui/lib/utils/attachment.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ export function isAttachmentIssueDoc(attachment: AttachmentDocItem) {
2828
)
2929
}
3030

31+
export function isAttachmentPageDoc(attachment: AttachmentDocItem) {
32+
return (
33+
attachment.__typename === 'AttachmentPageDoc' ||
34+
attachment.__typename === 'MessageAttachmentPageDoc'
35+
)
36+
}
37+
3138
export function getAttachmentDocContent(attachment: AttachmentDocItem) {
3239
switch (attachment.__typename) {
3340
case 'MessageAttachmentWebDoc':

0 commit comments

Comments
 (0)