Skip to content

Commit

Permalink
refactor: deprecate primitive-hooks (#961)
Browse files Browse the repository at this point in the history
* refactor: deprecate primitive-hooks

* changeset
  • Loading branch information
Yonom authored Oct 10, 2024
1 parent 6ffbfce commit 3d31f10
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 18 deletions.
5 changes: 5 additions & 0 deletions .changeset/fresh-books-greet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@assistant-ui/react": patch
---

refactor: deprecate primitive-hooks
29 changes: 29 additions & 0 deletions packages/react/src/primitive-hooks/actionBar/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,39 @@
export {
/**
* @deprecated Use `useMessageRuntime().copy()` instead. This will be removed in 0.6.
*/
useActionBarCopy,
/**
* @deprecated Use `useMessageRuntime().copy()` instead. This will be removed in 0.6.
*/
type UseActionBarCopyProps,
} from "./useActionBarCopy";
/**
* @deprecated Use `useMessageRuntime().composer.beginEdit()` instead. This will be removed in 0.6.
*/
export { useActionBarEdit } from "./useActionBarEdit";

/**
* @deprecated Use `useMessageRuntime().reload()` instead. This will be removed in 0.6.
*/
export { useActionBarReload } from "./useActionBarReload";

/**
* @deprecated Use `useMessageRuntime().speak()` instead. This will be removed in 0.6.
*/
export { useActionBarSpeak } from "./useActionBarSpeak";

/**
* @deprecated Use `useMessageRuntime().stopSpeaking()` instead. This will be removed in 0.6.
*/
export { useActionBarStopSpeaking } from "./useActionBarStopSpeaking";

/**
* @deprecated Use `useMessageRuntime().submitFeedback()` instead. This will be removed in 0.6.
*/
export { useActionBarFeedbackPositive } from "./useActionBarFeedbackPositive";

/**
* @deprecated Use `useMessageRuntime().submitFeedback()` instead. This will be removed in 0.6.
*/
export { useActionBarFeedbackNegative } from "./useActionBarFeedbackNegative";
14 changes: 14 additions & 0 deletions packages/react/src/primitive-hooks/branchPicker/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
/**
* @deprecated Use `useMessage(m => m.branhcCount)` instead. This will be removed in 0.6.
*/
export { useBranchPickerCount } from "./useBranchPickerCount";

/**
* @deprecated Use `useMessageRuntime().switchToBranch({ position: "next" })` instead. This will be removed in 0.6.
*/
export { useBranchPickerNext } from "./useBranchPickerNext";
/**
* @deprecated Use `useMessage(m => m.branchNumber)` instead. This will be removed in 0.6.
*/
export { useBranchPickerNumber } from "./useBranchPickerNumber";

/**
* @deprecated Use `useMessageRuntime().switchToBranch({ position: "previous" })` instead. This will be removed in 0.6.
*/
export { useBranchPickerPrevious } from "./useBranchPickerPrevious";
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import { useCallback } from "react";
import { useCombinedStore } from "../../utils/combined/useCombinedStore";
import { useEditComposerStore, useMessageStore } from "../../context";
import { useMessageRuntime } from "../../context/react/MessageContext";
import {
useMessage,
useMessageRuntime,
} from "../../context/react/MessageContext";

export const useBranchPickerNext = () => {
const messageRuntime = useMessageRuntime();
const messageStore = useMessageStore();
const editComposerStore = useEditComposerStore();
const disabled = useCombinedStore(
[messageStore, editComposerStore],
(m, c) => c.isEditing || m.branchNumber >= m.branchCount,
);
const disabled = useMessage((m) => m.branchNumber >= m.branchCount);

const callback = useCallback(() => {
messageRuntime.switchToBranch({ position: "next" });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
import { useCallback } from "react";
import {
useEditComposerStore,
useMessage,
useMessageRuntime,
useMessageStore,
} from "../../context/react/MessageContext";
import { useCombinedStore } from "../../utils/combined/useCombinedStore";

export const useBranchPickerPrevious = () => {
const messageRuntime = useMessageRuntime();
const messageStore = useMessageStore();
const editComposerStore = useEditComposerStore();
const disabled = useCombinedStore(
[messageStore, editComposerStore],
(m, c) => c.isEditing || m.branchNumber <= 1,
);
const disabled = useMessage((m) => m.branchNumber <= 1);

const callback = useCallback(() => {
messageRuntime.switchToBranch({ position: "previous" });
Expand Down
10 changes: 10 additions & 0 deletions packages/react/src/primitive-hooks/composer/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
/**
* @deprecated Use `useComposerRuntime().cancel()` instead. This will be removed in 0.6.
*/
export { useComposerCancel } from "./useComposerCancel";
export { useComposerIf } from "./useComposerIf";
/**
* @deprecated Use `useComposerRuntime().send()` instead. This will be removed in 0.6.
*/
export { useComposerSend } from "./useComposerSend";

/**
* @deprecated Use `useComposerRuntime().addAttachment()` instead. This will be removed in 0.6.
*/
export { useComposerAddAttachment } from "./useComposerAddAttachment";
6 changes: 6 additions & 0 deletions packages/react/src/primitive-hooks/thread/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
export { useThreadEmpty } from "./useThreadEmpty";
export { useThreadIf } from "./useThreadIf";
/**
* @deprecated Use `useThreadViewport().scrollToBottom()` instead. This will be removed in 0.6.
*/
export { useThreadScrollToBottom } from "./useThreadScrollToBottom";
/**
* @deprecated Use `useThreadRuntime().append()` instead. This will be removed in 0.6.
*/
export { useThreadSuggestion } from "./useThreadSuggestion";

0 comments on commit 3d31f10

Please sign in to comment.