Skip to content

Commit 78b8792

Browse files
zwpaperliangfungautofix-ci[bot]
authored
chore(page): change section stream type from PageSection to PageSecti… (#4167)
* chore(page): change section stream type from PageSection to PageSectionCreated * update: ui * [autofix.ci] apply automated fixes --------- Co-authored-by: liangfung <[email protected]> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent 6daae21 commit 78b8792

File tree

6 files changed

+58
-42
lines changed

6 files changed

+58
-42
lines changed

ee/tabby-schema/graphql/schema.graphql

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -972,13 +972,23 @@ type PageSectionContentDelta {
972972
delta: String!
973973
}
974974

975+
type PageSectionCreated {
976+
id: ID!
977+
pageId: ID!
978+
title: String!
979+
position: Int!
980+
createdAt: DateTime!
981+
updatedAt: DateTime!
982+
debugData: PageSectionDebugData
983+
}
984+
975985
type PageSectionDebugData {
976986
"Messages sent to LLM to generate the page section titles."
977987
generateSectionTitlesMessages: [ChatCompletionMessage!]!
978988
}
979989

980990
type PageSectionsCreated {
981-
sections: [PageSection!]!
991+
sections: [PageSectionCreated!]!
982992
debugData: PageSectionDebugData
983993
}
984994

@@ -1330,7 +1340,7 @@ union MessageAttachmentDoc = MessageAttachmentWebDoc | MessageAttachmentIssueDoc
13301340
union PageRunItem = PageCreated | PageContentDelta | PageContentCompleted | PageSectionsCreated | PageSectionAttachmentCodeFileList | PageSectionAttachmentCode | PageSectionAttachmentDoc | PageSectionContentDelta | PageSectionContentCompleted | PageCompleted
13311341

13321342
"Schema of page convert stream."
1333-
union SectionRunItem = PageSection | PageSectionAttachmentCodeFileList | PageSectionAttachmentCode | PageSectionAttachmentDoc | PageSectionContentDelta | PageSectionContentCompleted
1343+
union SectionRunItem = PageSectionCreated | PageSectionAttachmentCodeFileList | PageSectionAttachmentCode | PageSectionAttachmentDoc | PageSectionContentDelta | PageSectionContentCompleted
13341344

13351345
"""
13361346
Schema of thread run stream.

ee/tabby-schema/src/schema/page/types.rs

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,38 @@ pub struct PageSectionDebugData {
201201
pub generate_section_titles_messages: Vec<ChatCompletionMessage>,
202202
}
203203

204+
#[derive(GraphQLObject, Clone)]
205+
#[graphql(context = Context)]
206+
pub struct PageSectionCreated {
207+
pub id: ID,
208+
pub page_id: ID,
209+
pub title: String,
210+
pub position: i32,
211+
212+
pub created_at: DateTime<Utc>,
213+
pub updated_at: DateTime<Utc>,
214+
215+
pub debug_data: Option<PageSectionDebugData>,
216+
}
217+
218+
impl From<PageSection> for PageSectionCreated {
219+
fn from(value: PageSection) -> Self {
220+
Self {
221+
id: value.id,
222+
page_id: value.page_id,
223+
title: value.title,
224+
position: value.position,
225+
created_at: value.created_at,
226+
updated_at: value.updated_at,
227+
debug_data: None,
228+
}
229+
}
230+
}
231+
204232
#[derive(GraphQLObject, Clone)]
205233
#[graphql(context = Context)]
206234
pub struct PageSectionsCreated {
207-
pub sections: Vec<PageSection>,
235+
pub sections: Vec<PageSectionCreated>,
208236

209237
pub debug_data: Option<PageSectionDebugData>,
210238
}
@@ -365,7 +393,7 @@ pub enum PageRunItem {
365393
#[derive(GraphQLUnion)]
366394
#[graphql(context = Context)]
367395
pub enum SectionRunItem {
368-
PageSectionCreated(PageSection),
396+
PageSectionCreated(PageSectionCreated),
369397

370398
PageSectionAttachmentCodeFileList(PageSectionAttachmentCodeFileList),
371399
PageSectionAttachmentCode(PageSectionAttachmentCode),

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,16 @@ export function Page() {
193193
) => {
194194
if (!debugData || !sectionId) return
195195
setDebugData(prev => {
196-
if (!prev) return prev
196+
if (!prev) {
197+
return {
198+
sections: [
199+
{
200+
id: sectionId,
201+
...debugData
202+
}
203+
]
204+
}
205+
}
197206

198207
const sections = prev.sections || []
199208
let target = sections.find(s => s.id === sectionId)
@@ -412,7 +421,7 @@ export function Page() {
412421
data: CreatePageSectionRunSubscription['createPageSectionRun']
413422
) => {
414423
switch (data.__typename) {
415-
case 'PageSection': {
424+
case 'PageSectionCreated': {
416425
const { id, title, position } = data
417426
setCurrentSectionId(id)
418427
setPendingSectionIds(new Set([id]))

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

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,6 @@ export const createThreadToPageRunSubscription = graphql(/* GraphQL */ `
2727
id
2828
position
2929
title
30-
attachments {
31-
code {
32-
__typename
33-
gitUrl
34-
commit
35-
filepath
36-
language
37-
content
38-
startLine
39-
}
40-
codeFileList {
41-
__typename
42-
fileList
43-
truncated
44-
}
45-
}
4630
}
4731
debugData {
4832
__typename
@@ -193,22 +177,6 @@ export const createPageRunSubscription = graphql(/* GraphQL */ `
193177
id
194178
position
195179
title
196-
attachments {
197-
code {
198-
__typename
199-
gitUrl
200-
commit
201-
filepath
202-
language
203-
content
204-
startLine
205-
}
206-
codeFileList {
207-
__typename
208-
fileList
209-
truncated
210-
}
211-
}
212180
}
213181
debugData {
214182
__typename
@@ -329,7 +297,7 @@ export const createPageSectionRunSubscription = graphql(/* GraphQL */ `
329297
subscription createPageSectionRun($input: CreatePageSectionRunInput!) {
330298
createPageSectionRun(input: $input) {
331299
__typename
332-
... on PageSection {
300+
... on PageSectionCreated {
333301
id
334302
title
335303
position

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ const client = new Client({
146146
PageSectionContentCompleted: () => null,
147147
PageSectionAttachmentCode: () => null,
148148
PageSectionAttachmentDoc: () => null,
149-
SectionAttachment: () => null
149+
SectionAttachment: () => null,
150+
PageSectionCreated: () => null
150151
},
151152
resolvers: {
152153
Query: {

ee/tabby-webserver/src/service/page.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ impl PageService for PageServiceImpl {
204204
generate_section_titles_messages: messages,
205205
});
206206
}
207-
yield Ok(SectionRunItem::PageSectionCreated(section_from_db));
207+
yield Ok(SectionRunItem::PageSectionCreated(section_from_db.into()));
208208

209209
let mut attachments_stream = generate_section_with_attachments(
210210
debug_option.as_ref(),
@@ -445,7 +445,7 @@ impl PageServiceImpl {
445445
let mut page_sections = Vec::new();
446446
for section_title in &page_section_titles {
447447
let section = db.create_page_section(page_id.as_rowid()?, section_title).await?;
448-
page_sections.push(section_from_db(auth.clone(), section).await);
448+
page_sections.push(section_from_db(auth.clone(), section).await.into());
449449
}
450450

451451
yield Ok(PageRunItem::PageSectionsCreated(PageSectionsCreated {

0 commit comments

Comments
 (0)