Skip to content

feat(web): add copy buttons to frontmatter and metadata headings - #215

Merged
murrayju merged 1 commit into
mainfrom
murrayju/web-copy-frontmatter-metadata
Oct 13, 2026
Merged

murrayju merged 1 commit into
mainfrom
murrayju/web-copy-frontmatter-metadata

Conversation

@murrayju

Copy link
Copy Markdown
Member

Summary

Add a copy-to-clipboard button to the frontmatter and metadata section headings in the memory reading view.

  • Frontmatter: copies a fenced YAML block (--- … ---) with the set fields (name, tree, meta, temporal). This is the same block the editor shows.
  • Metadata: copies YAML with id, hasEmbedding, and createdBy (if set), with the API field names.

A click on the button does not open or close the section. A toast reports success or failure.

Changes

  • New viewer/SummaryCopyButton.tsx: the button. It prevents the default <summary> toggle.
  • lib/frontmatter.ts: extract formatFrontmatterBlock() from memoryToEditorText(), so the editor and the copy button produce the same text. Unit tests added.
  • icons.tsx: move CopyIcon here from EditorPane.tsx, because three places now use it.

Testing

  • ./bun run lint, ./bun run web:typecheck, web unit tests, and the e2e suite pass.
  • The root ./bun run typecheck reports 26 errors and 4 memory history/revert integration tests fail locally. Both also happen on main without this change.

Copilot AI balanced review requested due to automatic review settings October 13, 2026 13:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The implementation is focused, consistent with existing behavior, and has appropriate serializer coverage.

0 open findings

What changed in this PR

Adds copy-to-clipboard controls for frontmatter and metadata in the memory reading view.

Changes:

  • Adds reusable summary copy buttons with toast feedback.
  • Shares frontmatter serialization between viewing and editing.
  • Centralizes the copy icon and adds serializer tests.
File Description
packages/​web/​src/​lib/​frontmatter.ts Extracts frontmatter serialization.
packages/​web/​src/​lib/​frontmatter.test.ts Tests frontmatter block formatting.
packages/​web/​src/​components/​viewer/​SummaryCopyButton.tsx Adds the reusable copy control.
packages/​web/​src/​components/​viewer/​FrontmatterBlock.tsx Adds frontmatter copying.
packages/​web/​src/​components/​viewer/​MetadataPanel.tsx Adds YAML metadata copying.
packages/​web/​src/​components/​icons.tsx Exports the shared copy icon.
packages/​web/​src/​components/​editor/​EditorPane.tsx Uses the shared copy icon.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@gregsaab gregsaab left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet, thank you!

@murrayju
murrayju merged commit 7207c71 into main Oct 13, 2026
7 of 8 checks passed
@murrayju
murrayju deleted the murrayju/web-copy-frontmatter-metadata branch October 13, 2026 16:11
murrayju added a commit that referenced this pull request Oct 13, 2026
…leDB 2.30 (#216)

## Summary

Fix the memory history and revert functions on TimescaleDB 2.30+.
`has_tree_access` now uses `operator(public.@>)` instead of an
unqualified `@>`.

## Problem

CI started to fail on `main`-equivalent code (seen first on #215) in two
space-migration integration tests:

```
operator does not exist: public.ltree @> public.ltree
where: SQL function "has_tree_access" during inlining
       SQL function "resolve_memory_id_from_history" statement 1
```

The CI Postgres image (`docker/Dockerfile.postgres`) installs
`timescaledb-2-postgresql-18` without a version pin, so it now gets
2.30.2. I bisected with a minimal repro against the TimescaleDB versions
in the image:

| TimescaleDB | result |
|---|---|
| 2.28.3, 2.29.0, 2.29.2 | pass |
| 2.30.0, 2.30.2 | `operator does not exist` |

The failing pattern: an inlinable SQL function (no `set search_path`)
that uses an extension operator, in the `WHERE` clause of a hypertable
query with `ORDER BY <time> LIMIT 1`. From 2.30.0, the inlined body does
not resolve the operator, although the calling function sets
`search_path` to include `public`. The same query on a plain table
works.

In this schema, that hits `resolve_memory_id_from_history` and the
snapshot lookup in `revert_memory` (both on the `memory_event`
hypertable). `get_memory_history` already used `operator(public.<@)` for
its own subtree filter.

## Fix

Schema-qualify the operator in `has_tree_access`. The function stays
inlinable (no `set search_path`), which is why it must not depend on the
caller's `search_path`. Extensions are always installed `with schema
public` (`ensureExtension`), so the qualifier is safe. `has_tree_access`
and `tree_access` are the only inlinable SQL functions in the space
schema, and `tree_access` uses no operators.

Idempotent migrations re-run on every boot, so existing spaces get the
new body without a schema version bump. The signature does not change.

## Production impact

If production moves to TimescaleDB 2.30+, `memory.history` by path and
`memory.revert` would fail without this fix.

## Testing

- The previously failing tests pass against TimescaleDB 2.30.2:
`packages/database/space/migrate/migrate.integration.test.ts` and
`packages/server/rpc/memory/memory.integration.test.ts`.
- Full suite (1648 pass, 0 fail), e2e, and lint pass locally.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants