-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AI-powered Q&A w/ Document Citation Builds on work from - #2148 - #2151 - #2155 - #2157 - #2161 - #2163
- Loading branch information
1 parent
4e11b37
commit 0bb9084
Showing
31 changed files
with
2,270 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import { useEffect } from 'react' | ||
import Cookies from 'js-cookie' | ||
import { IconWand24 } from '@hashicorp/flight-icons/svg-react/wand-24' | ||
|
||
import { toast, ToastColor } from 'components/toast' | ||
import useAuthentication from 'hooks/use-authentication' | ||
|
||
import { CmdCtrlIcon } from 'components/command-bar/components/cmd-ctrl-icon' | ||
import { KIcon } from 'components/command-bar/components/k-icon' | ||
import Badge from 'components/badge' | ||
|
||
const COOKIE_IGNORE_AI_TOAST = 'dev-dot-ignore-ai-toast' | ||
const COOKIE_HAS_SEEN_AI_TOAST = 'dev-dot-has-seen-ai-toast' | ||
const COOKIE_EXPIRES_AT = new Date('12/25/2024') // arbitrary date | ||
|
||
const TOAST_AUTO_DISMISS_MS = 15000 | ||
|
||
export function AIFeatureToast() { | ||
const { session } = useAuthentication() | ||
|
||
useEffect(() => { | ||
// skip toast if we're past the expiration date | ||
if (new Date() > COOKIE_EXPIRES_AT) { | ||
return | ||
} | ||
|
||
// skip toast if user has previously dismissed it | ||
if (Cookies.get(COOKIE_IGNORE_AI_TOAST)) { | ||
return | ||
} | ||
|
||
// skip toast if it's already been seen | ||
if (Cookies.get(COOKIE_HAS_SEEN_AI_TOAST)) { | ||
return | ||
} | ||
|
||
if (session?.meta.isAIEnabled) { | ||
toast({ | ||
color: ToastColor.highlight, | ||
icon: <IconWand24 />, | ||
title: 'Welcome to the Developer AI closed beta', | ||
description: ( | ||
<> | ||
Try it out in our{' '} | ||
<Badge | ||
ariaLabel="Command or control key" | ||
color="neutral-dark-mode" | ||
icon={<CmdCtrlIcon />} | ||
size="small" | ||
/>{' '} | ||
<Badge | ||
ariaLabel="K key" | ||
color="neutral-dark-mode" | ||
icon={<KIcon />} | ||
size="small" | ||
/>{' '} | ||
menu! | ||
</> | ||
), | ||
autoDismiss: TOAST_AUTO_DISMISS_MS, | ||
onDismissCallback: () => { | ||
// when user dismisses the toast, we should ignore it going forwards | ||
Cookies.set(COOKIE_IGNORE_AI_TOAST, true, { | ||
expires: COOKIE_EXPIRES_AT, | ||
}) | ||
// remove extra cookie | ||
Cookies.remove(COOKIE_HAS_SEEN_AI_TOAST) | ||
}, | ||
dismissOnRouteChange: false, | ||
}) | ||
|
||
// if the user didn't explicitly dismiss the toast, show it again in 24 hours | ||
// this is a simple means to boost discoverability / awareness | ||
Cookies.set(COOKIE_HAS_SEEN_AI_TOAST, true, { | ||
expires: 1, // https://github.com/js-cookie/js-cookie?tab=readme-ov-file#expires | ||
}) | ||
} | ||
}, [session?.meta.isAIEnabled]) | ||
|
||
// no dom elements are needed for this component | ||
return null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
.chat { | ||
height: 100%; | ||
background: var(--token-color-palette-neutral-100); | ||
display: flex; | ||
flex-direction: column; | ||
z-index: 9999; | ||
justify-content: space-between; | ||
} | ||
|
||
.messageList { | ||
overflow-y: auto; | ||
max-height: 100%; | ||
display: flex; | ||
flex-direction: column; | ||
flex: 1; | ||
} | ||
|
||
.arrowdown { | ||
position: absolute; | ||
top: -52px; | ||
right: 20px; | ||
} | ||
|
||
.bottom { | ||
position: relative; /* for absolute positioned arrow down button */ | ||
padding: 16px 20px; | ||
display: flex; | ||
flex-direction: column; | ||
gap: 12px; | ||
background: var(--token-color-surface-primary); | ||
border-top: 1px solid var(--token-color-border-primary); | ||
} | ||
|
||
.question { | ||
display: flex; | ||
flex-direction: row; | ||
align-items: flex-end; | ||
padding: 8px 0; | ||
gap: 12px; | ||
background: var(--token-color-surface-primary); | ||
} | ||
.questionIcon { | ||
height: 40px; | ||
width: 40px; | ||
padding: 8px; | ||
|
||
/* See prior art: https://hashicorp-mktg.sourcegraph.com/github.com/hashicorp/web/-/blob/apps/www/views/state-of-the-cloud/2021/components/hero/style.module.css?L18-19 */ | ||
& :global(.loading) { | ||
animation: hds-flight-icon-animation-rotation 9s linear infinite; | ||
animation-duration: 0.7s; | ||
} | ||
} | ||
|
||
.purple { | ||
color: var(--token-color-foreground-highlight-on-surface); | ||
} | ||
|
||
@keyframes hds-flight-icon-animation-rotation { | ||
100% { | ||
transform: rotate(360deg); | ||
} | ||
} | ||
|
||
.reset { | ||
margin: 0; | ||
padding: 0; | ||
border: 0; | ||
box-sizing: border-box; | ||
font: inherit; | ||
font-size: 100%; | ||
vertical-align: baseline; | ||
text-decoration: none; | ||
-webkit-tap-highlight-color: transparent; | ||
outline: transparent; | ||
} | ||
|
||
.textarea { | ||
composes: g-focus-ring-from-box-shadow from global; | ||
|
||
/* Body/300/Medium */ | ||
composes: hds-typography-body-300 from global; | ||
composes: hds-font-weight-medium from global; | ||
appearance: none; | ||
border-radius: 5px; | ||
padding: 8px 4px; | ||
display: flex; | ||
flex: 1; | ||
height: 100%; | ||
resize: none; | ||
background: transparent; | ||
} | ||
.button { | ||
height: 24px; | ||
width: 24px; | ||
background: transparent; | ||
&:focus { | ||
outline: auto; | ||
} | ||
} | ||
|
||
.disclaimer { | ||
color: var(--token-color-foreground-faint); /* #656a76 */ | ||
display: block; | ||
padding: 8px 0 0 10px; | ||
} |
Oops, something went wrong.
0bb9084
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
dev-portal – ./
dev-portal-git-main-hashicorp.vercel.app
developer.hashicorp.com
docs.hashicorp.com
dev-portal-hashicorp.vercel.app