Skip to content

Commit 9c07fd9

Browse files
committed
feat(chat): wire scheduledtask chat-context kind
Adds a first-class 'scheduledtask' ChatContext kind so a scheduled-task resource maps to a real context (not a generic docs fallback), fixing the exhaustive RESOURCE_TO_CONTEXT map that broke the build: - ChatContext union + CHAT_CONTEXT_KIND_REGISTRY (Calendar chip) - resource→context mapping, context validity check, clipboard portability Agent-side consumption of the kind remains a follow-up.
1 parent e494b22 commit 9c07fd9

7 files changed

Lines changed: 13 additions & 8 deletions

File tree

apps/sim/app/workspace/[workspaceId]/home/components/chat-context-kind-registry/chat-context-kind-registry.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { ReactNode } from 'react'
22
import {
3+
Calendar,
34
Database,
45
Folder as FolderIcon,
56
Library,
@@ -79,6 +80,10 @@ export const CHAT_CONTEXT_KIND_REGISTRY: Record<ChatContextKind, ChatContextKind
7980
label: 'File folder',
8081
renderIcon: ({ className }) => <FolderIcon className={className} />,
8182
},
83+
scheduledtask: {
84+
label: 'Scheduled task',
85+
renderIcon: ({ className }) => <Calendar className={className} />,
86+
},
8287
past_chat: {
8388
label: 'Past chat',
8489
renderIcon: ({ className }) => <Task className={className} />,

apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-content/resource-content.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -703,8 +703,6 @@ function EmbeddedScheduledTask({ workspaceId, scheduleId }: EmbeddedScheduledTas
703703
if (isLoading && !schedule) return LOADING_SKELETON
704704

705705
if (!schedule) {
706-
// A failed list query also yields no schedule; keep that distinct from a
707-
// genuinely missing task so we don't tell the user it was deleted.
708706
const heading = isError ? "Couldn't load scheduled task" : 'Scheduled task not found'
709707
const detail = isError
710708
? 'Something went wrong loading this scheduled task. Try again.'

apps/sim/app/workspace/[workspaceId]/home/components/user-input/components/chip-clipboard-codec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const PORTABLE_KIND_TO_ID_FIELD = {
2727
file: 'fileId',
2828
folder: 'folderId',
2929
filefolder: 'fileFolderId',
30+
scheduledtask: 'scheduleId',
3031
knowledge: 'knowledgeId',
3132
past_chat: 'chatId',
3233
workflow: 'workflowId',
@@ -207,6 +208,8 @@ export function chipLinkToContext(link: ParsedChipLink): ChatContext {
207208
return { kind: 'folder', folderId: link.id, label: link.label }
208209
case 'filefolder':
209210
return { kind: 'filefolder', fileFolderId: link.id, label: link.label }
211+
case 'scheduledtask':
212+
return { kind: 'scheduledtask', scheduleId: link.id, label: link.label }
210213
case 'knowledge':
211214
return { kind: 'knowledge', knowledgeId: link.id, label: link.label }
212215
case 'past_chat':

apps/sim/app/workspace/[workspaceId]/home/components/user-input/components/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ const RESOURCE_TO_CONTEXT: Record<
112112
task: (r) => ({ kind: 'past_chat', chatId: r.id, label: r.title }),
113113
log: (r) => ({ kind: 'logs', executionId: r.id, label: r.title }),
114114
integration: (r) => ({ kind: 'integration', blockType: r.id, label: r.title }),
115+
scheduledtask: (r) => ({ kind: 'scheduledtask', scheduleId: r.id, label: r.title }),
115116
generic: (r) => ({ kind: 'docs', label: r.title }),
116117
}
117118

apps/sim/app/workspace/[workspaceId]/home/hooks/use-chat.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,8 @@ function isChatContext(value: unknown): value is ChatContext {
294294
return typeof value.folderId === 'string'
295295
case 'filefolder':
296296
return typeof value.fileFolderId === 'string'
297+
case 'scheduledtask':
298+
return typeof value.scheduleId === 'string'
297299
case 'docs':
298300
return true
299301
case 'slash_command':

apps/sim/lib/copilot/resources/types.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,7 @@ export function isEphemeralResource(resource: MothershipResource): boolean {
2525
return resource.type === 'generic' || resource.id === 'streaming-file'
2626
}
2727

28-
/**
29-
* Placeholder resource titles emitted before a specific name is known. A more
30-
* specific title may overwrite one of these during dedup; a specific title is
31-
* never downgraded back to a placeholder. Shared by the chat-resource route and
32-
* the server-side persistence merge so the two stay in lockstep.
33-
*/
28+
/** Placeholder resource titles that a more specific title may overwrite during dedup. */
3429
export const GENERIC_RESOURCE_TITLES = new Set<string>([
3530
'Table',
3631
'File',

apps/sim/stores/panel/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export type ChatContext =
3131
| { kind: 'file'; fileId: string; label: string }
3232
| { kind: 'folder'; folderId: string; label: string }
3333
| { kind: 'filefolder'; fileFolderId: string; label: string }
34+
| { kind: 'scheduledtask'; scheduleId: string; label: string }
3435
| { kind: 'docs'; label: string }
3536
| { kind: 'slash_command'; command: string; label: string }
3637
| { kind: 'integration'; blockType: string; label: string }

0 commit comments

Comments
 (0)