Skip to content

feat(mothership): let a question card pick from the workspace's resources - #8735

Draft
waleedlatif1 wants to merge 1 commit into
stagingfrom
feat/mothership-resource-picker-question
Draft

waleedlatif1 wants to merge 1 commit into
stagingfrom
feat/mothership-resource-picker-question

Conversation

@waleedlatif1

@waleedlatif1 waleedlatif1 commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • New <question> kind: {"type": "resource_select", "prompt": string, "resourceType": "workflow" | "table" | "file" | "knowledgebase"}. It has no options. The card fetches that family's live list for the current workspace and renders each row with the add-resource menu's row (renderDropdownItem, resourceFromItem). It has no 4-option cap.
  • The card's free-text row also works as a search box: typing filters the rows, and Enter submits the typed text as a normal answer. An empty query mounts at most 50 rows, followed by a "N more — type to search" row.
  • Picking a row sends the usual prompt — answer line. The chosen resource is attached as a chat context (mapResourceToContext), the same way a typed @-mention is, so the agent gets the id and not just the name. To support this, onOptionSelect is now InteractionAnswerHandler (message, contexts?) and it is threaded through to onSubmit.
  • Answer pairing and the recap after a reload are unchanged, because they still parse the prompt — answer text.
  • Why: when asked something ambiguous like "fix my workflow", the agent answers "which workflow?" in plain prose without naming any of them. A question card allows only 2–4 options, so it cannot list a whole workspace.
  • Compatibility: Sim ships first. An older Sim that gets a resource_select body fails validation and falls back to showing the prompt as plain text, which is today's behaviour. Organization chats have no workspace to list, so they get the free-text row only, and the worker does not offer the kind there.

Companion: https://github.com/simstudioai/mothership/pull/618

Type of Change

  • New feature

Testing

  • question/resource-question.test.tsx (new, jsdom), 6 tests:
    • lists all 11 rows past the old cap, and fetches only the requested family
    • a picked row sends the name plus a {kind: 'workflow', workflowId, label} context, and parseQuestionAnswerMessage round-trips it
    • typing filters the rows; unmatched text submits without contexts
    • a multi-step card mixing kinds carries only the picked resource
    • a 60-item workspace mounts 50 rows, and search reaches the rest
    • the transcript recap renders
  • special-tags.test.ts: resource_select parses with no options and drops stray fields. An unknown or missing resourceType is rejected.
  • tsc (apps/sim), bun run lint and bun run check:audits (58 audits) all pass. The unused-exports baseline shrank by the 4 retired QUESTION_TYPES / QuestionType entries.
  • Root bun run test: 35,207 pass and 1 fails. The failure is remark-plain-text.test.ts, a 10 s timing test that timed out because the machine was under load. It passes alone, both on this branch and on the base.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
docs Ready Ready Preview Oct 7, 2026 7:58am UTC

Request Review

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@github-actions github-actions Bot added the requires-mothership-merge Has a companion PR on the mothership/copilot side — merge in lockstep label Oct 7, 2026
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown

⚠️ Cross-repo companion check

One or more companion PRs aren't merged into staging yet. Merging this without them will leave copilot and sim out of sync — merge them in lockstep.

  • ❌ simstudioai/mothership#618 — OPEN, not merged (targets staging) — feat(worker): let the agent ask which workspace resource with a picker card

@cubic-dev-ai cubic-dev-ai Bot 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.

1 issue found across 10 files

Confidence score: 3/5

  • resource-question-rows.tsx can show candidates from the previous workspace during a workspace switch, and users can select one in the current chat. Don’t keep previous data across workspace changes, or disable selection until the new workspace’s data loads.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/sim/app/workspace/[workspaceId]/home/components/message-content/components/question/resource-question-rows.tsx">

<violation number="1" location="apps/sim/app/workspace/[workspaceId]/home/components/message-content/components/question/resource-question-rows.tsx:39">
P2: These workspace-scoped list hooks keep previous data when their keys change, so this renders the prior workspace’s candidates during a workspace switch and allows selecting one in the current chat. Ignore placeholder data and treat it as loading until the current workspace’s list resolves.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Turn on auto-fix | Re-trigger cubic

