Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .claude/rules/features/feature-tips.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ paths:
- "backend/app/Http/Actions/FeatureTips/**"
- "backend/app/DomainObjects/Enums/FeatureTip.php"
- "frontend/src/components/common/FeatureTip/**"
- "frontend/src/components/common/AgentHint/**"
---

# Feature tips
Expand All @@ -15,3 +16,4 @@ paths:
- Dismissing or opening a tip records it per user, across all events, and pauses every tip for `DAYS_BETWEEN_TIPS`. `users.feature_tips_hidden_at` turns them off (profile switch, or "Turn off tips" after a dismissal).
- Check the setting that actually controls the feature, and ignore rows the app creates on its own: the waitlist is switched on per ticket (`products.waitlist_enabled`, never for reserved seating), and every event gets a system default check-in list (`is_system_default`). Link straight to the control when it sits inside a drawer (the products page opens `#waitlist-<product id>`).
- A new tip needs: an enum case, a check in `FeatureTipSelectionService` with a unit test, copy and a link in `featureTipContent.ts` with translations, and an illustration from `public/blank-slate/`. Keep the copy short and in the tips' voice.
- AI assistant hints (`common/AgentHint`) point to the published Claude and ChatGPT apps. They show only on Hi.Events Cloud (`account.is_hi_events_cloud`, from `LicenceService::isCloud()`, not `is_saas_mode_enabled`, which other SaaS installs also set), respect `show_feature_tips` and impersonation, hide once the user has any OAuth connection, and are dismissed per placement in browser storage. Change the listing URLs only in `agentPlugins.ts`.
2 changes: 2 additions & 0 deletions backend/app/Resources/Account/AccountResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace HiEvents\Resources\Account;

use HiEvents\DomainObjects\AccountDomainObject;
use HiEvents\Enterprise\Licensing\LicenceService;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

Expand All @@ -23,6 +24,7 @@ public function toArray(Request $request): array

'is_account_email_confirmed' => $this->getAccountVerifiedAt() !== null,
'is_saas_mode_enabled' => config('app.saas_mode_enabled'),
'is_hi_events_cloud' => app(LicenceService::class)->isCloud(),
'requires_manual_verification' => config('app.saas_mode_enabled') && ! $this->getIsManuallyVerified(),

'deletion_request' => $this->getActiveDeletionRequest()
Expand Down
4 changes: 4 additions & 0 deletions backend/resources/api-reference/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -29248,6 +29248,9 @@
"is_saas_mode_enabled": {
"type": "string"
},
"is_hi_events_cloud": {
"type": "string"
},
"requires_manual_verification": {
"type": "string"
},
Expand All @@ -29271,6 +29274,7 @@
"require_two_factor_authentication",
"is_account_email_confirmed",
"is_saas_mode_enabled",
"is_hi_events_cloud",
"requires_manual_verification",
"deletion_request"
],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace Tests\Feature\Http\Actions\Accounts;

use HiEvents\Models\User;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Tests\Concerns\ActsAsAccountUsers;
use Tests\Concerns\ManagesLicence;
use Tests\TestCase;

class GetAccountActionTest extends TestCase
{
use ActsAsAccountUsers;
use DatabaseTransactions;
use ManagesLicence;

private User $owner;

private int $accountId;

protected function setUp(): void
{
parent::setUp();

[$this->owner, $this->accountId] = $this->createAccountOwner();
}

public function test_reports_hi_events_cloud_under_the_cloud_licence(): void
{
$this->useCloudLicence();

$this->getJson("/accounts/{$this->accountId}", $this->headersFor($this->owner, $this->accountId))
->assertOk()
->assertJsonPath('data.is_hi_events_cloud', true);
}

public function test_does_not_report_hi_events_cloud_under_another_licence(): void
{
$this->useLicence(expiresAt: '2099-12-31', env: config('app.env'));

$this->getJson("/accounts/{$this->accountId}", $this->headersFor($this->owner, $this->accountId))
->assertOk()
->assertJsonPath('data.is_hi_events_cloud', false);
}
}
128 changes: 128 additions & 0 deletions frontend/src/components/common/AgentHint/AgentHint.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
.root {
container-type: inline-size;
}

