Skip to content

Commit e17c3c7

Browse files
authored
Disable meet functionality and remove unused code (#1967)
# READ CAREFULLY THEN REMOVE Remove bullet points that are not relevant. PLEASE REFRAIN FROM USING AI TO WRITE YOUR CODE AND PR DESCRIPTION. IF YOU DO USE AI TO WRITE YOUR CODE PLEASE PROVIDE A DESCRIPTION AND REVIEW IT CAREFULLY. MAKE SURE YOU UNDERSTAND THE CODE YOU ARE SUBMITTING USING AI. - Pull requests that do not follow these guidelines will be closed without review or comment. - If you use AI to write your PR description your pr will be close without review or comment. - If you are unsure about anything, feel free to ask for clarification. ## Description Please provide a clear description of your changes. --- ## Type of Change Please delete options that are not relevant. - [ ] 🐛 Bug fix (non-breaking change which fixes an issue) - [ ] ✨ New feature (non-breaking change which adds functionality) - [ ] 💥 Breaking change (fix or feature with breaking changes) - [ ] 📝 Documentation update - [ ] 🎨 UI/UX improvement - [ ] 🔒 Security enhancement - [ ] ⚡ Performance improvement ## Areas Affected Please check all that apply: - [ ] Email Integration (Gmail, IMAP, etc.) - [ ] User Interface/Experience - [ ] Authentication/Authorization - [ ] Data Storage/Management - [ ] API Endpoints - [ ] Documentation - [ ] Testing Infrastructure - [ ] Development Workflow - [ ] Deployment/Infrastructure ## Testing Done Describe the tests you've done: - [ ] Unit tests added/updated - [ ] Integration tests added/updated - [ ] Manual testing performed - [ ] Cross-browser testing (if UI changes) - [ ] Mobile responsiveness verified (if UI changes) ## Security Considerations For changes involving data or authentication: - [ ] No sensitive data is exposed - [ ] Authentication checks are in place - [ ] Input validation is implemented - [ ] Rate limiting is considered (if applicable) ## Checklist - [ ] I have read the [CONTRIBUTING](https://github.com/Mail-0/Zero/blob/staging/.github/CONTRIBUTING.md) document - [ ] My code follows the project's style guidelines - [ ] I have performed a self-review of my code - [ ] I have commented my code, particularly in complex areas - [ ] I have updated the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix/feature works - [ ] All tests pass locally - [ ] Any dependent changes are merged and published ## Additional Notes Add any other context about the pull request here. ## Screenshots/Recordings Add screenshots or recordings here if applicable. --- _By submitting this pull request, I confirm that my contribution is made under the terms of the project's license._ <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Disabled the meet feature across the app and removed unused code related to meet functionality. - **Refactors** - Commented out meet-related UI and logic in the sidebar. - Added an environment flag to control meet availability. - Updated backend routes to check the flag and return 501 if meet is disabled. - Deleted unused meet code and cleaned up server files. <!-- End of auto-generated description by cubic. --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added environment variable to enable or disable the meeting creation feature. * Introduced thread-level resynchronization and improved thread fetching performance. * **Bug Fixes** * Meeting creation is now disabled in the sidebar and backend when the feature flag is off, preventing unintended access. * **Refactor** * Improved concurrency for shard data operations and optimized thread retrieval logic. * Removed legacy workflow functions for a cleaner codebase. * **Chores** * Removed scheduled cron triggers from the local server environment configuration. * **Other** * Enhanced synchronization after sending emails and creating drafts to ensure up-to-date thread information. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 0a375e7 commit e17c3c7

File tree

9 files changed

+93
-431
lines changed

9 files changed

+93
-431
lines changed

apps/mail/components/ui/app-sidebar.tsx

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import {
77
} from '@/components/ui/dialog';
88
import { Sidebar, SidebarContent, SidebarFooter, SidebarHeader } from '@/components/ui/sidebar';
99
import { navigationConfig, bottomNavItems } from '@/config/navigation';
10-
import { useTRPC } from '@/providers/query-provider';
10+
// import { useTRPC } from '@/providers/query-provider';
1111
import { useSidebar } from '@/components/ui/sidebar';
1212
import { CreateEmail } from '../create/create-email';
13-
import { useMutation } from '@tanstack/react-query';
13+
// import { useMutation } from '@tanstack/react-query';
1414
import { PencilCompose, X } from '../icons/icons';
1515
import { useBilling } from '@/hooks/use-billing';
1616
import { useIsMobile } from '@/hooks/use-mobile';
@@ -22,16 +22,16 @@ import { useStats } from '@/hooks/use-stats';
2222
import { useLocation } from 'react-router';
2323
import { cn, FOLDERS } from '@/lib/utils';
2424
import { m } from '@/paraglide/messages';
25-
import { Video } from 'lucide-react';
25+
// import { Video } from 'lucide-react';
2626
import { NavUser } from './nav-user';
2727
import { NavMain } from './nav-main';
2828
import { useQueryState } from 'nuqs';
29-
import { toast } from 'sonner';
29+
// import { toast } from 'sonner';
3030

3131
export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
3232
const { isPro, isLoading } = useBilling();
33-
const trpc = useTRPC();
34-
const { mutateAsync: createMeet } = useMutation(trpc.meet.create.mutationOptions());
33+
// const trpc = useTRPC();
34+
// const { mutateAsync: createMeet } = useMutation(trpc.meet.create.mutationOptions());
3535
const [showUpgrade, setShowUpgrade] = useState(() => {
3636
if (typeof window !== 'undefined') {
3737
return localStorage.getItem('hideUpgradeCard') !== 'true';
@@ -76,18 +76,18 @@ export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
7676
const showComposeButton = currentSection === 'mail';
7777
const { state } = useSidebar();
7878

79-
const handleCreateMeet = async () => {
80-
try {
81-
const {
82-
data: { id },
83-
} = await createMeet();
84-
navigator.clipboard.writeText(`https://meet.0.email/${id}`);
85-
toast.success('Meeting linked copied to clipboard');
86-
} catch (error) {
87-
console.error(error);
88-
toast.error('Failed to create meeting');
89-
}
90-
};
79+
// const handleCreateMeet = async () => {
80+
// try {
81+
// const {
82+
// data: { id },
83+
// } = await createMeet();
84+
// navigator.clipboard.writeText(`https://meet.0.email/${id}`);
85+
// toast.success('Meeting linked copied to clipboard');
86+
// } catch (error) {
87+
// console.error(error);
88+
// toast.error('Failed to create meeting');
89+
// }
90+
// };
9191

9292
return (
9393
<div>
@@ -104,17 +104,17 @@ export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
104104

105105
{showComposeButton && (
106106
<div className="flex gap-1">
107-
<div className={cn(isPro ? 'w-[80%]' : 'w-full')}>
107+
<div className={cn('w-full')}>
108108
<ComposeButton />
109109
</div>
110-
{isPro ? (
110+
{/* {isPro ? (
111111
<button
112112
onClick={handleCreateMeet}
113113
className="hover:bg-muted-foreground/10 inline-flex h-8 w-[20%] items-center justify-center gap-1 overflow-hidden rounded-lg border bg-white px-1.5 dark:border-none dark:bg-[#313131]"
114114
>
115115
<Video className="text-muted-foreground h-4 w-4" />
116116
</button>
117-
) : null}
117+
) : null} */}
118118
</div>
119119
)}
120120
</SidebarHeader>

apps/server/src/env.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ export type ZeroEnv = {
9393
DEV_PROXY: string;
9494
MEET_AUTH_HEADER: string;
9595
MEET_API_URL: string;
96+
ENABLE_MEET: 'true' | 'false';
9697
};
9798

9899
const env = _env as ZeroEnv;

apps/server/src/lib/server-utils.ts

Lines changed: 51 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { IGetThreadResponse, IGetThreadsResponse } from './driver/types';
22
import { OutgoingMessageType } from '../routes/agent/types';
33
import { getContext } from 'hono/context-storage';
44
import { connection } from '../db/schema';
5+
import { defaultPageSize } from './utils';
56
import type { HonoContext } from '../ctx';
67
import { createClient } from 'dormroom';
78
import { createDriver } from './driver';
@@ -350,21 +351,47 @@ export const getZeroAgent = async (connectionId: string, executionCtx?: Executio
350351
return agent;
351352
};
352353

354+
export const getZeroAgentFromShard = async (connectionId: string, shardId: string) => {
355+
const agent = await getShardClient(connectionId, shardId);
356+
return agent;
357+
};
358+
353359
export const forceReSync = async (connectionId: string) => {
354360
const registry = await getRegistryClient(connectionId);
355361
const allShards = await listShards(registry);
356-
for (const { shard_id: id } of allShards) {
357-
const shard = await getShardClient(connectionId, id);
358-
await shard.exec(`DROP TABLE IF EXISTS threads`);
359-
await shard.exec(`DROP TABLE IF EXISTS thread_labels`);
360-
await shard.exec(`DROP TABLE IF EXISTS labels`);
361-
}
362+
363+
await Promise.all(
364+
allShards.map(async ({ shard_id: id }) => {
365+
const shard = await getShardClient(connectionId, id);
366+
await Promise.all([
367+
shard.exec(`DROP TABLE IF EXISTS threads`),
368+
shard.exec(`DROP TABLE IF EXISTS thread_labels`),
369+
shard.exec(`DROP TABLE IF EXISTS labels`),
370+
]);
371+
}),
372+
);
373+
362374
await deleteAllShards(registry);
375+
363376
const agent = await getZeroAgent(connectionId);
364377
await agent.stub.forceReSync();
365378
};
366379

367-
380+
export const reSyncThread = async (connectionId: string, threadId: string) => {
381+
try {
382+
const { result: thread, shardId } = await getThread(connectionId, threadId);
383+
const agent = await getZeroAgentFromShard(connectionId, shardId);
384+
await agent.stub.syncThread({ threadId });
385+
} catch (error) {
386+
console.error(`[ZeroAgent] Thread not found for threadId: ${threadId}`);
387+
}
388+
if (thread) {
389+
const agent = await getZeroAgentFromShard(connectionId, shardId);
390+
await agent.stub.syncThread({ threadId });
391+
} else {
392+
console.error(`[ZeroAgent] Thread not found for threadId: ${threadId}`);
393+
}
394+
};
368395

369396
export const getThreadsFromDB = async (
370397
connectionId: string,
@@ -379,7 +406,17 @@ export const getThreadsFromDB = async (
379406
// Fire and forget - don't block the thread query on state updates
380407
void sendDoState(connectionId);
381408

382-
const maxResults = params.maxResults ?? 20;
409+
const maxResults = params.maxResults ?? defaultPageSize;
410+
411+
if (maxResults === defaultPageSize && !params.pageToken && !params.q) {
412+
return Effect.promise(async () => {
413+
const agent = await getZeroAgent(connectionId);
414+
return await agent.stub.getThreadsFromDB({
415+
...params,
416+
maxResults: maxResults,
417+
});
418+
}).pipe(Effect.runPromise);
419+
}
383420

384421
return Effect.runPromise(
385422
aggregateShardDataEffect<IGetThreadsResponse>(
@@ -388,23 +425,23 @@ export const getThreadsFromDB = async (
388425
Effect.promise(() =>
389426
shard.stub.getThreadsFromDB({
390427
...params,
391-
maxResults: maxResults * 2, // Request more from each shard to ensure we have enough
428+
maxResults: maxResults,
392429
}),
393430
),
394431
(shardResults) => {
395432
// Combine all threads from all shards
396433
const allThreads = shardResults.flatMap((result) => result.threads);
397-
434+
398435
// Sort by some criteria if needed (assuming threads have a sortable field)
399436
// allThreads.sort((a, b) => new Date(b.updated_at).getTime() - new Date(a.updated_at).getTime());
400-
437+
401438
// Take only the requested amount
402439
const threads = allThreads.slice(0, maxResults);
403-
440+
404441
// Determine if there's a next page token (simplified logic)
405442
const hasMoreResults = allThreads.length > maxResults;
406-
const nextPageToken = hasMoreResults
407-
? shardResults.find(r => r.nextPageToken)?.nextPageToken || null
443+
const nextPageToken = hasMoreResults
444+
? shardResults.find((r) => r.nextPageToken)?.nextPageToken || null
408445
: null;
409446

410447
return {

0 commit comments

Comments
 (0)