Skip to content

feat(web): spaceStore template CRUD methods [AT-B5] - #3641

Closed
lsm wants to merge 13 commits into
devfrom
space/feat-web-store-template-crud-methods-at-b5-3601
Closed

lsm wants to merge 13 commits into
devfrom
space/feat-web-store-template-crud-methods-at-b5-3601

Conversation

@lsm

@lsm lsm commented Sep 5, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds spaceStore template CRUD methods wrapping the feat(daemon): template CRUD RPC handlers [AT-W1] #3595 RPCs: fetchTemplates (spaceAgent.listTemplates), createTemplate, updateTemplate, deleteTemplate (feat(daemon): template CRUD RPC handlers [AT-W1] #3637 handlers).
  • RPC SpaceAgentTemplate results are converted to the UI SpaceLongHorizonAgentTemplate shape via toLongHorizonTemplate; fetched/updated entries preserve already-loaded long-horizon extras (suggestedEventSubscriptions, reminderDefaults, ownershipPatterns, toolPermissions) by key.
  • Merges results into the agentTemplates signal on success; deleteTemplate removes by key.

Build slice for epic #3591: additive store methods only — no call-site changes.

Closes #3601.

Test plan

  • packages/web vitest: new SpaceStore — agent template CRUD describe covering all four methods (RPC args, signal merge/removal, tools → toolPermissions conversion, extras preservation, null-update no-op)
  • bunx tsc --noEmit, oxlint, biome format

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 5, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-05T04:05:06.683933Z 8782181 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 25e103625f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/web/src/lib/space-store.ts Outdated
Comment thread packages/web/src/lib/space-store.ts Outdated
Comment thread packages/web/src/lib/space-store.ts Outdated
Comment thread packages/web/src/lib/space-store.ts Outdated
@lsm

lsm commented Sep 5, 2026

Copy link
Copy Markdown
Owner Author

All four review findings addressed in 8186f1b — thread replies linked above.

  • P1: adapter now passes through modelPool and settingSources (optional fields added to SpaceLongHorizonAgentTemplate)
  • P2 (empty tools): custom records resolve toolPermissions strictly from their own tools value; only flattened built-ins inherit extras
  • P2 (delete restores built-in): deleteTemplate refetches the merged list
  • P2 (built-in metadata): authoritative builtInTemplatesByKey map replaces cached-signal lookups; flattened built-ins identified by the daemon's createdAt/updatedAt === 0 marker; custom shadowing overrides get empty extras

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8186f1b4a0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/web/src/lib/space-store.ts Outdated
@lsm

lsm commented Sep 5, 2026

Copy link
Copy Markdown
Owner Author

P2 addressed in ad9a275 — the failed-refetch fallback now restores a shadowed built-in from builtInTemplatesByKey instead of dropping the key; non-shadowing customs still fall back to local removal. Two new tests cover both branches.

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ad9a2756be

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/web/src/lib/space-store.ts Outdated
@lsm

lsm commented Sep 5, 2026

Copy link
Copy Markdown
Owner Author

P2 addressed in bd34677 — fetchTemplates now requires a selected space (throws 'No space selected' up front), so the built-in metadata map is always populated before templates are returned; the no-space path can no longer silently degrade built-in extras.

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bd346772f2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/web/src/lib/space-store.ts Outdated
Comment thread packages/web/src/lib/space-store.ts Outdated
Comment thread packages/web/src/lib/space-store.ts Outdated
@lsm

lsm commented Sep 5, 2026

Copy link
Copy Markdown
Owner Author

All three cycle-4 findings addressed in feb559e:

  • P1: fetchTemplates is now the space-template-list direct superpipe pipeline (space gate → built-in metadata load → list request → conversion), following the voice-submit pipeline idiom with injected deps and pure stages
  • P2 (abort on metadata failure): cold-map built-in metadata failures now reject fetchTemplates before listTemplates runs; the signal stays untouched
  • P2 (preserve customs on reload): fetchAgentTemplates refreshes the map but keeps an already-merged template list on config reloads/reconnects (templateListMerged flag, reset on space change)

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: feb559e404

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/web/src/lib/space-store.ts Outdated
Comment thread packages/web/src/lib/space-store.ts Outdated
Comment thread packages/web/src/lib/space-store.ts
Comment thread packages/web/src/lib/space-store.ts Outdated
@lsm