.hint {
display: grid;
grid-template-columns: auto minmax(0, 1fr) auto auto;
grid-template-areas: "icon text actions close";
align-items: center;
column-gap: 12px;
row-gap: 10px;
padding: 10px 8px 10px 12px;
border: 1px solid var(--hi-color-border);
border-radius: 10px;
background: var(--hi-color-gray);
animation: agentHintIn 0.24s ease-out both;
}

.icon {
grid-area: icon;
display: grid;
place-items: center;
width: 30px;
height: 30px;
border-radius: 8px;
background: var(--mantine-color-body);
border: 1px solid var(--hi-color-border);
color: var(--mantine-color-primary-6);
}

.text {
grid-area: text;
min-width: 0;
}

.actions {
grid-area: actions;
}

.title {
margin: 0;
font-size: 0.8125rem;
font-weight: 600;
line-height: 1.35;
color: var(--mantine-color-text);
}

.description {
margin: 1px 0 0;
font-size: 0.78125rem;
line-height: 1.45;
color: var(--hi-color-text-muted);
overflow-wrap: anywhere;
}

.close {
grid-area: close;
color: var(--hi-color-text-tertiary);

&:hover {
color: var(--mantine-color-text);
}
}

.buttons {
display: flex;
flex-wrap: wrap;
gap: 6px;
}

.button {
font-weight: 500;
}

@container (max-width: 559px) {
.hint {
grid-template-columns: auto minmax(0, 1fr) auto;
grid-template-areas:
"icon text close"
". actions actions";
align-items: start;
padding: 10px 6px 12px 12px;
}

.icon {
margin-top: 1px;
}

.actions {
padding-right: 6px;
}

.close {
margin-top: -2px;
}
}

@container (max-width: 359px) {
.hint {
grid-template-areas:
"icon text close"
"actions actions actions";
}

.actions {
.button {
flex: 1 1 0;
}
}
}

@keyframes agentHintIn {
from {
opacity: 0;
transform: translateY(4px);
}

to {
opacity: 1;
transform: none;
}
}

@media (prefers-reduced-motion: reduce) {
.hint {
animation: none;
}
}
46 changes: 46 additions & 0 deletions frontend/src/components/common/AgentHint/AgentPluginButtons.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import {Button} from "@mantine/core";
import {IconBrandOpenai} from "@tabler/icons-react";
import {t} from "@lingui/macro";
import classNames from "classnames";
import {ClaudeIcon} from "./ClaudeIcon.tsx";
import {CHATGPT_PLUGIN_URL, CLAUDE_PLUGIN_URL} from "./agentPlugins.ts";
import classes from "./AgentHint.module.scss";

interface AgentPluginButtonsProps {
size?: 'xs' | 'sm';
className?: string;
testIdPrefix: string;
}

export const AgentPluginButtons = ({size = 'xs', className, testIdPrefix}: AgentPluginButtonsProps) => (
<div className={classNames(classes.buttons, className)}>
<Button
component="a"
href={CLAUDE_PLUGIN_URL}
target="_blank"
rel="noopener noreferrer"
variant="default"
size={size}
leftSection={<ClaudeIcon size={size === 'xs' ? 14 : 16}/>}
aria-label={t`Add Hi.Events to Claude (opens in a new tab)`}
className={classes.button}
data-testid={`${testIdPrefix}-claude`}
>
Claude
</Button>
<Button
component="a"
href={CHATGPT_PLUGIN_URL}
target="_blank"
rel="noopener noreferrer"
variant="default"
size={size}
leftSection={<IconBrandOpenai size={size === 'xs' ? 15 : 17} stroke={1.6}/>}
aria-label={t`Add Hi.Events to ChatGPT (opens in a new tab)`}
className={classes.button}
data-testid={`${testIdPrefix}-chatgpt`}
>
ChatGPT
</Button>
</div>
);
9 changes: 9 additions & 0 deletions frontend/src/components/common/AgentHint/ClaudeIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
interface ClaudeIconProps {
size?: number;
}

