Skip to content
Closed
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ See [STATUS.md](server/STATUS.md) to learn more about which features will remain

## UNRELEASED

- Preserve nested JSON nulls in Rust Loro object and array writes, including indexed array insertion (narrow backport from #2206).

- Batch accepted SYNC_PUSH resource projections and indexes per frame, with one durable flush on LAST (including an empty terminator). Persistence failures now reject the sync. Backported from #2361 to the Atomic plugins candidate without changing admission rules or signed-envelope validation.

- A plugin run no longer falls back to the server's agent for an app or
installation whose key is not on this node (#1644), and that check sees
installation identities (#1700, answer 8): an Installation's keyless
Expand Down
6 changes: 6 additions & 0 deletions TESTING_COVERAGE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
SYNC_PUSH candidate backport: counting/failing KV tests in `lib/src/db/test.rs` verify per-frame atomic projection/index application, import identity durability, staged table change logs and parent admission, wire-order duplicate-subject delta merging, empty-LAST flush failure and write failure propagation. `lib/tests/import_durability.rs` aborts and reopens the real store after LAST to verify resources, snapshots, envelopes and indexes. This does not establish a 100 ms sync target.

Schema-backed JSON table previews: `schemaJSONPreview.test.ts` covers prose, labeled booleans/lists, local references, nulls, order, unsupported schemas, bounded long wrappers and output bounds. `resource.nested-json-null.test.ts` verifies JSON nulls survive an exported/reopened Loro snapshot (fails on candidate22 before the narrow upstream fix). The Rust `json_nulls_survive_snapshots_and_list_edits` regression covers nested object/list null snapshot round trips and indexed list insertion. Native Playwright checks readable cells, full editing, bounded tooltips and row geometry at desktop/mobile sizes; grid loading is tested separately.

Bounded WebSocket reads: `browser/lib/src/store.read-fallback.test.ts` covers stalled OPEN sockets and authentication recovering over authenticated HTTP, local/remote budgets, deduplication, healthy sockets, explicit refusal, fallback failure, and POST using HTTP once. `websockets.test.ts` covers cancellation, ignored late responses and retained subscription pushes. Library/frame tests do not establish browser paint latency. Bulk GET_MANY retains its own timeout.

Server descriptor budget (2026-09-22): `server/src/serve.rs` tests the HTTP
connection budget at small, staging-sized, and effectively unlimited process
descriptor limits. Startup reads the process soft `RLIMIT_NOFILE`, limits Actix
Expand Down
3 changes: 3 additions & 0 deletions browser/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ This changelog covers all five packages, as they are (for now) updated as a whol

## UNRELEASED

- Recover stalled individual WebSocket reads over authenticated HTTP; show table loading status while membership is pending.
- Show schema-backed JSON table values as single-line readable previews with ellipses and text tooltips, while retaining full JSON editing and fallback for unsupported schemas. Preserve null fields inside nested JSON arrays when editing.

- An Installation page connects the integration-proxy platforms its release manifest declares (`proxy: [...]`, #1700): per platform, "Connect <platform>" (the proxy's `/connect`, then the signed redeem) or "Use existing connection", both after a consent step, then a delegation to the Installation's app id and `integrationConnections[platform] = connection_id` on the Installation, signed by the user. Disconnect removes the delegation at the proxy and the key. Only people who can write the Installation see the controls. An Installation that declares no platform and has no recorded connection makes no request to the proxy at all, including runtime registration.
- The page registers an Installation's runtimes with the integration proxy (#1700): each node's agent, published on an `InstallationRuntime` child, becomes a runtime of the Installation's app id via `POST /runtimes {app, agent, label}`, signed v2 with the user key. It happens when an Installation page or app frame opens and when a runtime child appears, and after a delegation. It is idempotent and does not hold up the UI; failures show as a toast. Revoking or uninstalling calls `DELETE /runtimes/{agent}`. A child counts only when its genesis was signed by the agent it names. Delegations and frame capabilities now name an Installation's `integrationAppAgent` rather than the node's agent from `GET /app-agent`, which stays the fallback for `createApp` apps and older Installations.
- App frames call the integration proxy directly, with a capability instead of a relay (ontola/atomic-plugins#54; replaces #1657's `proxy` relay and LocalThought's rotating connection codes, which the new proxy no longer issues). A frame makes its own non-extractable Ed25519 key in memory; the page checks that the connection is delegated to the app and signs a capability bound to that key (`integration-proxy-capability-v2`, 10 minutes); each request is signed by the frame key with a version 2 request signature. `store.proxy.request(...)` keeps its shape; it mints a new capability shortly before expiry and once more on a `capability_expired` refusal. View op `proxy` is gone, `proxyCapability` is new. Connecting no longer logs in at the proxy: the page redeems the handoff signed with the user key, which makes the user the connection's owner, then delegates it to the app (also signed). The connect bar offers an existing connection for the same platform, which only adds a delegation. Only apps with their own agent (made with `createApp`) can be given a connection for now; others are told so. Where WebCrypto has no Ed25519 the frame fails with a message saying so. Existing connections are not migrated: connect again.
Expand Down
62 changes: 54 additions & 8 deletions browser/data-browser/src/chunks/TablePage/EditorCells/JSONCell.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { JSONValue, useProperty } from '@tomic/react';
import {
JSONValue,
server,
useProperty,
useResource,
useValue,
} from '@tomic/react';

import { CellContainer, DisplayCellProps, EditCellProps } from './Type';

Expand All @@ -12,6 +18,34 @@ import { addIf } from '@helpers/addIf';
import { useTableEditorContext } from '@chunks/TableEditor/TableEditorContext';
import { useColumnLabel } from '../helpers/useColumnLabel';
import { InputJSON } from '@components/forms/InputJSON';
import { schemaJSONPreview } from './schemaJSONPreview';

function JSONPreview({
value,
property,
}: {
value: JSONValue;
property: string;
}) {
const propertyResource = useResource(property);
const [schema] = useValue(propertyResource, server.properties.jsonSchema);
const preview = schemaJSONPreview(value, schema);
const shortenedMessage =
'Preview shortened. Open edit dialog for complete JSON.';

return (
<Preview
title={
preview.truncated
? `${preview.text}\n${shortenedMessage}`
: preview.text
}
>
{preview.text}
{preview.truncated && <small> {shortenedMessage}</small>}
</Preview>
);
}

function JSONCellEdit({
value,
Expand Down Expand Up @@ -49,14 +83,12 @@ function JSONCellEdit({

useCellOptions(options);

const displayValue = JSON.stringify(value);

return (
<>
<IconButton title='Open edit dialog' onClick={show} autoFocus>
<FaPencil />
</IconButton>
<div>{displayValue}</div>
<JSONPreview value={value} property={property} />
<Dialog {...dialogProps} width='70ch'>
{isOpen && (
<>
Expand All @@ -80,10 +112,11 @@ function JSONCellEdit({
);
}

function JSONCellDisplay({ value }: DisplayCellProps<JSONValue>): JSX.Element {
const displayValue = JSON.stringify(value);

return <>{displayValue}</>;
function JSONCellDisplay({
value,
property,
}: DisplayCellProps<JSONValue>): JSX.Element {
return <JSONPreview value={value} property={property} />;
}

export const JSONCell: CellContainer<JSONValue> = {
Expand All @@ -94,3 +127,16 @@ export const JSONCell: CellContainer<JSONValue> = {
const StyledDialogContent = styled(Dialog.Content)`
padding-top: 2px;
`;

const Preview = styled.div`
flex: 1;
min-width: 0;
max-width: 100%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;

small {
opacity: 0.7;
}
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,256 @@
import { describe, expect, it } from 'vitest';
import { createElement } from 'react';
import { renderToStaticMarkup } from 'react-dom/server';
import { schemaJSONPreview } from './schemaJSONPreview';

// Synthetic schema and records. No provider or personal data fixtures.
const textSchema = {
type: 'object',
properties: { content: { type: 'string' } },
};
const schema = {
type: 'object',
properties: {
prose: { $ref: '#/$defs/Prose' },
list: {
type: 'object',
properties: {
entries: { type: 'array', items: { $ref: '#/$defs/Entry' } },
},
},
},
$defs: {
Prose: textSchema,
Entry: {
type: 'object',
properties: {
selected: { type: 'boolean', title: 'Selected' },
label: { $ref: '#/$defs/Prose' },
children: { type: 'array', items: { $ref: '#/$defs/Entry' } },
},
},
},
};

describe('schemaJSONPreview', () => {
it('unwraps a prose body and preserves its line breaks', () => {
expect(
schemaJSONPreview(
{ prose: { content: 'First line\nNext line' } },
schema,
),
).toEqual({
text: 'First line\nNext line',
readable: true,
truncated: false,
});
});

it('renders list order, explicit boolean states and nested items', () => {
const result = schemaJSONPreview(
{
list: {
entries: [
{ selected: true, label: { content: 'First item' } },
{
selected: false,
label: { content: 'Second item' },
children: [{ label: { content: 'Nested item' } }],
},
],
},
},
schema,
);

expect(result).toEqual({
text: '• Selected: ☑\n label: First item\n• Selected: ☐\n label: Second item\n children: • Nested item',
readable: true,
truncated: false,
});
});

it('does not invent a checkbox state when a boolean is absent or null', () => {
expect(
schemaJSONPreview(
{ label: { content: 'Plain item' } },
{
...schema.$defs.Entry,
$defs: schema.$defs,
},
).text,
).toBe('Plain item');
expect(
schemaJSONPreview(
{ selected: null, content: 'Unknown state' },
{
type: 'object',
properties: {
selected: { type: ['boolean', 'null'] },
content: { type: 'string' },
},
},
).text,
).toBe('selected: null\ncontent: Unknown state');
});

it('resolves escaped JSON pointers and OpenAPI-style local definitions', () => {
expect(
schemaJSONPreview(
{ content: 'Readable' },
{
$ref: '#/components/schemas/a~1b~0c',
components: { schemas: { 'a/b~c': textSchema } },
},
).text,
).toBe('Readable');
});

it('retains empty containers and explicit null values', () => {
expect(schemaJSONPreview(null, { type: 'null' }).text).toBe('null');
expect(schemaJSONPreview({}, { type: 'object', properties: {} }).text).toBe(
'{}',
);
expect(
schemaJSONPreview([], { type: 'array', items: { type: 'string' } }).text,
).toBe('[]');
});

it('handles schema numeric types and OpenAPI nullable values', () => {
expect(schemaJSONPreview(42, { type: 'integer' })).toEqual({
text: '42',
readable: true,
truncated: false,
});
expect(schemaJSONPreview(null, { type: 'string', nullable: true })).toEqual(
{
text: 'null',
readable: true,
truncated: false,
},
);
});

it('falls back to complete raw JSON for unsupported or missing schemas', () => {
const value = { content: 'Keep me', other: 42 };

for (const unsupportedSchema of [
undefined,
true,
{ oneOf: [textSchema] },
{ $ref: 'https://example.invalid/schema' },
{ $ref: '#/missing' },
textSchema, // The unknown field must not disappear behind a text wrapper.
{ type: 'array', items: { type: 'string' } },
]) {
const result = schemaJSONPreview(value, unsupportedSchema);
expect(result.readable).toBe(false);
expect(result.truncated).toBe(false);
expect(JSON.parse(result.text)).toEqual(value);
}
});

it('preserves source property order and schema titles', () => {
expect(
schemaJSONPreview(
{ second: 'B', first: 'A' },
{
type: 'object',
properties: {
first: { type: 'string' },
second: { type: 'string', title: 'Second field' },
},
},
).text,
).toBe('Second field: B\nfirst: A');
});

it('still unwraps long prose when its nested value exhausts the budget', () => {
const result = schemaJSONPreview(
{ prose: { content: `Original opening. ${'x'.repeat(10_000)}` } },
schema,
);

expect(result.readable).toBe(true);
expect(result.truncated).toBe(true);
expect(result.text).toMatch(/^Original opening\. x/);
expect(result.text).not.toContain('prose:');
expect(result.text).not.toContain('content:');
expect(result.text).toMatch(/…$/);
expect(result.text.length).toBeLessThanOrEqual(4000);
});

it('keeps a multi-field object label when its first long value exhausts the budget', () => {
const result = schemaJSONPreview(
{
first: `Original opening. ${'x'.repeat(10_000)}`,
second: 'Another field',
},
{
type: 'object',
properties: {
first: { type: 'string', title: 'First field' },
second: { type: 'string' },
},
},
);

expect(result.readable).toBe(true);
expect(result.truncated).toBe(true);
expect(result.text).toMatch(/^First field: Original opening\. x/);
expect(result.text).toMatch(/…$/);
expect(result.text.length).toBeLessThanOrEqual(4000);
});

it('bounds long text, wide arrays and recursive values with an explicit flag', () => {
const recursiveSchema = {
type: 'object',
properties: { child: { $ref: '#' } },
};
let nested: unknown = 'Leaf';
for (let i = 0; i < 100; i++) nested = { child: nested };

for (const [value, definition] of [
['x'.repeat(100_000), { type: 'string' }],
[
Array.from({ length: 10_000 }, () => 'x'),
{ type: 'array', items: { type: 'string' } },
],
[nested, recursiveSchema],
['x'.repeat(100_000), undefined],
[nested, undefined],
]) {
const result = schemaJSONPreview(value, definition);
expect(result.truncated).toBe(true);
expect(result.text.length).toBeLessThanOrEqual(4000);
expect(result.text).toContain('…');
}
});

it('terminates cyclic schema references using raw JSON fallback', () => {
const cyclic = {
$ref: '#/$defs/self',
$defs: { self: { $ref: '#/$defs/self' } },
};
expect(schemaJSONPreview({ content: 'Safe' }, cyclic).readable).toBe(false);
});

it('keeps HTML in values and schema labels as plain React text', () => {
const result = schemaJSONPreview(
{ content: '<img src=x onerror=alert(1)>', other: 'ok' },
{
type: 'object',
properties: {
content: { type: 'string', title: '<script>alert(2)</script>' },
other: { type: 'string' },
},
},
);
const html = renderToStaticMarkup(createElement('div', null, result.text));

expect(html).toContain('&lt;img');
expect(html).toContain('&lt;script&gt;');
expect(html).not.toContain('<img');
expect(html).not.toContain('<script>');
});
});
Loading
Loading