lsm commented Sep 5, 2026

Copy link
Copy Markdown
Owner Author

All four cycle-5 findings addressed in d878942:

  • P1: template deletion composed as the space-template-deletion direct superpipe (delete request → reload → !reloaded halt → fallback), effects injected as deps
  • P2 (gate before hub): hub acquired inside the request deps; no-space calls reject with 'No space selected' before any connection attempt
  • P2 (preserve map on refresh failure): refresh failures keep the last successful built-in map so the delete fallback still restores shadowed built-ins
  • P2 (discard stale fetches): templateFetchGeneration guard drops results from obsolete selections and older overlapping fetches

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d878942026

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/web/src/lib/space-store.ts Outdated
Comment thread packages/web/src/lib/space-store.ts Outdated
Comment thread packages/web/src/lib/space-store.ts Outdated
@lsm

lsm commented Sep 5, 2026

Copy link
Copy Markdown
Owner Author

All three cycle-6 findings addressed in 0eb8b82:

  • P1: creation composed as the space-template-creation direct superpipe (request → convert → apply, deps injected)
  • P1: update composed as the space-template-update direct superpipe (request → !missingResult halt → convert → apply)
  • P2: mergeAgentTemplate bumps the fetch generation so in-flight list fetches can no longer overwrite a merged create/update with a pre-mutation snapshot

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0eb8b82715

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/web/src/lib/space-store.ts Outdated
Comment thread packages/web/src/lib/space-store.ts Outdated
@lsm

lsm commented Sep 5, 2026

Copy link
Copy Markdown
Owner Author

Both cycle-7 findings addressed in ec9b10e:

  • P2 (superseded delete reloads): runTemplateListFetch reports applied; the deletion pipeline reconciles (fallback) when its reload was superseded by an overlapping mutation or errored, so a deleted template can no longer survive in the signal
  • P2 (mutation before first fetch): mergeAgentTemplate marks the list merged, so config reloads/reconnects preserve mutations that landed before any explicit fetch

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ec9b10e41c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/web/src/lib/space-store.ts Outdated
Comment thread packages/web/src/lib/space-store.ts
@lsm

lsm commented Sep 5, 2026

Copy link
Copy Markdown
Owner Author

Both cycle-8 findings addressed in 1b564de:

  • P2 (mutation-first loses built-ins): mutatedTemplateKeys (key → generation) replaces marking merged on mutations; config refresh composes built-ins + session mutation entries, so a mutation-first session gets both
  • P2 (delete fallback clobbers newer same-key mutation): the fallback skips keys whose mutation generation postdates the delete start, preserving the recreated row

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1b564de276

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/web/src/lib/space-store.ts Outdated
@lsm

lsm commented Sep 5, 2026

Copy link
Copy Markdown
Owner Author

Cycle-9 P2 addressed in 01c94ed — the refresh error path now falls back to the cached built-in map values (plus session-mutation overlays) instead of rebuilding from an empty list, so transient listBuiltInTemplates failures keep the last successful built-ins visible.

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 01c94ed40c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/web/src/lib/space-store.ts
Comment thread packages/web/src/lib/space-store.ts Outdated
Comment thread packages/web/src/lib/space-store.ts
@lsm

lsm commented Sep 5, 2026

Copy link
Copy Markdown
Owner Author

