Skip to content

Commit 21131fe

Browse files
authored
feat: Tables that have names starting with underscore do not auto-launch from console (#1656)
- Creating a table with a name that begins with an underscore will not open it regardless of whether "Auto Launch Panels" is checked - Closes #1549 - Fixes a bug where tables will not update if its variable is reassigned while "Auto Launch Panels" is unchecked - Closes #1410 ### Testing Instructions: 1. Run the following code with the "Auto Launch Panels" option checked: ```py from deephaven import empty_table t = empty_table(10).update("x=i") _t = empty_table(10).update("x=i") ``` 2. Table `t` should open automatically but table `_t` should remain closed 3. Clicking on the button for `_t` should open it normally 4. Run `_t = empty_table(10).update("x=i+10")`. This should update the values in `_t` if it is open - Nothing should happen if `_t` is closed. BREAKING CHANGE: Tables assigned to variable beginning with "_" will not open automatically even if "Auto Launch Panels" is checked.
1 parent c0cc966 commit 21131fe

2 files changed

Lines changed: 44 additions & 8 deletions

File tree

packages/console/src/Console.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,14 @@ interface ConsoleProps {
6060
statusBarChildren: ReactNode;
6161
settings: Partial<Settings>;
6262
focusCommandHistory: () => void;
63-
openObject: (object: VariableDefinition) => void;
63+
64+
/**
65+
* @param object The object to open
66+
* @param forceOpen If true, always open the object. If false, only update existing panels
67+
*/
68+
openObject: (object: VariableDefinition, forceOpen?: boolean) => void;
69+
70+
/** Closes all panels containing the object */
6471
closeObject: (object: VariableDefinition) => void;
6572
session: IdeSession;
6673
language: string;
@@ -471,14 +478,19 @@ export class Console extends PureComponent<ConsoleProps, ConsoleState> {
471478
}, Console.LOG_THROTTLE);
472479

473480
openUpdatedItems(changes: VariableChanges): void {
481+
log.debug('openUpdatedItems', changes);
474482
const { isAutoLaunchPanelsEnabled } = this.state;
475-
if (changes == null || !isAutoLaunchPanelsEnabled) {
483+
if (changes == null) {
476484
return;
477485
}
478486

479487
const { openObject } = this.props;
480488
[...changes.created, ...changes.updated].forEach(object =>
481-
openObject(object)
489+
openObject(
490+
object,
491+
isAutoLaunchPanelsEnabled &&
492+
(object.title === undefined || !object.title.startsWith('_'))
493+
)
482494
);
483495
}
484496

packages/dashboard-core-plugins/src/panels/ConsolePanel.tsx

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ import {
1111
HeapUsage,
1212
ObjectIcon,
1313
} from '@deephaven/console';
14-
import { DashboardPanelProps, PanelEvent } from '@deephaven/dashboard';
14+
import {
15+
DashboardPanelProps,
16+
LayoutManagerContext,
17+
LayoutUtils,
18+
PanelEvent,
19+
} from '@deephaven/dashboard';
1520
import type { IdeSession, VariableDefinition } from '@deephaven/jsapi-types';
1621
import { SessionWrapper } from '@deephaven/jsapi-utils';
1722
import Log from '@deephaven/log';
@@ -84,6 +89,8 @@ export class ConsolePanel extends PureComponent<
8489

8590
static TITLE = 'Console';
8691

92+
static contextType = LayoutManagerContext;
93+
8794
constructor(props: ConsolePanelProps) {
8895
super(props);
8996

@@ -235,18 +242,35 @@ export class ConsolePanel extends PureComponent<
235242
this.updateDimensions();
236243
}
237244

238-
handleOpenObject(object: VariableDefinition): void {
245+
handleOpenObject(object: VariableDefinition, forceOpen = true): void {
239246
const { sessionWrapper } = this.props;
240247
const { session } = sessionWrapper;
241-
this.openWidget(object, session);
248+
const { root } = this.context;
249+
const oldPanelId =
250+
object.title != null ? this.getItemId(object.title, false) : null;
251+
if (
252+
forceOpen ||
253+
(oldPanelId != null &&
254+
LayoutUtils.getStackForRoot(
255+
root,
256+
{ id: oldPanelId },
257+
false,
258+
false,
259+
false
260+
) != null)
261+
) {
262+
this.openWidget(object, session);
263+
}
242264
}
243265

244266
handleCloseObject(object: VariableDefinition): void {
245267
const { title } = object;
246268
if (title !== undefined) {
247269
const id = this.getItemId(title, false);
248-
const { glEventHub } = this.props;
249-
glEventHub.emit(PanelEvent.CLOSE, id);
270+
if (id != null) {
271+
const { glEventHub } = this.props;
272+
glEventHub.emit(PanelEvent.CLOSE, id);
273+
}
250274
}
251275
}
252276

0 commit comments

Comments
 (0)