mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-05-31 19:15:17 +02:00
Show update instructions CTA to trigger copilot when new data sources are attached to agents
This commit is contained in:
parent
e4cd71e6b1
commit
5bc1dc8b37
3 changed files with 82 additions and 14 deletions
|
|
@ -34,7 +34,7 @@ interface AppProps {
|
|||
dataSources?: z.infer<typeof DataSource>[];
|
||||
}
|
||||
|
||||
const App = forwardRef<{ handleCopyChat: () => void }, AppProps>(function App({
|
||||
const App = forwardRef<{ handleCopyChat: () => void; handleUserMessage: (message: string) => void }, AppProps>(function App({
|
||||
projectId,
|
||||
workflow,
|
||||
dispatch,
|
||||
|
|
@ -133,7 +133,8 @@ const App = forwardRef<{ handleCopyChat: () => void }, AppProps>(function App({
|
|||
}, [messages, onCopyJson]);
|
||||
|
||||
useImperativeHandle(ref, () => ({
|
||||
handleCopyChat
|
||||
handleCopyChat,
|
||||
handleUserMessage
|
||||
}), [handleCopyChat]);
|
||||
|
||||
return (
|
||||
|
|
@ -194,25 +195,25 @@ const App = forwardRef<{ handleCopyChat: () => void }, AppProps>(function App({
|
|||
);
|
||||
});
|
||||
|
||||
export function Copilot({
|
||||
projectId,
|
||||
workflow,
|
||||
chatContext = undefined,
|
||||
dispatch,
|
||||
isInitialState = false,
|
||||
dataSources,
|
||||
}: {
|
||||
export const Copilot = forwardRef<{ handleUserMessage: (message: string) => void }, {
|
||||
projectId: string;
|
||||
workflow: z.infer<typeof Workflow>;
|
||||
chatContext?: z.infer<typeof CopilotChatContext>;
|
||||
dispatch: (action: WorkflowDispatch) => void;
|
||||
isInitialState?: boolean;
|
||||
dataSources?: z.infer<typeof DataSource>[];
|
||||
}) {
|
||||
}>(({
|
||||
projectId,
|
||||
workflow,
|
||||
chatContext = undefined,
|
||||
dispatch,
|
||||
isInitialState = false,
|
||||
dataSources,
|
||||
}, ref) => {
|
||||
const [copilotKey, setCopilotKey] = useState(0);
|
||||
const [showCopySuccess, setShowCopySuccess] = useState(false);
|
||||
const [messages, setMessages] = useState<z.infer<typeof CopilotMessage>[]>([]);
|
||||
const appRef = useRef<{ handleCopyChat: () => void }>(null);
|
||||
const appRef = useRef<{ handleCopyChat: () => void; handleUserMessage: (message: string) => void }>(null);
|
||||
|
||||
function handleNewChat() {
|
||||
setCopilotKey(prev => prev + 1);
|
||||
|
|
@ -228,6 +229,16 @@ export function Copilot({
|
|||
}, 2000);
|
||||
}
|
||||
|
||||
// Expose handleUserMessage through ref
|
||||
useImperativeHandle(ref, () => ({
|
||||
handleUserMessage: (message: string) => {
|
||||
const app = appRef.current as any;
|
||||
if (app?.handleUserMessage) {
|
||||
app.handleUserMessage(message);
|
||||
}
|
||||
}
|
||||
}), []);
|
||||
|
||||
return (
|
||||
<Panel variant="copilot"
|
||||
tourTarget="copilot"
|
||||
|
|
@ -288,5 +299,5 @@ export function Copilot({
|
|||
</div>
|
||||
</Panel>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue