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
6 changes: 4 additions & 2 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -376,18 +376,20 @@ ticketSchema.pre('save', async function () {

## @mieweb/ui Usage

**The component rules live in [`.github/instructions/mieweb-ui.instructions.md`](instructions/mieweb-ui.instructions.md)**, generated by `npx @mieweb/ui@0.10.0 init-agent` and applied automatically to `**/*.{ts,tsx,js,jsx}`. The same rules are mirrored into the `AGENTS.md` managed block for tools that read that convention.
**The component rules live in [`.github/instructions/mieweb-ui.instructions.md`](instructions/mieweb-ui.instructions.md)**, generated by `npx @mieweb/ui@0.11.0 init-agent` and applied automatically to `**/*.{ts,tsx,js,jsx}`. The same rules are mirrored into the `AGENTS.md` managed block for tools that read that convention.

That file is the single source of truth for component selection — it ships with the library and covers the full catalog, `ButtonGroup` usage, composition slots, variants, design tokens, and theming. Do not restate its rules here; they go stale as the library moves.

**Rerun `npx @mieweb/ui@<version> init-agent` after every `@mieweb/ui` upgrade** to refresh both targets, and commit the result.

Pin the version in that command to whatever `@mieweb/ui` the app is on, so the rules match the installed catalog. The `init-agent` CLI does not exist before 0.8.0; `npx` fetches it without installing it.

**The 0.7.3 hold is over.** The project sat on 0.7.3 because 0.8.0+ regressed the Kerebron `RichEditor` seeding the clock composer depends on. That regression is fixed as of **0.9.0** — verified by editing an existing Huddle post and confirming the editor seeds with its content, plus a full clock in/out cycle. The app is now on 0.10.0. The `SuperChat`/`SuperChatInbox` public type surface (`node_modules/@mieweb/ui/dist/components/SuperChat/index.d.ts`) is unchanged between 0.9.0 and 0.10.0 — no new reactions, replies, composer slots, or date separators — so [`docs/superchat-inbox-gaps.md`](docs/superchat-inbox-gaps.md) still applies as written.
**The 0.7.3 hold is over.** The project sat on 0.7.3 because 0.8.0+ regressed the Kerebron `RichEditor` seeding the clock composer depends on. That regression is fixed as of **0.9.0** — verified by editing an existing Huddle post and confirming the editor seeds with its content, plus a full clock in/out cycle. The app is now on 0.11.0, synced with mieweb/ui `main`. 0.11.0 adds a media view, agent and model selectors, `showHeader`, `placeholder` and `allowAttachments` to `SuperChat`, but still no reactions, replies, preview override or date separators — so [`docs/superchat-inbox-gaps.md`](docs/superchat-inbox-gaps.md) still applies as written.

**The app runs a vendored `@mieweb/ui`.** It installs `vendor/mieweb-ui.tgz`, built from the `vendor/ui` submodule — a branch of mieweb/ui where the library changes TimeHuddle needs are made as an upstream PR instead of being worked around here. Build with `npm run ui:build`, pull upstream with `npm run ui:sync`; the workflow is in [`vendor/README.md`](vendor/README.md).

**Kerebron is pinned to exactly 0.8.12 and patched.** `@mieweb/ui` 0.11.0 needs `@kerebron/*` 0.8.12 or newer and asks host apps to apply its Kerebron fixes themselves, since Kerebron is a peer dependency. They live in [`patches/`](patches/README.md) and are applied on install; that README says how to keep them in step with upstream.

**Before marking any page complete, verify: does it import from `@mieweb/ui`? If not, it's not done.**

### Code Quality Checklist
Expand Down
96 changes: 94 additions & 2 deletions .github/instructions/mieweb-ui.instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ When asked to create a table, data grid, or any tabular data view:

```tsx
import { DataVisNitroSource, DataVisNitroGrid } from '@mieweb/ui/datavis';
// Peer deps: npm install @mieweb/datavis datavis-ace
// Self-contained entry: @mieweb/datavis is bundled in and datavis-ace ships as
// a dependency of @mieweb/ui — no extra installs needed to use these.
```

## Rule 2: Buttons belong in a ButtonGroup
Expand Down Expand Up @@ -167,7 +168,19 @@ Tailwind: on Tailwind 4, add an `@source` for `@mieweb/ui` so library classes ar

If JSDoc, the console, or the docs mark something deprecated (`AGGrid` today), do not use it in new code and do not suppress the warning. Use the documented replacement.

## Rule 14: When existing components do not meet the need
## Rule 14: A component that renders a collection takes it through props

Anything that displays a list, board, calendar, timeline or inbox of records the caller owns is a **headless module**. It receives `items` / `loading` / `error` as props, hands changes back through `on*` callbacks typed `void | Promise<void>`, and navigates through `onOpen(id)` / `getHref(id)`.

Never fetch, subscribe, read a store, or import a router or app framework inside such a component — `meteor/*`, `next/*`, `react-router*`, `@tanstack/react-query` and `@fortawesome/*` are blocked by ESLint. Make it generic over the item type with accessor props (`getId`, `getStatus`, `getStart`, …), put domain rendering in `render*` slots, return a token _name_ for colour (never a class string), and make every user-facing string overridable through `labels`.

Declare it with `parameters.catalog.collection: true`; `pnpm catalog:check` then requires an **Empty**, **Loading** and **Error** story. Full contract:
[component-policy → Tier 2.5](https://github.com/mieweb/ui/blob/main/lessons/component-policy.md#tier-25-headless-modules).

Wiring one to an app's data layer — accessors, awaited mutations, `onOpen` plus `getHref`, where filter state lives:
[wiring-headless-modules.md](https://github.com/mieweb/ui/blob/main/lessons/wiring-headless-modules.md).

## Rule 15: When existing components do not meet the need

Before creating or materially extending a reusable component, read the
[upstream contribution guide](https://github.com/mieweb/ui/blob/main/CONTRIBUTING.md)
Expand All @@ -185,3 +198,82 @@ abstraction solely to make it contributable.
Follow the repository's permissions and approval requirements for commits,
pushes, and PR creation. Do not treat these instructions as authorization to
publish changes.

## Rule 16: Embedding the Ozwell assistant that acts on the page

Two different things share the "Ozwell" name — pick deliberately:

- **`OzwellChat` / `AIChat` (this library)** — the _chat UI shell_. You own the
transport and render messages you already have. Use it when the assistant is
part of your own product and you wire the answers yourself (see the
[Chat family](https://ui.mieweb.org/?path=/docs/modules-chat-overview--docs)
and the [Ozwell backend guide](https://github.com/mieweb/ui/blob/main/src/components/AI/OZWELL-BACKEND.md)).
- **The embedded Ozwell assistant (`@ozwell/react`, from ozwellai-api)** — a
drop-in, page-aware assistant that can **read and act on your page** through
tool calls. Use this when the user says things like "add Ozwell" or "let
Ozwell click / read / fill something on the page."

To add the page-aware assistant to a `@mieweb/ui` app:

- Install `@ozwell/react` alongside `@mieweb/ui`.
- Render `OzwellChat` from `@ozwell/react` and declare one tool in `tools` for
each page action the user wants Ozwell to perform (click, read, fill, …).
- Authenticate with a **site-approved agent key** (`agnt_key-…`) via
`VITE_OZWELL_AGENT_KEY`. Vite inlines every `VITE_*` value into the browser
bundle — this is **not** secret storage, so never expose a parent (`ozw_…`),
admin, or model-provider key this way; use a server-side integration when a
credential must stay private.
- Handle each call in `onToolCall(name, args, respond)`: perform the DOM action
and **always** `respond(...)`. Return `isError: true` for an unknown tool name
or a missing target, so the assistant never claims an action that did not happen.
- Follow the canonical guide — a full **Vite + MIE UI "Click Hello World"**
example — at <https://mieweb.github.io/ozwellai-api/frontend/react/>.

Example — let Ozwell fill a field on the page (adapt the tool to your app's own actions):

```tsx
import { useState } from 'react';
import { Input } from '@mieweb/ui';
import { OzwellChat, type OzwellTool } from '@ozwell/react';

const tools: OzwellTool[] = [
{
type: 'function',
function: {
name: 'set_note',
description: 'Write text into the Note field when the user asks.',
parameters: {
type: 'object',
properties: { text: { type: 'string', description: 'Text to put in the Note field' } },
required: ['text'],
},
},
},
];

export default function App() {
const [note, setNote] = useState('');
return (
<>
<Input label="Note" value={note} onChange={(e) => setNote(e.target.value)} />
<output aria-live="polite">Note: {note}</output>
<OzwellChat
apiKey={import.meta.env.VITE_OZWELL_AGENT_KEY}
tools={tools}
onToolCall={(name, args, respond) => {
if (name !== 'set_note' || typeof args.text !== 'string') {
respond({ isError: true, content: [{ type: 'text', text: 'Tool unavailable' }] });
return;
}
setNote(args.text);
respond({ content: [{ type: 'text', text: `Note set to "${args.text}"` }] });
}}
/>
</>
);
}
```

Privacy: conversation content stays between the user and Ozwell and is never
relayed to the host page. The host receives only the tool calls it declares,
lifecycle/error events, and any data the user explicitly shares (opt-in).
96 changes: 94 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ When asked to create a table, data grid, or any tabular data view:

```tsx
import { DataVisNitroSource, DataVisNitroGrid } from '@mieweb/ui/datavis';
// Peer deps: npm install @mieweb/datavis datavis-ace
// Self-contained entry: @mieweb/datavis is bundled in and datavis-ace ships as
// a dependency of @mieweb/ui — no extra installs needed to use these.
```

## Rule 2: Buttons belong in a ButtonGroup
Expand Down Expand Up @@ -164,7 +165,19 @@ Tailwind: on Tailwind 4, add an `@source` for `@mieweb/ui` so library classes ar

If JSDoc, the console, or the docs mark something deprecated (`AGGrid` today), do not use it in new code and do not suppress the warning. Use the documented replacement.

## Rule 14: When existing components do not meet the need
## Rule 14: A component that renders a collection takes it through props

Anything that displays a list, board, calendar, timeline or inbox of records the caller owns is a **headless module**. It receives `items` / `loading` / `error` as props, hands changes back through `on*` callbacks typed `void | Promise<void>`, and navigates through `onOpen(id)` / `getHref(id)`.

Never fetch, subscribe, read a store, or import a router or app framework inside such a component — `meteor/*`, `next/*`, `react-router*`, `@tanstack/react-query` and `@fortawesome/*` are blocked by ESLint. Make it generic over the item type with accessor props (`getId`, `getStatus`, `getStart`, …), put domain rendering in `render*` slots, return a token _name_ for colour (never a class string), and make every user-facing string overridable through `labels`.

Declare it with `parameters.catalog.collection: true`; `pnpm catalog:check` then requires an **Empty**, **Loading** and **Error** story. Full contract:
[component-policy → Tier 2.5](https://github.com/mieweb/ui/blob/main/lessons/component-policy.md#tier-25-headless-modules).

Wiring one to an app's data layer — accessors, awaited mutations, `onOpen` plus `getHref`, where filter state lives:
[wiring-headless-modules.md](https://github.com/mieweb/ui/blob/main/lessons/wiring-headless-modules.md).

## Rule 15: When existing components do not meet the need

Before creating or materially extending a reusable component, read the
[upstream contribution guide](https://github.com/mieweb/ui/blob/main/CONTRIBUTING.md)
Expand All @@ -182,4 +195,83 @@ abstraction solely to make it contributable.
Follow the repository's permissions and approval requirements for commits,
pushes, and PR creation. Do not treat these instructions as authorization to
publish changes.

## Rule 16: Embedding the Ozwell assistant that acts on the page

Two different things share the "Ozwell" name — pick deliberately:

- **`OzwellChat` / `AIChat` (this library)** — the _chat UI shell_. You own the
transport and render messages you already have. Use it when the assistant is
part of your own product and you wire the answers yourself (see the
[Chat family](https://ui.mieweb.org/?path=/docs/modules-chat-overview--docs)
and the [Ozwell backend guide](https://github.com/mieweb/ui/blob/main/src/components/AI/OZWELL-BACKEND.md)).
- **The embedded Ozwell assistant (`@ozwell/react`, from ozwellai-api)** — a
drop-in, page-aware assistant that can **read and act on your page** through
tool calls. Use this when the user says things like "add Ozwell" or "let
Ozwell click / read / fill something on the page."

To add the page-aware assistant to a `@mieweb/ui` app:

- Install `@ozwell/react` alongside `@mieweb/ui`.
- Render `OzwellChat` from `@ozwell/react` and declare one tool in `tools` for
each page action the user wants Ozwell to perform (click, read, fill, …).
- Authenticate with a **site-approved agent key** (`agnt_key-…`) via
`VITE_OZWELL_AGENT_KEY`. Vite inlines every `VITE_*` value into the browser
bundle — this is **not** secret storage, so never expose a parent (`ozw_…`),
admin, or model-provider key this way; use a server-side integration when a
credential must stay private.
- Handle each call in `onToolCall(name, args, respond)`: perform the DOM action
and **always** `respond(...)`. Return `isError: true` for an unknown tool name
or a missing target, so the assistant never claims an action that did not happen.
- Follow the canonical guide — a full **Vite + MIE UI "Click Hello World"**
example — at <https://mieweb.github.io/ozwellai-api/frontend/react/>.

Example — let Ozwell fill a field on the page (adapt the tool to your app's own actions):

```tsx
import { useState } from 'react';
import { Input } from '@mieweb/ui';
import { OzwellChat, type OzwellTool } from '@ozwell/react';

const tools: OzwellTool[] = [
{
type: 'function',
function: {
name: 'set_note',
description: 'Write text into the Note field when the user asks.',
parameters: {
type: 'object',
properties: { text: { type: 'string', description: 'Text to put in the Note field' } },
required: ['text'],
},
},
},
];

export default function App() {
const [note, setNote] = useState('');
return (
<>
<Input label="Note" value={note} onChange={(e) => setNote(e.target.value)} />
<output aria-live="polite">Note: {note}</output>
<OzwellChat
apiKey={import.meta.env.VITE_OZWELL_AGENT_KEY}
tools={tools}
onToolCall={(name, args, respond) => {
if (name !== 'set_note' || typeof args.text !== 'string') {
respond({ isError: true, content: [{ type: 'text', text: 'Tool unavailable' }] });
return;
}
setNote(args.text);
respond({ content: [{ type: 'text', text: `Note set to "${args.text}"` }] });
}}
/>
</>
);
}
```

Privacy: conversation content stays between the user and Ozwell and is never
relayed to the host page. The host receives only the tool calls it declares,
lifecycle/error events, and any data the user explicitly shares (opt-in).
<!-- mieweb-ui:end -->
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ COPY scripts ./scripts
# the file: dependency; the submodule itself isn't needed here.
COPY vendor/mieweb-ui.tgz ./vendor/mieweb-ui.tgz

# Kerebron fixes the RichEditor needs, applied by the postinstall step
# (scripts/apply-patches.cjs) — see patches/README.md.
COPY patches ./patches

# Install all dependencies (dev included — needed for Vite build + Meteor).
RUN npm install
RUN cd meteor-backend && npm install
Expand Down
Loading
Loading