Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/vnext/capability-charter.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ count and estimated retained bytes.

Provisional compressed bundle budgets:

- Framework-independent core with relation completion: 48 KiB
- Core plus CodeMirror adapter, excluding parser and dialect data: 75 KiB
- Each ordinary dialect module: 25 KiB
- Optional `node-sql-parser` chunk: no regression from its recorded baseline
Expand Down
75 changes: 71 additions & 4 deletions docs/vnext/session-primitives.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
Status: experimental walking skeleton
Import: `@marimo-team/codemirror-sql/vnext`

This entry point currently provides document ownership, atomic text/context
updates, opaque revisions, dialect registration, and lifecycle management. It
does not yet provide parsing, completion, diagnostics, hover, or navigation.
Those methods will be added only with working vertical slices.
This entry point provides document ownership, atomic text/context updates,
opaque revisions, dialect registration, lifecycle management, and
parser-independent relation completion. Diagnostics, hover, navigation, and
general expression completion are not yet available.

See [source coordinates](./source-coordinates.md) for the shared UTF-16 range
contract and the internal immutable source-snapshot model.
Expand Down Expand Up @@ -56,6 +56,73 @@ Use `{ kind: "replace", text }` for full replacement and
also supplies the complete embedded-region set for its resulting text. A
region-only transaction can replace or clear that set without a fake text edit.

## Relation completion

Completion works without a catalog for visible CTEs. A service can also own one
shared asynchronous relation-catalog provider:

```ts
const service = createSqlLanguageService<AppSqlContext>({
catalog: {
id: "app-catalog",
search: async (request, signal) => {
signal.throwIfAborted();
return {
coverage: { kind: "complete" },
epoch: { generation: 0, token: "initial" },
relations: [],
status: "ready",
};
},
},
completion: { catalogResponseBudgetMs: 40 },
dialects: [duckdbDialect()],
});

const session = service.openDocument({
context: {
dialect: "duckdb",
engine: "local",
catalog: { scope: "connection-incarnation:1" },
},
text: "SELECT * FROM ",
});

const subscription = session.onDidChange(({ reason }) => {
if (reason === "catalog" || reason === "catalog-availability") {
// Ask the editor adapter to request completion again.
}
});

const result = await session.complete({
position: 14,
trigger: { kind: "invoked" },
});

if (result.status === "ready" && session.isCurrent(result.revision)) {
for (const item of result.value.items) {
// Apply item.edit in the original document's UTF-16 coordinates.
}
}

subscription.dispose();
session.dispose();
service.dispose();
```

The catalog `scope` identifies a live connection incarnation, not a reusable
display name. Search responses distinguish complete, partial, paginated,
loading, and failed evidence. A ready result can therefore be incomplete; its
closed `issues` explain why, while `sources` reports catalog outcomes without
exposing provider errors or internal epochs.

The interactive catalog wait is bounded from the start of `complete()`. When
the budget expires, the session returns local evidence with a
`catalog-loading` issue and a checked remaining intent lease. Compatible
readiness advances the session revision and emits `catalog-availability`;
higher provider epochs emit `catalog`. Consumers must request completion again
and apply only results whose revision remains current.

## Dialect registration

`duckdbDialect()`, `postgresDialect()`, `bigQueryDialect()`, and
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"bench:local-relation-site": "vitest bench --run src/vnext/__tests__/local-relation-site.bench.ts",
"bench:parser-adapter": "vitest bench --run src/vnext/__tests__/node-sql-parser-adapter.bench.ts",
"bench:query-site": "vitest bench --run src/vnext/__tests__/query-site.bench.ts",
"bench:session-completion": "vitest bench --run src/vnext/__tests__/session-completion.bench.ts",
"bench:statement-index": "vitest bench --run src/vnext/__tests__/statement-index.bench.ts",
"test:package": "node ./scripts/clean.mjs && tsc && node ./scripts/package-smoke.mjs",
"demo": "vite build",
Expand Down
8 changes: 4 additions & 4 deletions scripts/worker-placement.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ const PARSER_MARKERS = [
"tableList",
];
const BIGQUERY_GZIP_LIMIT = 50 * 1024;
const CORE_TOTAL_GZIP_LIMIT = 16 * 1024;
const CORE_TOTAL_RAW_LIMIT = 52 * 1024;
const CORE_TOTAL_GZIP_LIMIT = 48 * 1024;
const CORE_TOTAL_RAW_LIMIT = 180 * 1024;
const POSTGRESQL_GZIP_LIMIT = 68 * 1024;
const WORKER_TOTAL_GZIP_LIMIT = 128 * 1024;
const WORKER_TOTAL_RAW_LIMIT = 570 * 1024;
const WORKER_TOTAL_GZIP_LIMIT = 160 * 1024;
const WORKER_TOTAL_RAW_LIMIT = 700 * 1024;
const MIME_TYPES = new Map([
[".css", "text/css; charset=utf-8"],
[".html", "text/html; charset=utf-8"],
Expand Down
Loading
Loading