Skip to content

Commit c35697f

Browse files
committed
Merge remote-tracking branch 'origin/master' into jupyter-llm-8500
2 parents 93ebf3f + 3e752b9 commit c35697f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+1534
-1141
lines changed

src/.claude/settings.json

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,39 @@
11
{
22
"permissions": {
33
"allow": [
4+
"Bash(../node_modules/.bin/tsc:*)",
5+
"Bash(NODE_OPTIONS=--max-old-space-size=8192 ../node_modules/.bin/tsc --noEmit)",
6+
"Bash(curl:*)",
7+
"Bash(docker run:*)",
48
"Bash(find:*)",
59
"Bash(gh pr view:*)",
610
"Bash(gh:*)",
711
"Bash(git add:*)",
12+
"Bash(git checkout:*)",
813
"Bash(git commit:*)",
14+
"Bash(git push:*)",
915
"Bash(grep:*)",
1016
"Bash(node:*)",
1117
"Bash(npm show:*)",
18+
"Bash(npm view:*)",
1219
"Bash(npx tsc:*)",
1320
"Bash(pnpm build:*)",
21+
"Bash(pnpm i18n:*)",
1422
"Bash(pnpm ts-build:*)",
1523
"Bash(pnpm tsc:*)",
1624
"Bash(prettier -w:*)",
25+
"Bash(psql:*)",
1726
"WebFetch(domain:cocalc.com)",
1827
"WebFetch(domain:doc.cocalc.com)",
1928
"WebFetch(domain:docs.anthropic.com)",
2029
"WebFetch(domain:github.com)",
21-
"Bash(git checkout:*)",
22-
"Bash(git push:*)",
23-
"Bash(NODE_OPTIONS=--max-old-space-size=8192 ../node_modules/.bin/tsc --noEmit)",
24-
"Bash(docker run:*)",
25-
"Bash(../node_modules/.bin/tsc:*)",
26-
"Bash(npm view:*)",
27-
"WebFetch(domain:www.anthropic.com)",
2830
"WebFetch(domain:mistral.ai)",
29-
"Bash(pnpm i18n:*)",
30-
"WebFetch(domain:simplelocalize.io)"
31+
"WebFetch(domain:simplelocalize.io)",
32+
"Bash(pnpm list:*)",
33+
"Bash(pnpm why:*)",
34+
"mcp__github__get_issue",
35+
"WebFetch(domain:www.anthropic.com)",
36+
"mcp__cclsp__find_definition"
3137
],
3238
"deny": []
3339
}

src/CLAUDE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ CoCalc is organized as a monorepo with key packages:
7373
- **TypeScript React Components**: All frontend code is TypeScript with proper typing
7474
- **Modular Store System**: Each feature has its own store/actions (AccountStore, BillingStore, etc.)
7575
- **WebSocket Communication**: Real-time communication with backend via WebSocket messages
76+
- **Authentication Waiting**: When frontend code needs to wait for user authentication, use `redux.getStore("account").async_wait({ until: () => store.get_account_id() != null, timeout: 0 })` to wait indefinitely until authentication completes
77+
- **Conat DKV Usage**: For key-value storage with real-time sync, use `webapp_client.conat_client.dkv({ account_id, name: "store-name" })` to get a distributed key-value store that syncs across sessions
7678

7779
#### Backend Architecture
7880

@@ -81,6 +83,8 @@ CoCalc is organized as a monorepo with key packages:
8183
- **Conat System**: Container orchestration for compute servers
8284
- **Event-Driven Architecture**: Extensive use of EventEmitter patterns
8385
- **Microservice-like Packages**: Each package handles specific functionality
86+
- **Database Access**: Use `getPool()` from `@cocalc/database/pool` for direct database queries in hub/backend code. Example: `const pool = getPool(); const { rows } = await pool.query('SELECT * FROM table WHERE id = $1', [id]);`
87+
- **Hub Migration Functions**: Migration functions in hub should be designed to run once at startup, use batch processing with delays between batches to avoid database saturation
8488

8589
#### Communication Patterns
8690

src/packages/conat/service/typed.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type { Options, ServiceCall } from "./service";
99
export type { ConatService };
1010

1111
export interface Extra {
12-
ping: typeof pingConatService;
12+
ping: (opts?: { maxWait?: number }) => Promise<void>;
1313
waitFor: (opts?: { maxWait?: number }) => Promise<void>;
1414
}
1515

src/packages/database/postgres/news.ts

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@ export function clearCache(): void {
2323
const Q_FEED = `
2424
SELECT
2525
id, channel, title, text, url,
26-
extract(epoch from date::timestamp)::integer as date
26+
extract(epoch from date::timestamp)::integer as date,
27+
extract(epoch from until::timestamp)::integer as until
2728
FROM news
2829
WHERE news.date <= NOW()
2930
AND hide IS NOT TRUE
3031
AND channel != '${EVENT_CHANNEL}'
32+
AND (until IS NULL OR until > NOW())
3133
ORDER BY date DESC
3234
LIMIT 100`;
3335

@@ -40,7 +42,8 @@ export async function getFeedData(): Promise<NewsItem[]> {
4042
const Q_BY_ID = `
4143
SELECT
4244
id, channel, title, text, url, hide, tags,
43-
extract(epoch from date::timestamptz)::INTEGER as date
45+
extract(epoch from date::timestamptz)::INTEGER as date,
46+
extract(epoch from until::timestamptz)::INTEGER as until
4447
FROM news
4548
WHERE id = $1`;
4649

@@ -56,7 +59,9 @@ const Q_BY_ID_USER = `
5659
SELECT
5760
id, channel, title, text, url, hide, tags, history,
5861
date >= NOW() as future,
59-
extract(epoch from date::timestamptz)::INTEGER as date
62+
until IS NOT NULL AND until <= NOW() as expired,
63+
extract(epoch from date::timestamptz)::INTEGER as date,
64+
extract(epoch from until::timestamptz)::INTEGER as until
6065
FROM news
6166
WHERE id = $1`;
6267

@@ -68,6 +73,7 @@ WHERE date >= (SELECT date FROM news WHERE id = $1)
6873
AND hide IS NOT TRUE
6974
AND date < NOW()
7075
AND channel != '${EVENT_CHANNEL}'
76+
AND (until IS NULL OR until > NOW())
7177
ORDER BY date ASC, id ASC
7278
LIMIT 1`;
7379

@@ -79,6 +85,7 @@ WHERE date <= (SELECT date FROM news WHERE id = $1)
7985
AND hide IS NOT TRUE
8086
AND date < NOW()
8187
AND channel != '${EVENT_CHANNEL}'
88+
AND (until IS NULL OR until > NOW())
8289
ORDER BY date DESC, id DESC
8390
LIMIT 1`;
8491

@@ -104,7 +111,9 @@ const Q_INDEX = `
104111
SELECT
105112
id, channel, title, text, url, hide, tags,
106113
date >= NOW() as future,
107-
extract(epoch from date::timestamptz)::INTEGER as date
114+
until IS NOT NULL AND until <= NOW() as expired,
115+
extract(epoch from date::timestamptz)::INTEGER as date,
116+
extract(epoch from until::timestamptz)::INTEGER as until
108117
FROM news
109118
WHERE channel <> '${EVENT_CHANNEL}'
110119
ORDER BY date DESC
@@ -122,11 +131,13 @@ export async function getIndex(
122131
const Q_MOST_RECENT = `
123132
SELECT
124133
id, channel, title, tags,
125-
extract(epoch from date::timestamptz)::INTEGER as date
134+
extract(epoch from date::timestamptz)::INTEGER as date,
135+
extract(epoch from until::timestamptz)::INTEGER as until
126136
FROM news
127137
WHERE date <= NOW()
128138
AND hide IS NOT TRUE
129139
AND channel != '${EVENT_CHANNEL}'
140+
AND (until IS NULL OR until > NOW())
130141
ORDER BY date DESC
131142
LIMIT 1`;
132143

@@ -137,11 +148,13 @@ export async function getMostRecentNews(): Promise<RecentHeadline | null> {
137148
const Q_RECENT = `
138149
SELECT
139150
id, channel, title, tags,
140-
extract(epoch from date::timestamptz)::INTEGER as date
151+
extract(epoch from date::timestamptz)::INTEGER as date,
152+
extract(epoch from until::timestamptz)::INTEGER as until
141153
FROM news
142154
WHERE date <= NOW()
143155
AND channel != '${EVENT_CHANNEL}'
144156
AND hide IS NOT TRUE
157+
AND (until IS NULL OR until > NOW())
145158
ORDER BY date DESC
146159
LIMIT $1`;
147160

@@ -158,11 +171,13 @@ export async function getRecentHeadlines(
158171
const Q_UPCOMING_NEWS_CHANNEL_ITEMS = `
159172
SELECT
160173
id, channel, title, text, url, tags,
161-
extract(epoch from date::timestamp)::integer as date
174+
extract(epoch from date::timestamp)::integer as date,
175+
extract(epoch from until::timestamp)::integer as until
162176
FROM news
163177
WHERE date >= NOW()
164178
AND channel = $1
165179
AND hide IS NOT TRUE
180+
AND (until IS NULL OR until > NOW())
166181
ORDER BY date
167182
LIMIT 100`;
168183

@@ -176,11 +191,13 @@ export async function getUpcomingNewsChannelItems(
176191
const Q_PAST_NEWS_CHANNEL_ITEMS = `
177192
SELECT
178193
id, channel, title, text, url, tags,
179-
extract(epoch from date::timestamp)::integer as date
194+
extract(epoch from date::timestamp)::integer as date,
195+
extract(epoch from until::timestamp)::integer as until
180196
FROM news
181197
WHERE date <= NOW()
182198
AND channel = $1
183199
AND hide IS NOT TRUE
200+
AND (until IS NULL OR until > NOW())
184201
ORDER BY date DESC
185202
LIMIT 100`;
186203

0 commit comments

Comments
 (0)