mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
feat(vscode-ide-companion/webview): persist info banner dismissal state and add context control
This commit is contained in:
@@ -77,10 +77,21 @@ export const App: React.FC = () => {
|
|||||||
const inputFieldRef = useRef<HTMLDivElement>(
|
const inputFieldRef = useRef<HTMLDivElement>(
|
||||||
null,
|
null,
|
||||||
) as React.RefObject<HTMLDivElement>;
|
) as React.RefObject<HTMLDivElement>;
|
||||||
const [showBanner, setShowBanner] = useState(true);
|
// Persist the dismissal of the info banner across webview reloads
|
||||||
|
// Use VS Code webview state to avoid flicker on first render.
|
||||||
|
const [showBanner, setShowBanner] = useState<boolean>(() => {
|
||||||
|
try {
|
||||||
|
const state = (vscode.getState?.() as Record<string, unknown>) || {};
|
||||||
|
return state.infoBannerDismissed !== true; // show unless explicitly dismissed
|
||||||
|
} catch {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
const [editMode, setEditMode] = useState<EditMode>('ask');
|
const [editMode, setEditMode] = useState<EditMode>('ask');
|
||||||
const [thinkingEnabled, setThinkingEnabled] = useState(false);
|
const [thinkingEnabled, setThinkingEnabled] = useState(false);
|
||||||
const [isComposing, setIsComposing] = useState(false);
|
const [isComposing, setIsComposing] = useState(false);
|
||||||
|
// When true, do NOT auto-attach the active editor file/selection to message context
|
||||||
|
const [skipAutoActiveContext, setSkipAutoActiveContext] = useState(false);
|
||||||
|
|
||||||
// Completion system
|
// Completion system
|
||||||
const getCompletionItems = React.useCallback(
|
const getCompletionItems = React.useCallback(
|
||||||
@@ -168,6 +179,7 @@ export const App: React.FC = () => {
|
|||||||
setInputText,
|
setInputText,
|
||||||
messageHandling,
|
messageHandling,
|
||||||
fileContext,
|
fileContext,
|
||||||
|
skipAutoActiveContext,
|
||||||
vscode,
|
vscode,
|
||||||
inputFieldRef,
|
inputFieldRef,
|
||||||
isStreaming: messageHandling.isStreaming,
|
isStreaming: messageHandling.isStreaming,
|
||||||
@@ -646,7 +658,16 @@ export const App: React.FC = () => {
|
|||||||
|
|
||||||
<InfoBanner
|
<InfoBanner
|
||||||
visible={showBanner}
|
visible={showBanner}
|
||||||
onDismiss={() => setShowBanner(false)}
|
onDismiss={() => {
|
||||||
|
setShowBanner(false);
|
||||||
|
// merge with existing webview state so we don't clobber other keys
|
||||||
|
try {
|
||||||
|
const prev = (vscode.getState?.() as Record<string, unknown>) || {};
|
||||||
|
vscode.setState?.({ ...prev, infoBannerDismissed: true });
|
||||||
|
} catch {
|
||||||
|
/* no-op */
|
||||||
|
}
|
||||||
|
}}
|
||||||
onLinkClick={(e) => {
|
onLinkClick={(e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
vscode.postMessage({ type: 'openSettings', data: {} });
|
vscode.postMessage({ type: 'openSettings', data: {} });
|
||||||
@@ -663,6 +684,7 @@ export const App: React.FC = () => {
|
|||||||
thinkingEnabled={thinkingEnabled}
|
thinkingEnabled={thinkingEnabled}
|
||||||
activeFileName={fileContext.activeFileName}
|
activeFileName={fileContext.activeFileName}
|
||||||
activeSelection={fileContext.activeSelection}
|
activeSelection={fileContext.activeSelection}
|
||||||
|
skipAutoActiveContext={skipAutoActiveContext}
|
||||||
onInputChange={setInputText}
|
onInputChange={setInputText}
|
||||||
onCompositionStart={() => setIsComposing(true)}
|
onCompositionStart={() => setIsComposing(true)}
|
||||||
onCompositionEnd={() => setIsComposing(false)}
|
onCompositionEnd={() => setIsComposing(false)}
|
||||||
@@ -672,6 +694,9 @@ export const App: React.FC = () => {
|
|||||||
onToggleEditMode={handleToggleEditMode}
|
onToggleEditMode={handleToggleEditMode}
|
||||||
onToggleThinking={handleToggleThinking}
|
onToggleThinking={handleToggleThinking}
|
||||||
onFocusActiveEditor={fileContext.focusActiveEditor}
|
onFocusActiveEditor={fileContext.focusActiveEditor}
|
||||||
|
onToggleSkipAutoActiveContext={() =>
|
||||||
|
setSkipAutoActiveContext((v) => !v)
|
||||||
|
}
|
||||||
onShowCommandMenu={async () => {
|
onShowCommandMenu={async () => {
|
||||||
if (inputFieldRef.current) {
|
if (inputFieldRef.current) {
|
||||||
inputFieldRef.current.focus();
|
inputFieldRef.current.focus();
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ export const InfoBanner: React.FC<InfoBannerProps> = ({
|
|||||||
<a
|
<a
|
||||||
href="#"
|
href="#"
|
||||||
className="no-underline hover:underline cursor-pointer outline-none"
|
className="no-underline hover:underline cursor-pointer outline-none"
|
||||||
style={{ color: 'var(--app-qwen-orange)' }}
|
style={{ color: 'var(--app-secondary-foreground)' }}
|
||||||
onClick={onLinkClick}
|
onClick={onLinkClick}
|
||||||
>
|
>
|
||||||
{linkText}
|
{linkText}
|
||||||
|
|||||||
Reference in New Issue
Block a user