export const ClaudeIcon = ({size = 16}: ClaudeIconProps) => (
<svg width={size} height={size} viewBox="0 0 24 24" fill="#D97757" aria-hidden="true" focusable="false">
<path d="m4.7144 15.9555 4.7174-2.6471.079-.2307-.079-.1275h-.2307l-.7893-.0486-2.6956-.0729-2.3375-.0971-2.2646-.1214-.5707-.1215-.5343-.7042.0546-.3522.4797-.3218.686.0608 1.5179.1032 2.2767.1578 1.6514.0972 2.4468.255h.3886l.0546-.1579-.1336-.0971-.1032-.0972L6.973 9.8356l-2.55-1.6879-1.3356-.9714-.7225-.4918-.3643-.4614-.1578-1.0078.6557-.7225.8803.0607.2246.0607.8925.686 1.9064 1.4754 2.4893 1.8336.3643.3035.1457-.1032.0182-.0728-.164-.2733-1.3539-2.4467-1.445-2.4893-.6435-1.032-.17-.6194c-.0607-.255-.1032-.4674-.1032-.7285L6.287.1335 6.6997 0l.9957.1336.419.3642.6192 1.4147 1.0018 2.2282 1.5543 3.0296.4553.8985.2429.8318.091.255h.1579v-.1457l.1275-1.706.2368-2.0947.2307-2.6957.0789-.7589.3764-.9107.7468-.4918.5828.2793.4797.686-.0668.4433-.2853 1.8517-.5586 2.9021-.3643 1.9429h.2125l.2429-.2429.9835-1.3053 1.6514-2.0643.7286-.8196.85-.9046.5464-.4311h1.0321l.759 1.1293-.34 1.1657-1.0625 1.3478-.8804 1.1414-1.2628 1.7-.7893 1.36.0729.1093.1882-.0183 2.8535-.607 1.5421-.2794 1.8396-.3157.8318.3886.091.3946-.3278.8075-1.967.4857-2.3072.4614-3.4364.8136-.0425.0304.0486.0607 1.5482.1457.6618.0364h1.621l3.0175.2247.7892.522.4736.6376-.079.4857-1.2142.6193-1.6393-.3886-3.825-.9107-1.3113-.3279h-.1822v.1093l1.0929 1.0686 2.0035 1.8092 2.5075 2.3314.1275.5768-.3218.4554-.34-.0486-2.2039-1.6575-.85-.7468-1.9246-1.621h-.1275v.17l.4432.6496 2.3436 3.5214.1214 1.0807-.17.3521-.6071.2125-.6679-.1214-1.3721-1.9246L14.38 17.959l-1.1414-1.9428-.1397.079-.674 7.2552-.3156.3703-.7286.2793-.6071-.4614-.3218-.7468.3218-1.4753.3886-1.9246.3157-1.53.2853-1.9004.17-.6314-.0121-.0425-.1397.0182-1.4328 1.9672-2.1796 2.9446-1.7243 1.8456-.4128.164-.7164-.3704.0667-.6618.4008-.5889 2.386-3.0357 1.4389-1.882.929-1.0868-.0062-.1579h-.0546l-6.3385 4.1164-1.1293.1457-.4857-.4554.0608-.7467.2307-.2429 1.9064-1.3114Z"/>
</svg>
);
2 changes: 2 additions & 0 deletions frontend/src/components/common/AgentHint/agentPlugins.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const CLAUDE_PLUGIN_URL = 'https://claude.ai/directory/hi-events';
export const CHATGPT_PLUGIN_URL = 'https://chatgpt.com/plugins/plugin_asdk_app_6afb70938c2c819186d9b7014be2ddba';
45 changes: 45 additions & 0 deletions frontend/src/components/common/AgentHint/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import {CloseButton} from "@mantine/core";
import {IconSparkles} from "@tabler/icons-react";
import {t} from "@lingui/macro";
import classNames from "classnames";
import {AgentPluginButtons} from "./AgentPluginButtons.tsx";
import {AgentHintPlacement, useAgentHint} from "./useAgentHint.ts";
import classes from "./AgentHint.module.scss";

