u
This commit is contained in:
@@ -38,6 +38,7 @@ import { ACCEPT_STRING, readFileAttachment } from './chatAttachments';
|
||||
import { ChatStagedAttachmentsTray } from './ChatAttachmentItems';
|
||||
import {
|
||||
BLUE_GLOW,
|
||||
DIALOG_FOG,
|
||||
SHADOW_DRAWER,
|
||||
} from '../../colors';
|
||||
|
||||
@@ -69,7 +70,7 @@ export default class ChatDrawer extends PureComponent {
|
||||
sseStatus: s.sseStatus,
|
||||
sendError: s.sendError,
|
||||
activeTurns: s.activeTurns || [],
|
||||
inputText: '',
|
||||
inputText: s.pendingInput != null ? s.pendingInput : '',
|
||||
isInputFocused: false,
|
||||
stagedAttachments: [],
|
||||
stagedReferences: [],
|
||||
@@ -95,18 +96,39 @@ export default class ChatDrawer extends PureComponent {
|
||||
}, delay);
|
||||
};
|
||||
|
||||
focusInputAtEnd = (delay = 50) => {
|
||||
if (this.focusTimeout) clearTimeout(this.focusTimeout);
|
||||
this.focusTimeout = setTimeout(() => {
|
||||
const el = this.inputRef.current;
|
||||
if (!el) return;
|
||||
el.focus?.();
|
||||
if (typeof el.setSelectionRange === 'function' && el.value) {
|
||||
const len = el.value.length;
|
||||
el.setSelectionRange(len, len);
|
||||
}
|
||||
}, delay);
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
if (this.state.isOpen) {
|
||||
this.focusInput(150);
|
||||
if (chatAutomat.state.pendingInput != null) {
|
||||
this.focusInputAtEnd(150);
|
||||
} else {
|
||||
this.focusInput(150);
|
||||
}
|
||||
}
|
||||
void this.loadModelSettings();
|
||||
if (chatAutomat.state.pendingInput != null) {
|
||||
queueMicrotask(() => {
|
||||
if (chatAutomat.state.pendingInput != null) {
|
||||
chatAutomat.setState({ pendingInput: null });
|
||||
}
|
||||
});
|
||||
}
|
||||
this.unsub = chatAutomat.subscribe(this, (state) => {
|
||||
const wasOpen = this.state.isOpen;
|
||||
const willOpen = state.isOpen;
|
||||
if (!wasOpen && willOpen) {
|
||||
this.focusInput(150);
|
||||
}
|
||||
return {
|
||||
const patch = {
|
||||
isOpen: state.isOpen,
|
||||
conversations: state.conversations,
|
||||
selectedConversationId: state.selectedConversationId,
|
||||
@@ -123,6 +145,20 @@ export default class ChatDrawer extends PureComponent {
|
||||
sendError: state.sendError,
|
||||
activeTurns: state.activeTurns || [],
|
||||
};
|
||||
if (state.pendingInput != null) {
|
||||
patch.inputText = state.pendingInput;
|
||||
patch.stagedAttachments = [];
|
||||
patch.stagedReferences = [];
|
||||
queueMicrotask(() => {
|
||||
if (chatAutomat.state.pendingInput != null) {
|
||||
chatAutomat.setState({ pendingInput: null });
|
||||
}
|
||||
});
|
||||
this.focusInputAtEnd(150);
|
||||
} else if (!wasOpen && willOpen) {
|
||||
this.focusInput(150);
|
||||
}
|
||||
return patch;
|
||||
});
|
||||
|
||||
this.unsubSettings = userSettingsAutomat.subscribe(this, (state) => {
|
||||
@@ -1265,7 +1301,12 @@ export default class ChatDrawer extends PureComponent {
|
||||
|
||||
{/* Unified Copilot-style input container with context reference pills */}
|
||||
<Box
|
||||
onClick={() => this.focusInput(0)}
|
||||
onClick={(e) => {
|
||||
if (this.inputRef.current && (e.target === this.inputRef.current || this.inputRef.current.contains(e.target))) {
|
||||
return;
|
||||
}
|
||||
this.focusInput(0);
|
||||
}}
|
||||
sx={{
|
||||
flex: 1,
|
||||
minWidth: 0,
|
||||
@@ -1463,8 +1504,14 @@ export default class ChatDrawer extends PureComponent {
|
||||
anchor="right"
|
||||
open={isOpen}
|
||||
onClose={this.handleClose}
|
||||
ModalProps={{
|
||||
disableEnforceFocus: true,
|
||||
}}
|
||||
sx={(theme) => ({
|
||||
zIndex: theme.zIndex.drawer + 2,
|
||||
zIndex: theme.zIndex.modal + 10,
|
||||
'& .MuiBackdrop-root': {
|
||||
backgroundColor: DIALOG_FOG,
|
||||
},
|
||||
'& .MuiDrawer-paper': {
|
||||
width: { xs: '100vw', sm: `${totalWidth}px` },
|
||||
maxWidth: '100vw',
|
||||
|
||||
Reference in New Issue
Block a user