Skip to content

Conversation

wilhus
Copy link
Contributor

@wilhus wilhus commented Sep 17, 2025

This is a suggestion for UI/UX enhancements of command result by rendering with a table. It's possible to copy values by clicking the table cell, and the columns can be sorted/filtered. Please try it out and let me know if the idea is good and how it can be improved.

Old New
SCR-20250917-ozvb SCR-20250917-pbks
SCR-20250917-paep SCR-20250917-pbqi
SCR-20250917-pavk SCR-20250917-pbtq

Closes #2256, #2257

@github-actions github-actions bot added the enhancement New feature or request label Sep 17, 2025
@eglitise
Copy link
Collaborator

eglitise commented Sep 17, 2025

Thanks for this - I haven't tested this out yet, but overall I like the idea. I do have some concerns though:

  • I don't think this formatted view should be visible by default. My suggestion would be to make it accessible through a toggle (e.g. in the bottom left corner of the modal), while the default view should still show the raw returned value - it is critical to have for users that call the command through their automation code, since they need to know the exact message format.
    • However, since the raw view doesn't set a limit on the modal height, which you have solved here using the table, I would suggest also wrapping the raw view with a card/table/other component.
  • I would also recommend adding a button to copy the entire raw result to the clipboard. This can be located next to the formatting toggle.
  • For commands returning a primitive value, the formatting toggle can be hidden altogether.

open={!!visibleCommandResult}
onOk={() => setVisibleCommandResult(null)}
onCancel={() => setVisibleCommandResult(null)}
width={900}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This width exceeds the default width of the Inspector window. Responsive width could be a useful approach here: https://ant.design/components/modal#modal-demo-width
In the ideal case, the modal width would also shrink even further if the contents don't require all of it, but I'm not sure how possible this is. It's definitely more of a nice-to-have feature.

padding: 4px 4px 0 0;
}

.command-result-table :global(.ant-table-tbody) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency, please use camelCase for CSS class names

import {copyToClipboard} from '../../../polyfills.js';
import styles from './Commands.module.css';

const isTimestampKey = (key) => key === 'timestamp';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how useful this conversion is, since it will only work for the timestamp key, but the result may include timestamp values under another key. Rendering the raw value is perfectly fine, in my opinion.

};

return (
<Tooltip placement="topLeft" title={isCopied ? 'Copied' : 'Click to copy'}>
Copy link
Collaborator

@eglitise eglitise Sep 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These texts will need to have i18n support, so I would suggest simply reusing the Copied! translation key from SelectedElement.jsx. Click to copy can be omitted if the cursor is changed accordingly.

Comment on lines +103 to +106
const keys = Object.keys(data);
if (keys.length === 1) {
return createTableResult(data[keys[0]]);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will result in the top-level key being hidden from the user

Comment on lines +132 to +134
if (!tableData) {
return <div>No data to display</div>;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably won't be needed if the formatting option is disabled for primitive return values

columns={tableData.columns}
pagination={false}
size="small"
scroll={{y: 400, x: 'max-content'}}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if the y value can be made responsive similarly to the width 🤔 I looked into this a few weeks ago, but couldn't find an answer right away.

@eglitise
Copy link
Collaborator

Superseded by #2358

@eglitise eglitise closed this Oct 16, 2025
@wilhus wilhus deleted the feat-commands-table branch October 20, 2025 11:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feature request: Add a copy to clipboard button for getUrl and getTitle

2 participants