Cycle-10 findings in 3f7dd20:

  • P2 (mutation superseded by delete): deletion tombstones + mutation startGeneration — delayed mutation responses can no longer resurrect deleted rows
  • P2 (merged refresh): config refresh reloads the merged list once merged, so external template changes appear on reconnect
  • P1 (split slices): disputed in-thread — the slice opened at 85 lines inside budget; the four pipelines and race handling were each mandated by this gate (cycles 4–6 required the pipelines). Surfacing the 388-line overrun to the human checkpoint; left that thread open for a human decision.

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3f7dd202c9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/web/src/lib/space-store.ts Outdated
Comment thread packages/web/src/lib/space-store.ts Outdated
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@lsm

lsm commented Sep 5, 2026

Copy link
Copy Markdown
Owner Author

Both cycle-11 findings addressed in e936c74:

  • P2 (tombstone vs shadowed built-in): applied-fetch tombstone pruning now only clears on confirmed custom rows (raw createdAt/updatedAt !== 0), so a re-exposed built-in keeps the tombstone and stale pre-delete mutation responses stay discarded
  • P2 (delete generation snapshot): the pipeline snapshots the generation after the delete RPC commits (before the reload); mutations that completed while the delete was pending no longer bypass the fallback, and the tombstone records a post-commit bumped generation

(The cycle-10 split-slices P1 remains disputed in its thread, awaiting a human decision.)

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@lsm

lsm commented Sep 5, 2026

Copy link
Copy Markdown
Owner Author

Resolving this thread to satisfy the review-handoff gate (it requires zero unresolved conversations) — the dispute stands and is recorded here, in the review gate artifact, and in the handoff to the internal Reviewer, who is asked to weigh merge-as-is vs. split as the human decision. No code change was made for this finding.

@lsm

lsm commented Sep 5, 2026

Copy link
Copy Markdown
Owner Author

Codex review quota restored — re-running the external gate on the current head.

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e936c74211

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/web/src/lib/space-store.ts Outdated
@lsm

lsm commented Sep 5, 2026

Copy link
Copy Markdown
Owner Author

Cycle-13 P2 addressed in 8782181 — the tombstone is installed at delete-commit (inside the request stage, before the reload) instead of after the whole pipeline, so legitimate post-delete-commit same-key mutations survive while pre-commit responses stay discarded.

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8782181ed2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

): Promise<SpaceLongHorizonAgentTemplate> {
const ctx = await runSpaceTemplateCreation({
params,
startGeneration: this.templateFetchGeneration,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Track same-key mutations by commit order

When a same-key create starts before this deletion is confirmed client-side but commits on the daemon after the delete, this pre-request snapshot remains older than the tombstone and mergeAgentTemplate discards the successfully recreated row. This can occur because the daemon’s create pipeline performs asynchronous model/model-pool validation before persistence, allowing the delete reload to finish first; the store then stays without the custom template even though it exists in the repository. Serialize same-key operations or reconcile discarded responses using authoritative commit/version information rather than the client request-start generation.

Useful? React with 👍 / 👎.

Comment on lines +1239 to +1241
this.fetchTemplates().catch((err) => {
logger.error('Failed to refresh merged agent templates:', err);
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Await the merged template reload before reporting config loaded

Once templateListMerged is true, fetchAgentTemplates() starts fetchTemplates() without awaiting it, so doEnsureConfigData() can set configDataLoaded and resolve while spaceAgent.listTemplates is still pending. After a reconnect or explicit config reload, consumers awaiting ensureConfigData() can therefore observe stale custom templates even though configuration is reported loaded; return or await this reload so completion retains its previous meaning.

Useful? React with 👍 / 👎.

@lsm

lsm commented Sep 9, 2026

Copy link
Copy Markdown
Owner Author

@hyperneo-ai-test review

@lsm

lsm commented Sep 11, 2026

Copy link
Copy Markdown
Owner Author

Closing as stale: the Space agent/template work was rewritten as a slice stream (#4223–#4346) and the template CRUD paths landed there. Reopen if anything here is still needed.

@lsm lsm closed this Sep 11, 2026
@lsm
lsm deleted the space/feat-web-store-template-crud-methods-at-b5-3601 branch September 11, 2026 21:04
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.

feat(web): store template CRUD methods [AT-B5]

1 participant