Skip to content

Commit

Permalink
feat: update share functionality to include comparison engines state (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
HashCookie authored Jan 21, 2025
1 parent 8a8a647 commit e6ab88a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions app/components/editor/hooks/useIndex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default function useIndex() {
const [share, setShare] = useState('');
const [enforceContextData, setEnforceContextData] = useState(new Map(defaultEnforceContextData));
const [selectedEngine, setSelectedEngine] = useState('node');
const [comparisonEngines, setComparisonEngines] = useState<string[]>([]);
const loadState = useRef<{
loadedHash?: string;
}>({});
Expand Down Expand Up @@ -54,6 +55,9 @@ export default function useIndex() {
if (shared?.selectedEngine) {
setSelectedEngine(shared.selectedEngine);
}
if (shared?.comparisonEngines) {
setComparisonEngines(shared.comparisonEngines);
}
};

useEffect(() => {
Expand Down Expand Up @@ -121,5 +125,7 @@ export default function useIndex() {
handleShare,
selectedEngine,
setSelectedEngine,
comparisonEngines,
setComparisonEngines,
};
}
1 change: 1 addition & 0 deletions app/components/editor/hooks/useShareInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export interface ShareFormat {
requestResult?: object;
enforceContext?: string;
selectedEngine?: string;
comparisonEngines?: string[];
}

async function dpaste(content: string) {
Expand Down
4 changes: 3 additions & 1 deletion app/components/editor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ export const EditorScreen = () => {
handleShare,
selectedEngine,
setSelectedEngine,
comparisonEngines,
setComparisonEngines,
} = useIndex();
const { enforcer } = useRunTest();
const { shareInfo } = useShareInfo();
Expand All @@ -61,7 +63,6 @@ export const EditorScreen = () => {
const [showCustomConfig, setShowCustomConfig] = useState(false);
const [isLoading, setIsLoading] = useState(false);
const [requestResults, setRequestResults] = useState<ResultsMap>({});
const [comparisonEngines, setComparisonEngines] = useState<string[]>([]);
const skipNextEffectRef = useRef(false);
const sidePanelChatRef = useRef<{ openDrawer: (message: string) => void } | null>(null);
const { setupEnforceContextData, setupHandleEnforceContextChange } = useSetupEnforceContext({
Expand Down Expand Up @@ -457,6 +458,7 @@ export const EditorScreen = () => {
request,
requestResult: Array.from(enforceContextData.entries()),
selectedEngine,
comparisonEngines,
});
}}
>
Expand Down

0 comments on commit e6ab88a

Please sign in to comment.