interface AgentHintProps {
placement: AgentHintPlacement;
title: string;
description: string;
className?: string;
}

export const AgentHint = ({placement, title, description, className}: AgentHintProps) => {
const {isVisible, dismiss} = useAgentHint(placement);

if (!isVisible) {
return null;
}

return (
<div className={classNames(classes.root, className)}>
<aside className={classes.hint} aria-label={t`AI assistant tip`} data-testid={`agent-hint-${placement}`}>
<span className={classes.icon} aria-hidden="true">
<IconSparkles size={16} stroke={1.8}/>
</span>
<div className={classes.text}>
<p className={classes.title}>{title}</p>
<p className={classes.description}>{description}</p>
</div>
<AgentPluginButtons className={classes.actions} testIdPrefix={`agent-hint-${placement}`}/>
<CloseButton
className={classes.close}
size="sm"
iconSize={14}
onClick={dismiss}
aria-label={t`Dismiss tip`}
data-testid={`agent-hint-${placement}-dismiss`}
/>
</aside>
</div>
);
};
71 changes: 71 additions & 0 deletions frontend/src/components/common/AgentHint/useAgentHint.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import {useCallback, useSyncExternalStore} from "react";
import {useGetAccount} from "../../../queries/useGetAccount.ts";
import {useGetMe} from "../../../queries/useGetMe.ts";
import {useGetOAuthConnections} from "../../../queries/useGetOAuthConnections.ts";

export type AgentHintPlacement = 'create-event' | 'create-ticket' | 'reports';

const storageKey = (placement: AgentHintPlacement) => `hi-agent-hint-dismissed:${placement}`;
const listeners = new Set<() => void>();
const dismissedThisSession = new Set<AgentHintPlacement>();

const subscribe = (listener: () => void) => {
listeners.add(listener);
window.addEventListener('storage', listener);

return () => {
listeners.delete(listener);
window.removeEventListener('storage', listener);
};
};

const readDismissed = (placement: AgentHintPlacement) => {
if (dismissedThisSession.has(placement)) {
return true;
}

try {
return window.localStorage.getItem(storageKey(placement)) !== null;
} catch {
return false;
}
};

const persistDismissal = (placement: AgentHintPlacement) => {
try {
window.localStorage.setItem(storageKey(placement), new Date().toISOString());
return true;
} catch {
return false;
}
};

export const useIsHiEventsCloud = () => {
const {data: account} = useGetAccount();

return !!account?.is_hi_events_cloud;
};

export const useAgentHint = (placement: AgentHintPlacement) => {
const isCloud = useIsHiEventsCloud();
const {data: me} = useGetMe();
const wantsHints = isCloud && !!me && me.show_feature_tips !== false && !me.is_impersonating;
const {data: connections, isSuccess: connectionsLoaded} = useGetOAuthConnections(wantsHints);

const isDismissed = useSyncExternalStore(
subscribe,
() => readDismissed(placement),
() => true,
);

const dismiss = useCallback(() => {
dismissedThisSession.add(placement);
persistDismissal(placement);
listeners.forEach(listener => listener());
}, [placement]);

return {
isVisible: wantsHints && connectionsLoaded && (connections ?? []).length === 0 && !isDismissed,
dismiss,
};
};
Loading
Loading