Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: additional simplify — sort copy, static imports, centralize OAuth URI

Adam Eivy0510e991385c
diff --git a/client/src/components/calendar/ReviewTab.jsx b/client/src/components/calendar/ReviewTab.jsx
index 1f4ac99f24..9a0cd6f2aa 100644
--- a/client/src/components/calendar/ReviewTab.jsx
+++ b/client/src/components/calendar/ReviewTab.jsx
@@ -182,7 +182,7 @@ export default function ReviewTab() {
</div>
) : (
<div className="space-y-2">
- {review.events
+ {[...review.events]
.sort((a, b) => {
if (a.isAllDay && !b.isAllDay) return -1;
if (!a.isAllDay && b.isAllDay) return 1;
diff --git a/server/services/calendarGoogleApiSync.js b/server/services/calendarGoogleApiSync.js
index b5e8e56652..dfce20a58b 100644
--- a/server/services/calendarGoogleApiSync.js
+++ b/server/services/calendarGoogleApiSync.js
@@ -1,6 +1,6 @@
import { google } from 'googleapis';
import { getAuthenticatedClient } from './googleAuth.js';
-import { getAccount, mergeDiscoveredSubcalendars } from './calendarAccounts.js';
+import { getAccount, updateSubcalendars, mergeDiscoveredSubcalendars } from './calendarAccounts.js';
import { pushSyncEvents, getSyncDateRange } from './calendarGoogleSync.js';
export async function apiSyncAccount(accountId, io) {
@@ -94,7 +94,6 @@ export async function apiDiscoverCalendars(accountId) {
}));
const merged = mergeDiscoveredSubcalendars(account.subcalendars, discovered);
- const { updateSubcalendars } = await import('./calendarAccounts.js');
await updateSubcalendars(accountId, merged);
console.log(`📅 Discovered ${allCalendars.length} calendars via Google API for ${account.name}`);
diff --git a/server/services/calendarGoogleSync.js b/server/services/calendarGoogleSync.js
index d4d8b41be8..ebfff80f3b 100644
--- a/server/services/calendarGoogleSync.js
+++ b/server/services/calendarGoogleSync.js
@@ -1,7 +1,7 @@
import { v4 as uuidv4 } from 'uuid';
import { createHash } from 'crypto';
import { spawn } from 'child_process';
-import { getAccount, updateSyncStatus, mergeDiscoveredSubcalendars } from './calendarAccounts.js';
+import { getAccount, updateSyncStatus, updateSubcalendars, mergeDiscoveredSubcalendars } from './calendarAccounts.js';
import { loadCache, saveCache } from './calendarSync.js';
function md5(str) {
@@ -235,8 +235,6 @@ Output NOTHING else — just the JSON array.`;
// Merge with existing subcalendars (preserve enabled/dormant state)
const merged = mergeDiscoveredSubcalendars(account.subcalendars, calendars);
- // Save merged subcalendars
- const { updateSubcalendars } = await import('./calendarAccounts.js');
await updateSubcalendars(accountId, merged);
console.log(`📅 Discovered ${calendars.length} calendars for ${account.name}`);
diff --git a/server/services/googleAuth.js b/server/services/googleAuth.js
index 91ad830faf..42864bf112 100644
--- a/server/services/googleAuth.js
+++ b/server/services/googleAuth.js
@@ -7,6 +7,7 @@ const AUTH_DIR = join(PATHS.calendar, 'google-auth');
const CREDENTIALS_FILE = join(AUTH_DIR, 'credentials.json');
const TOKENS_FILE = join(AUTH_DIR, 'tokens.json');
const SCOPES = ['https://www.googleapis.com/auth/calendar.readonly'];
+export const OAUTH_REDIRECT_URI = `http://localhost:${process.env.PORT || 5555}/api/calendar/google/oauth/callback`;
let oAuth2Client = null;
@@ -23,7 +24,7 @@ export async function getCredentials() {
export async function saveCredentials({ clientId, clientSecret }) {
await ensureAuthDir();
- const credentials = { clientId, clientSecret, redirectUri: 'http://localhost:5555/api/calendar/google/oauth/callback' };
+ const credentials = { clientId, clientSecret, redirectUri: OAUTH_REDIRECT_URI };
await writeFile(CREDENTIALS_FILE, JSON.stringify(credentials, null, 2));
oAuth2Client = null; // Reset client
console.log('📅 Google OAuth credentials saved');
@@ -54,7 +55,7 @@ function createOAuth2Client(credentials) {
return new google.auth.OAuth2(
credentials.clientId,
credentials.clientSecret,
- credentials.redirectUri || 'http://localhost:5555/api/calendar/google/oauth/callback'
+ credentials.redirectUri || OAUTH_REDIRECT_URI
);
}
diff --git a/server/services/googleOAuthAutoConfig.js b/server/services/googleOAuthAutoConfig.js
index 274fc1600a..d0d0da2d0f 100644
--- a/server/services/googleOAuthAutoConfig.js
+++ b/server/services/googleOAuthAutoConfig.js
@@ -17,9 +17,7 @@
*/
import { findOrOpenPage, evaluateOnPage, getPages } from './messagePlaywrightSync.js';
import { navigateToUrl } from './browserService.js';
-import { saveCredentials, getAuthUrl } from './googleAuth.js';
-
-const REDIRECT_URI = 'http://localhost:5555/api/calendar/google/oauth/callback';
+import { saveCredentials, getAuthUrl, OAUTH_OAUTH_REDIRECT_URI } from './googleAuth.js';
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
@@ -356,8 +354,8 @@ export async function runAutomatedSetup(userEmail, io) {
if (!empty) return false;
empty.focus();
const setter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value')?.set;
- if (setter) setter.call(empty, '${REDIRECT_URI}');
- else empty.value = '${REDIRECT_URI}';
+ if (setter) setter.call(empty, '${OAUTH_REDIRECT_URI}');
+ else empty.value = '${OAUTH_REDIRECT_URI}';
empty.dispatchEvent(new Event('input', { bubbles: true }));
empty.dispatchEvent(new Event('change', { bubbles: true }));
return true;