Skip to content

feat: add workflow slash triggers - #280

Merged
willchen96 merged 5 commits into
Open-Legal-Products:mainfrom
zenzen-sol:codex/workflow-slash-triggers
Aug 3, 2026
Merged

feat: add workflow slash triggers#280
willchen96 merged 5 commits into
Open-Legal-Products:mainfrom
zenzen-sol:codex/workflow-slash-triggers

Conversation

@zenzen-sol

@zenzen-sol zenzen-sol commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Summary

  • define an optional metadata.mike-slash-trigger field for assistant workflow SKILL.md frontmatter
  • expose declared triggers for system and installed workflows
  • show matching workflow commands in the chat composer and execute the selected workflow through the existing workflow message field

Protocol

metadata:
  mike-slash-trigger: "/contract-intake"

Triggers must begin with / and contain only lowercase letters, numbers, and hyphens.

Validation

  • npm test in frontend: 52 tests passed
  • npm test in backend: 276 tests passed, 14 skipped
  • npm run build in backend
  • npx next build --webpack in frontend
  • npm run lint in frontend: 0 errors

@CLAassistant

CLAassistant commented Aug 2, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@willchen96

Copy link
Copy Markdown
Collaborator

Thanks useful feature - could you add some screenshots of the UI once done?

@zenzen-sol

Copy link
Copy Markdown
Contributor Author

Thanks useful feature - could you add some screenshots of the UI once done?

Full screen view after typing "/":

CleanShot 2026-08-03 at 08 28 49@2x

Detail of workflow selector:

CleanShot 2026-08-03 at 08 28 56@2x

Detail after typing "/co":

CleanShot 2026-08-03 at 09 05 31@2x

Example after choosing a workflow from the selector:

CleanShot 2026-08-03 at 08 29 25@2x

Another example after choosing a workflow from the selector:

CleanShot 2026-08-03 at 08 31 00@2x

Typing "/" when no workflows have triggers just passes the character through without any UI or other user-facing intervention:

CleanShot 2026-08-03 at 08 48 22@2x

@zenzen-sol
zenzen-sol marked this pull request as ready for review August 3, 2026 00:21
@willchen96

Copy link
Copy Markdown
Collaborator

Updated the slash-command implementation in commit 942a9ff.

What changed:

  • Slash commands are now derived from each workflow’s existing top-level SKILL.md name (name: nda-review becomes /nda-review) instead of requiring a separate mike-slash-trigger field.
  • The workflow build output now includes metadata.name, validates that names are lowercase command-safe slugs, and the API also extracts names from database-backed SKILL.md frontmatter when available.
  • The checked-in built assistant workflows now have usable commands, so typing / produces real suggestions without additional workflow metadata.
  • The suggestion popup now uses the shared liquid-glass dropdown surface and item primitives.
  • Selecting a slash result now attaches the workflow chip to the chat composer, clears the slash query, and keeps focus in the input. It does not submit a message; the workflow runs only when the user enters and sends their actual prompt.
  • Tests and README documentation were updated for the name-derived behavior.

Why:

  • Workflow names are already unique, stable, and slug-shaped, so using them removes duplicate configuration and prevents the feature from shipping with no configured commands.
  • Attaching rather than immediately submitting matches the existing workflow-picker interaction and lets the user provide the instructions/documents the workflow needs.

Validation: backend tests (276 passed), frontend tests (53 passed), backend build, frontend TypeScript, and frontend ESLint all pass.

@willchen96 willchen96 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm - made some additional refinements

@willchen96
willchen96 merged commit afe163a into Open-Legal-Products:main Aug 3, 2026
4 of 5 checks passed
@willchen96

Copy link
Copy Markdown
Collaborator

Thanks for the contribution. let me know if you would like to join the contributors' discord!

@zenzen-sol

Copy link
Copy Markdown
Contributor Author

Thanks for the contribution. let me know if you would like to join the contributors' discord!

Thank you! I've got a few ideas for PRs, so I would definitely like to join the Discord.

willchen96 pushed a commit that referenced this pull request Aug 3, 2026
…with lib tests

WHY THIS MATTERS

Main's "Frontend build and tests" job has been red for everyone:
statements 52.14% vs the 54% floor and branches 62.57% vs 73%. A
coverage ratchet only works if regressions are paid down with tests —
if we lower the floor instead, the ratchet becomes a decoration and
every future untested merge quietly erodes the suite. This commit
restores green by testing the code that caused the drop, then re-arms
the ratchet at the new level.

WHAT HAPPENED

The ratchet floors were measured in #255 (2266446) before three merges
landed untested code inside the gated scope (src/app/lib/**):

- #263 (db-pagination) + #274 (folder-grouped tabular reviews) grew
  mikeApi.ts's listTabularReviews/listTabularReviewIds into
  query-string builders with seven conditional params each, added the
  document_grouping field, the uploadReviewDocument orchestration, and
  the tabular chat/cell endpoints — nearly all unexercised. Lines
  1044-1456 were the bulk of the uncovered report.
- #280 (workflow slash triggers) leans on the workflow endpoints
  (listWorkflows feeds the slash menu), which were also untested.

Because coverage is a global percentage over the gated files, adding
untested statements/branches anywhere in scope dilutes the totals even
though no tested line got worse.

HOW THE FIX WORKS

Extend the existing mikeApi.test.ts fetch/session mocking pattern to
the regressed surface, asserting behavior (URLs, methods, exact
payloads, error contracts), not just execution:

- listTabularReviews/listTabularReviewIds: every pagination knob
  serialized under its snake_case name, scope="all" omitted (backend
  default), abort signals forwarded, and the ids query scoped
  identically to the list query — the invariant that keeps
  select-all-then-delete from deleting reviews the user cannot see.
- createTabularReview/updateTabularReview: document_grouping (the #274
  field) passes through unchanged; PATCH sends only the given fields.
- uploadReviewDocument: project vs standalone upload routing, and that
  the follow-up PATCH appends to existing document_ids instead of
  replacing them (the review-shrinking failure mode).
- Multipart uploads: FormData with auth header only (a manual JSON
  content type would break the boundary), optional filename field, and
  the plain-Error-with-response-text failure contract.
- Tabular chats/cells, workflow list/hide/unhide, query and payload
  defaults (getDocumentUrl version param, createChat "{}" body,
  parent_folder_id null-vs-undefined, empty error bodies).
- supabase.ts: importing without env vars fails loudly at module load —
  the desired crash-at-startup behavior for a misconfigured build.
- deleteTabularReviewsWithConcurrency: empty input short-circuits;
  concurrency<=0 clamps to one worker instead of silently deleting
  nothing.
- utils.diceCoefficient: sub-bigram inputs score 0.

Coverage moves from 52.14/62.57/34.67/52.41 (stmts/branch/funcs/lines)
to 81.18/98.24/55.64/79.18. Per the ratchet's own rule ("floors only go
up: when you add tests, raise them in the same PR"), the floors move to
79/96/53/77 — about two points under the new measurement, so one small
innocent addition doesn't instantly re-redden main, while a real drop
still fails CI.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
willchen96 added a commit that referenced this pull request Aug 3, 2026
test(frontend): fix the red main — pay down the coverage regression from #274/#263/#280
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.

3 participants