type
]
const candidates = useMemo(
() => (query.data ?? []).map((item) => ({ id: item.id, name: item.name })),

@cubic-dev-ai cubic-dev-ai Bot Oct 7, 2026 •

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.

P2: These workspace-scoped list hooks keep previous data when their keys change, so this renders the prior workspace’s candidates during a workspace switch and allows selecting one in the current chat. Ignore placeholder data and treat it as loading until the current workspace’s list resolves.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At apps/sim/app/workspace/[workspaceId]/home/components/message-content/components/question/resource-question-rows.tsx, line 39:

<comment>These workspace-scoped list hooks keep previous data when their keys change, so this renders the prior workspace’s candidates during a workspace switch and allows selecting one in the current chat. Ignore placeholder data and treat it as loading until the current workspace’s list resolves.</comment>

<file context>
@@ -0,0 +1,124 @@
+    type
+  ]
+  const candidates = useMemo(
+    () => (query.data ?? []).map((item) => ({ id: item.id, name: item.name })),
+    [query.data]
+  )
</file context>
Fix with cubic

@greptile-apps

greptile-apps Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

[Medium risk] Adds resource picker to question cards in chat.

The feature’s context handoff is intact, but the explicit styling and testing requirements must be satisfied before merging.

Findings

  1. P2 Multiline names lose the recap ▶
  2. P2 Hidden rows lack a cue ▶
  3. P2 Tests use forbidden assertions ▶

Summary

Adds resource_select questions that list and search workspace workflows, tables, files, or knowledge bases. Picks send the resource name with an ID-bearing chat context.

  • A multiline workflow name breaks answer pairing after reload.
  • The new scroll box and several test assertions violate explicit repository rules.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Tag["resource_select question"] --> List["Workspace resource list"]
  List --> Pick["User picks a row"]
  Pick --> Answer["Prompt — resource name"]
  Pick --> Context["Resource ID context"]
  Answer --> Submit["Chat submit"]
  Context --> Submit
  Submit --> Transcript["Saved transcript"]
  Transcript --> Parse["Parse answer lines"]
  Parse --> Recap["Answered recap"]
Loading

Reviews (1) · Last reviewed commit: "feat(mothership): let a question card pi..." · Reviewed by Greptile

resourceType={question.resourceType}
query={freeText}
disabled={disabled}
onPick={(resource) => handleSingleSelect(resource.title, resource)}

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.

P2 Multiline names lose the recap

Picking a workflow whose name contains a newline breaks the answered recap after reload. Workflow names allow internal newlines, but this passes the name unchanged into an answer format that requires one line per question. parseQuestionAnswerMessage returns null, so the chat leaves the question unpaired and shows a separate answer bubble.

Normalize line breaks in the picked label before formatting the answer. Keep the resource context unchanged.

}

return (
<div className='max-h-[180px] overflow-y-auto'>

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.

P2 Hidden rows lack a cue

The new scroll box hides resource rows without the required edge treatment. The styling guide requires useScrollEdges, scrollFadeClass, and scrollFadeAttributes for regions that hide rows beyond an edge.

Apply those helpers so users can see when more resources are offscreen. This repository requirement must be satisfied before merging.

Context Used: Tailwind CSS and styling conventions (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Comment on lines +97 to +99
expect(rowLabels()).toEqual(WORKFLOWS.map((workflow) => workflow.name))
expect(mockUseWorkflows).toHaveBeenCalledWith('ws-1', { enabled: true })
expect(mockUseTablesList).toHaveBeenCalledWith('ws-1', 'active', { enabled: false })

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.

P2 Tests use forbidden assertions

This test checks rendered labels and calls to mocked hooks. CLAUDE.md explicitly forbids mock-call and rendered-text assertions. The preview and recap tests also check rendered text.

Replace these checks with end-to-end proof that a picked resource reaches the chat request and survives transcript reload. This testing requirement must be satisfied before merging.

Context Used: CLAUDE.md (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

This branch was successfully deployed

1 active deployment
Preview — 9d786909 Deployed Oct 7, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

requires-mothership-merge Has a companion PR on the mothership/copilot side — merge in lockstep

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant