-
Notifications
You must be signed in to change notification settings - Fork 107
Display active runtime metadata in console pane #6156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
dhruvisompura
merged 12 commits into
main
from
feature/display-active-runtime-metadata-in-console-pane
Jan 31, 2025
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
f7d6a82
Add feature flag for multi console sessions
dhruvisompura dda0cf3
Add console session info button
dhruvisompura 28547c1
Display basic session data
dhruvisompura d41d1f6
Add action to open output channel
dhruvisompura 2195f9a
Display session state
dhruvisompura 7667e9d
Update colors and markup
dhruvisompura cb9ff95
Clean up CSS syntax
dhruvisompura 8558faf
Add localization
dhruvisompura 1ee98e4
Condense multi-line import to single line
dhruvisompura c247ff8
Remove checks for undefined session
dhruvisompura 243e45c
Prevent useEffect from running on every render
dhruvisompura 32e4dcc
Reduce unnecessary computations per render cycle
dhruvisompura File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/vs/workbench/contrib/positronConsole/browser/components/consoleInstanceInfoButton.css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (C) 2025 Posit Software, PBC. All rights reserved. | ||
* Licensed under the Elastic License 2.0. See LICENSE.txt for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
.positron-modal-popup-children:has(.console-instance-info) { | ||
background: var(--vscode-editorHoverWidget-background); | ||
} | ||
|
||
.console-instance-info .top-separator { | ||
border-top: 1px solid var(--vscode-editorHoverWidget-border); | ||
} | ||
|
||
.console-instance-info .actions { | ||
background-color: var(--vscode-editorHoverWidget-statusBarBackground); | ||
padding-bottom: 4px; | ||
} | ||
|
||
.console-instance-info .content .line { | ||
margin: 8px 0; | ||
overflow-wrap: break-word; | ||
padding: 0 8px; | ||
} | ||
|
||
.console-instance-info .actions .link { | ||
color: var(--vscode-textLink-foreground); | ||
cursor: pointer; | ||
font-size: 12px; | ||
line-height: 22px; | ||
padding: 0 8px; | ||
text-decoration: underline; | ||
} |
135 changes: 135 additions & 0 deletions
135
src/vs/workbench/contrib/positronConsole/browser/components/consoleInstanceInfoButton.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (C) 2025 Posit Software, PBC. All rights reserved. | ||
* Licensed under the Elastic License 2.0. See LICENSE.txt for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
// CSS. | ||
import './consoleInstanceInfoButton.css'; | ||
|
||
// React. | ||
import React, { useEffect, useRef, useState } from 'react'; | ||
|
||
// Other dependencies. | ||
import { localize } from '../../../../../nls.js'; | ||
import * as DOM from '../../../../../base/browser/dom.js'; | ||
import { PositronModalPopup } from '../../../../browser/positronComponents/positronModalPopup/positronModalPopup.js' | ||
import { ActionBarButton } from '../../../../../platform/positronActionBar/browser/components/actionBarButton.js'; | ||
import { PositronModalReactRenderer } from '../../../../browser/positronModalReactRenderer/positronModalReactRenderer.js'; | ||
import { usePositronConsoleContext } from '../positronConsoleContext.js'; | ||
import { PositronButton } from '../../../../../base/browser/ui/positronComponents/button/positronButton.js'; | ||
import { ILanguageRuntimeSession } from '../../../../services/runtimeSession/common/runtimeSessionService.js'; | ||
import { DisposableStore } from '../../../../../base/common/lifecycle.js'; | ||
|
||
const positronConsoleInfo = localize('positron.console.info.label', "Console information"); | ||
const showKernelOutputChannel = localize('positron.console.info.showKernelOutputChannel', "Show Kernel Output Channel"); | ||
|
||
export const ConsoleInstanceInfoButton = () => { | ||
// Hooks. | ||
const positronConsoleContext = usePositronConsoleContext(); | ||
|
||
// Reference hooks. | ||
const ref = useRef<HTMLButtonElement>(undefined!); | ||
|
||
const handlePressed = () => { | ||
if (!positronConsoleContext.activePositronConsoleInstance) { | ||
return; | ||
} | ||
|
||
// Create the renderer. | ||
const renderer = new PositronModalReactRenderer({ | ||
keybindingService: positronConsoleContext.keybindingService, | ||
layoutService: positronConsoleContext.workbenchLayoutService, | ||
container: positronConsoleContext.workbenchLayoutService.getContainer(DOM.getWindow(ref.current)), | ||
parent: ref.current | ||
}); | ||
|
||
renderer.render( | ||
<ConsoleInstanceInfoModalPopup | ||
anchorElement={ref.current} | ||
renderer={renderer} | ||
session={positronConsoleContext.activePositronConsoleInstance.session} | ||
/> | ||
); | ||
} | ||
|
||
// Render. | ||
return ( | ||
<ActionBarButton | ||
iconId='info' | ||
align='right' | ||
tooltip={positronConsoleInfo} | ||
ariaLabel={positronConsoleInfo} | ||
onPressed={handlePressed} | ||
ref={ref} | ||
/> | ||
) | ||
}; | ||
|
||
interface ConsoleInstanceInfoModalPopupProps { | ||
anchorElement: HTMLElement; | ||
renderer: PositronModalReactRenderer; | ||
session: ILanguageRuntimeSession; | ||
} | ||
|
||
const ConsoleInstanceInfoModalPopup = (props: ConsoleInstanceInfoModalPopupProps) => { | ||
const [sessionState, setSessionState] = useState(() => props.session.getRuntimeState()); | ||
|
||
// Main useEffect hook. | ||
useEffect(() => { | ||
const disposableStore = new DisposableStore(); | ||
disposableStore.add(props.session.onDidChangeRuntimeState(state => { | ||
setSessionState(state); | ||
})); | ||
return () => disposableStore.dispose(); | ||
}, []); | ||
|
||
const showKernelOutputChannelClickHandler = () => { | ||
props.session.showOutput(); | ||
} | ||
|
||
// Render. | ||
return ( | ||
<PositronModalPopup | ||
dhruvisompura marked this conversation as resolved.
Show resolved
Hide resolved
|
||
anchorElement={props.anchorElement} | ||
height='min-content' | ||
keyboardNavigationStyle='menu' | ||
renderer={props.renderer} | ||
popupAlignment='auto' | ||
popupPosition='auto' | ||
width={400} | ||
> | ||
<div className='console-instance-info'> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed! This is something I noticed and made a note about in the epic around cleanup/improvements! |
||
<div className='content'> | ||
<p className='line'>{props.session.metadata.sessionName}</p> | ||
<div className='top-separator'> | ||
<p className='line'> | ||
{(() => localize( | ||
'positron.console.info.sessionId', 'Session ID: {0}', | ||
props.session.sessionId | ||
))()} | ||
</p> | ||
<p className='line'>{(() => localize( | ||
'positron.console.info.state', 'State: {0}', | ||
sessionState))()} | ||
</p> | ||
</div> | ||
<div className='top-separator'> | ||
<p className='line'>{(() => localize( | ||
'positron.console.info.runtimePath', 'Path: {0}', | ||
props.session.runtimeMetadata.runtimePath))()} | ||
</p> | ||
<p className='line'>{(() => localize( | ||
'positron.console.info.runtimeSource', 'Source: {0}', | ||
props.session.runtimeMetadata.runtimeSource))()} | ||
</p> | ||
</div> | ||
</div> | ||
<div className='top-separator actions'> | ||
<PositronButton className='link' onPressed={showKernelOutputChannelClickHandler}> | ||
{showKernelOutputChannel} | ||
</PositronButton> | ||
</div> | ||
</div> | ||
</PositronModalPopup> | ||
) | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...vs/workbench/services/runtimeSession/common/positronMultipleConsoleSessionsFeatureFlag.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (C) 2025 Posit Software, PBC. All rights reserved. | ||
* Licensed under the Elastic License 2.0. See LICENSE.txt for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { localize } from '../../../../nls.js'; | ||
import { IConfigurationService } from '../../../../platform/configuration/common/configuration.js'; | ||
import { ConfigurationScope, Extensions, IConfigurationRegistry } from '../../../../platform/configuration/common/configurationRegistry.js'; | ||
import { Registry } from '../../../../platform/registry/common/platform.js'; | ||
import { positronConfigurationNodeBase } from '../../languageRuntime/common/languageRuntime.js'; | ||
|
||
// Key for the multiple sessions setting | ||
export const USE_POSITRON_MULTIPLE_CONSOLE_SESSIONS_CONFIG_KEY = | ||
'positron.multipleConsoleSessions'; | ||
|
||
/** | ||
* Retrieves the value of the configuration setting that determines whether to enable | ||
* multiple sessions feature. | ||
* @param configurationService The configuration service | ||
* @returns Whether to enablet the multiple sessions feature | ||
*/ | ||
export function multipleConsoleSessionsFeatureEnabled( | ||
configurationService: IConfigurationService | ||
) { | ||
return Boolean( | ||
configurationService.getValue(USE_POSITRON_MULTIPLE_CONSOLE_SESSIONS_CONFIG_KEY) | ||
); | ||
} | ||
|
||
// Register the configuration setting | ||
const configurationRegistry = Registry.as<IConfigurationRegistry>( | ||
Extensions.Configuration | ||
); | ||
configurationRegistry.registerConfiguration({ | ||
...positronConfigurationNodeBase, | ||
scope: ConfigurationScope.MACHINE_OVERRIDABLE, | ||
properties: { | ||
[USE_POSITRON_MULTIPLE_CONSOLE_SESSIONS_CONFIG_KEY]: { | ||
type: 'boolean', | ||
default: false, | ||
markdownDescription: localize( | ||
'positron.enableMultipleConsoleSessionsFeature', | ||
'**CAUTION**: Enable experimental Positron multiple console sessions features which may result in unexpected behaviour. Please restart Positron if you change this option.' | ||
), | ||
}, | ||
}, | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.