-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Slight rollback #1607
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Slight rollback #1607
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -189,19 +189,19 @@ export class AgentRpcDO extends RpcTarget { | |
|
|
||
| async markThreadsRead(threadIds: string[]) { | ||
| const result = await this.mainDo.markThreadsRead(threadIds); | ||
| await Promise.all(threadIds.map((id) => this.mainDo.syncThread(id))); | ||
| // await Promise.all(threadIds.map((id) => this.mainDo.syncThread(id))); | ||
| return result; | ||
|
Comment on lines
191
to
193
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logic: Sync after read/unread has been disabled. Consider implementing debounced sync or event-based updates to prevent stale UI state. |
||
| } | ||
|
|
||
| async markThreadsUnread(threadIds: string[]) { | ||
| const result = await this.mainDo.markThreadsUnread(threadIds); | ||
| await Promise.all(threadIds.map((id) => this.mainDo.syncThread(id))); | ||
| // await Promise.all(threadIds.map((id) => this.mainDo.syncThread(id))); | ||
| return result; | ||
| } | ||
|
|
||
| async modifyLabels(threadIds: string[], addLabelIds: string[], removeLabelIds: string[]) { | ||
| const result = await this.mainDo.modifyLabels(threadIds, addLabelIds, removeLabelIds); | ||
| await Promise.all(threadIds.map((id) => this.mainDo.syncThread(id))); | ||
| // await Promise.all(threadIds.map((id) => this.mainDo.syncThread(id))); | ||
| return result; | ||
| } | ||
|
|
||
|
|
@@ -233,13 +233,13 @@ export class AgentRpcDO extends RpcTarget { | |
|
|
||
| async markAsRead(threadIds: string[]) { | ||
| const result = await this.mainDo.markAsRead(threadIds); | ||
| await Promise.all(threadIds.map((id) => this.mainDo.syncThread(id))); | ||
| // await Promise.all(threadIds.map((id) => this.mainDo.syncThread(id))); | ||
| return result; | ||
| } | ||
|
|
||
| async markAsUnread(threadIds: string[]) { | ||
| const result = await this.mainDo.markAsUnread(threadIds); | ||
| await Promise.all(threadIds.map((id) => this.mainDo.syncThread(id))); | ||
| // await Promise.all(threadIds.map((id) => this.mainDo.syncThread(id))); | ||
| return result; | ||
| } | ||
|
|
||
|
|
@@ -310,19 +310,19 @@ export class ZeroAgent extends AIChatAgent<typeof env> { | |
| constructor(ctx: DurableObjectState, env: Env) { | ||
| super(ctx, env); | ||
| if (shouldDropTables) this.dropTables(); | ||
| this.sql` | ||
| CREATE TABLE IF NOT EXISTS threads ( | ||
| id TEXT PRIMARY KEY, | ||
| created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
| updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
| thread_id TEXT NOT NULL, | ||
| provider_id TEXT NOT NULL, | ||
| latest_sender TEXT, | ||
| latest_received_on TEXT, | ||
| latest_subject TEXT, | ||
| latest_label_ids TEXT | ||
| ); | ||
| `; | ||
| // this.sql` | ||
| // CREATE TABLE IF NOT EXISTS threads ( | ||
| // id TEXT PRIMARY KEY, | ||
| // created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
| // updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
| // thread_id TEXT NOT NULL, | ||
| // provider_id TEXT NOT NULL, | ||
| // latest_sender TEXT, | ||
| // latest_received_on TEXT, | ||
| // latest_subject TEXT, | ||
| // latest_label_ids TEXT | ||
| // ); | ||
| // `; | ||
| } | ||
|
|
||
| async dropTables() { | ||
|
|
@@ -388,10 +388,10 @@ export class ZeroAgent extends AIChatAgent<typeof env> { | |
| }); | ||
| if (_connection) this.driver = connectionToDriver(_connection); | ||
| this.ctx.waitUntil(conn.end()); | ||
| this.ctx.waitUntil(this.syncThreads('inbox')); | ||
| this.ctx.waitUntil(this.syncThreads('sent')); | ||
| this.ctx.waitUntil(this.syncThreads('spam')); | ||
| this.ctx.waitUntil(this.syncThreads('archive')); | ||
| // this.ctx.waitUntil(this.syncThreads('inbox')); | ||
| // this.ctx.waitUntil(this.syncThreads('sent')); | ||
| // this.ctx.waitUntil(this.syncThreads('spam')); | ||
| // this.ctx.waitUntil(this.syncThreads('archive')); | ||
|
Comment on lines
+391
to
+394
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logic: Removing automatic sync after auth setup could lead to initial data loading issues. Consider adding a manual sync trigger or user-controlled refresh mechanism. |
||
| } | ||
| } | ||
|
|
||
|
|
@@ -515,34 +515,34 @@ export class ZeroAgent extends AIChatAgent<typeof env> { | |
| this.cancelChatRequest(data.id); | ||
| break; | ||
| } | ||
| case IncomingMessageType.Mail_List: { | ||
| const result = await this.getThreadsFromDB({ | ||
| labelIds: data.labelIds, | ||
| folder: data.folder, | ||
| q: data.query, | ||
| max: data.maxResults, | ||
| cursor: data.pageToken, | ||
| }); | ||
| this.currentFolder = data.folder; | ||
| connection.send( | ||
| JSON.stringify({ | ||
| type: OutgoingMessageType.Mail_List, | ||
| result, | ||
| }), | ||
| ); | ||
| break; | ||
| } | ||
| case IncomingMessageType.Mail_Get: { | ||
| const result = await this.getThreadFromDB(data.threadId); | ||
| connection.send( | ||
| JSON.stringify({ | ||
| type: OutgoingMessageType.Mail_Get, | ||
| result, | ||
| threadId: data.threadId, | ||
| }), | ||
| ); | ||
| break; | ||
| } | ||
| // case IncomingMessageType.Mail_List: { | ||
| // const result = await this.getThreadsFromDB({ | ||
| // labelIds: data.labelIds, | ||
| // folder: data.folder, | ||
| // q: data.query, | ||
| // max: data.maxResults, | ||
| // cursor: data.pageToken, | ||
| // }); | ||
| // this.currentFolder = data.folder; | ||
| // connection.send( | ||
| // JSON.stringify({ | ||
| // type: OutgoingMessageType.Mail_List, | ||
| // result, | ||
| // }), | ||
| // ); | ||
| // break; | ||
| // } | ||
| // case IncomingMessageType.Mail_Get: { | ||
| // const result = await this.getThreadFromDB(data.threadId); | ||
| // connection.send( | ||
| // JSON.stringify({ | ||
| // type: OutgoingMessageType.Mail_Get, | ||
| // result, | ||
| // threadId: data.threadId, | ||
| // }), | ||
| // ); | ||
| // break; | ||
| // } | ||
| } | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: returning error string instead of throwing could break error handling expectations in caller code