mirror of
https://github.com/enricoros/big-AGI.git
synced 2026-05-10 21:50:14 -07:00
Proper edit mentions
This commit is contained in:
@@ -22,7 +22,7 @@ function initTestConversation(): DConversation {
|
||||
}
|
||||
|
||||
function initTestBeamStore(messages: DMessage[], beamStore: BeamStoreApi = createBeamVanillaStore()): BeamStoreApi {
|
||||
beamStore.getState().open(messages, getChatLLMId(), (content) => alert(content));
|
||||
beamStore.getState().open(messages, getChatLLMId(), false, (content) => alert(content));
|
||||
return beamStore;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,8 +24,9 @@ export function ChatBarAltBeam(props: {
|
||||
|
||||
|
||||
// external beam state
|
||||
const { isScattering, isGatheringAny, requiresConfirmation, setIsMaximized, terminateBeam } = useBeamStore(props.beamStore, useShallow((store) => ({
|
||||
const { isEditMode, isScattering, isGatheringAny, requiresConfirmation, setIsMaximized, terminateBeam } = useBeamStore(props.beamStore, useShallow((store) => ({
|
||||
// state
|
||||
isEditMode: store.isEditMode,
|
||||
isScattering: store.isScattering,
|
||||
isGatheringAny: store.isGatheringAny,
|
||||
requiresConfirmation: store.isScattering || store.isGatheringAny || store.raysReady > 0,
|
||||
@@ -76,9 +77,9 @@ export function ChatBarAltBeam(props: {
|
||||
: isScattering ? { animation: `${animationColorBeamScatterINV} 5s infinite, ${animationEnterBelow} 0.6s` }
|
||||
: { fontWeight: 'lg' }
|
||||
}>
|
||||
{isGatheringAny ? 'Merging...' : isScattering ? 'Beaming...' : 'Beam'}
|
||||
{isGatheringAny ? 'Merging...' : isScattering ? 'Beaming...' : isEditMode ? 'Beam Edit' : 'Beam'}
|
||||
</Box>
|
||||
{(!isGatheringAny && !isScattering) && ' Mode'}
|
||||
{(!isGatheringAny && !isScattering && !isEditMode) && ' Mode'}
|
||||
</Typography>
|
||||
|
||||
{/* Right Close Icon */}
|
||||
|
||||
@@ -925,7 +925,7 @@ export function ChatMessage(props: {
|
||||
? <>Beam <span style={{ opacity: 0.5 }}>from here</span></>
|
||||
: !props.isBottom
|
||||
? <>Beam <span style={{ opacity: 0.5 }}>this message</span></>
|
||||
: <Box sx={{ flexGrow: 1, display: 'flex', justifyContent: 'space-between', gap: 1 }}>Beam<KeyStroke variant='outlined' combo='Ctrl + Shift + B' /></Box>}
|
||||
: <Box sx={{ flexGrow: 1, display: 'flex', justifyContent: 'space-between', gap: 1 }}>Beam Edit<KeyStroke variant='outlined' combo='Ctrl + Shift + B' /></Box>}
|
||||
</MenuItem>
|
||||
)}
|
||||
</CloseableMenu>
|
||||
|
||||
@@ -234,7 +234,7 @@ export class ConversationHandler {
|
||||
terminateKeepingSettings();
|
||||
};
|
||||
|
||||
beamOpen(viewHistory, getChatLLMId(), onBeamSuccess);
|
||||
beamOpen(viewHistory, getChatLLMId(), !!destReplaceMessageId, onBeamSuccess);
|
||||
importMessages.length && beamImportRays(importMessages, getChatLLMId());
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ type BeamSuccessCallback = (messageUpdate: Pick<DMessage, 'fragments' | 'generat
|
||||
interface RootStateSlice {
|
||||
|
||||
isOpen: boolean;
|
||||
isEditMode: boolean;
|
||||
isMaximized: boolean;
|
||||
inputHistory: DMessage[] | null;
|
||||
inputIssues: string | null;
|
||||
@@ -43,6 +44,7 @@ interface RootStateSlice {
|
||||
const initRootStateSlice = (): RootStateSlice => ({
|
||||
|
||||
isOpen: false,
|
||||
isEditMode: false,
|
||||
isMaximized: false,
|
||||
inputHistory: null,
|
||||
inputIssues: null,
|
||||
@@ -54,7 +56,7 @@ const initRootStateSlice = (): RootStateSlice => ({
|
||||
export interface RootStoreSlice extends RootStateSlice {
|
||||
|
||||
// lifecycle
|
||||
open: (chatHistory: Readonly<DMessage[]>, initialChatLlmId: DLLMId | null, callback: BeamSuccessCallback) => void;
|
||||
open: (chatHistory: Readonly<DMessage[]>, initialChatLlmId: DLLMId | null, isEditMode: boolean, callback: BeamSuccessCallback) => void;
|
||||
terminateKeepingSettings: () => void;
|
||||
loadBeamConfig: (preset: BeamConfigSnapshot | null) => void;
|
||||
|
||||
@@ -70,7 +72,7 @@ const createRootSlice: StateCreator<BeamStore, [], [], RootStoreSlice> = (_set,
|
||||
...initRootStateSlice(),
|
||||
|
||||
|
||||
open: (chatHistory: Readonly<DMessage[]>, initialChatLlmId: DLLMId | null, callback: BeamSuccessCallback) => {
|
||||
open: (chatHistory: Readonly<DMessage[]>, initialChatLlmId: DLLMId | null, isEditMode: boolean, callback: BeamSuccessCallback) => {
|
||||
const { isOpen: wasAlreadyOpen, terminateKeepingSettings, loadBeamConfig, hadImportedRays, setRayLlmIds, setCurrentGatherLlmId } = _get();
|
||||
|
||||
// reset pending operations
|
||||
@@ -84,6 +86,7 @@ const createRootSlice: StateCreator<BeamStore, [], [], RootStoreSlice> = (_set,
|
||||
_set({
|
||||
// input
|
||||
isOpen: true,
|
||||
isEditMode,
|
||||
inputHistory: isValidHistory ? history : null,
|
||||
inputIssues: isValidHistory ? null : 'Invalid conversation history: missing user message',
|
||||
inputReady: isValidHistory,
|
||||
|
||||
Reference in New Issue
Block a user