@instructure/platform-learning-agent-launcher
v1.1.1
Published
Initial React package scaffold for launching the Learning Agent user experience.
Readme
@instructure/platform-learning-agent-launcher
Initial React package scaffold for launching the Learning Agent user experience.
Features
- Host-agnostic React component package
- InstUI-based launcher button component
- Storybook story for local development
- Vitest + Testing Library test setup
- TypeScript declaration output via Vite build
Installation
pnpm add @instructure/platform-learning-agent-launcherPeer Dependencies
{
"@instructure/platform-provider": "^0.1.1",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"@instructure/ui-buttons": "^10.0.0",
"@instructure/ui-svg-images": "^10.0.0"
}Usage
import { PlatformUiProvider } from '@instructure/platform-provider'
import { LearningAgentLauncher } from '@instructure/platform-learning-agent-launcher'
import '@instructure/platform-learning-agent-launcher/styles'
export function Example() {
return (
<PlatformUiProvider executeQuery={async () => ({})} currentUserId="12345">
<LearningAgentLauncher
learningAgentPath="/lms-launcher"
lmsPathname="/courses/42/modules/items/9"
lmsDomain="canvas.example.edu"
lmsHasAthenaUser={false}
/>
</PlatformUiProvider>
)
}Minimal Usage (All Launcher Defaults)
import { PlatformUiProvider } from '@instructure/platform-provider'
import { QueryClient } from '@tanstack/react-query'
import { LearningAgentLauncher } from '@instructure/platform-learning-agent-launcher'
import '@instructure/platform-learning-agent-launcher/styles'
const queryClient = new QueryClient()
export function ExampleWithDefaults() {
return (
<PlatformUiProvider
executeQuery={async () => ({})}
currentUserId="12345"
locale="en"
timezone="America/Denver"
appContext="canvas-academic"
queryClient={queryClient}
>
<LearningAgentLauncher />
</PlatformUiProvider>
)
}API
All LearningAgentLauncher props are optional.
Temporary behavior note: when lmsHasAthenaUser is false, the launcher renders nothing (null). This is a temporary rollout behavior until Canvas supports multiple feature flags.
label?: string- Optional launcher button label.
- Defaults to
Launch Athena.
enabled?: boolean- Controls button enabled/disabled state.
- Defaults to
true.
learningAgentDomain?: string- Base Learning Agent domain.
- Defaults to
https://studywithathena.com.
learningAgentPath?: string- Destination path used when building the launcher URL.
- Defaults to
/lms-launcher.
lmsPathname?: string- Optional LMS pathname context passed in query params as
lmsPathname. - will be used to derive the course context for the Learning Agent experience.
- Defaults to
window.location.pathnamewhen omitted.
- Optional LMS pathname context passed in query params as
lmsDomain?: string- Optional LMS domain context passed in query params as
lmsDomain. - i.e.
myuniversity.instructure.com. - Defaults to
window.location.hostwhen omitted.
- Optional LMS domain context passed in query params as
lmsUserId?: string- Optional LMS user identifier passed in query params as
lmsUserId. - Defaults to
currentUserIdfromPlatformUiProviderwhen omitted.
- Optional LMS user identifier passed in query params as
lmsHasAthenaUser?: boolean- Whether the LMS user has an Athena user account
- When
false, the component returnsnulland does not render a launcher button (temporary until Canvas has multiple feature flags). - Passed in query params as
lmsHasAthenaUser. - Defaults to
false.
lmsSource?: string- Source value passed in query params as
lmsSource. - Defaults to
appContextfromPlatformUiProviderwhen omitted.
- Source value passed in query params as
locale?: string- Locale value passed in query params as
locale. - Defaults to
localefromPlatformUiProviderwhen omitted.
- Locale value passed in query params as
timezone?: string- Timezone value passed in query params as
timezone. - Defaults to
timezonefromPlatformUiProviderwhen omitted.
- Timezone value passed in query params as
Development
# Run tests
pnpm test
# Run tests with coverage
pnpm test --coverage
# Build
pnpm build
# Type check
pnpm type-check