Skip to content

Commit

Permalink
Ensure non add/copy/move ops don’t throw
Browse files Browse the repository at this point in the history
Renderers currently on pay attention to 3 ops (add, remove, replace) when rendering previews. But we would incorrectly assume that an op that appeared in a patch would be supported on renderers, so move, copy, or test would cause an error.

fixes #455
  • Loading branch information
dragonstyle committed Sep 19, 2024
1 parent d48bf28 commit 7798cc7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/inspect_ai/_view/www/dist/assets/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15718,7 +15718,7 @@ const generatePreview = (changes, resolvedState) => {
const requiredMatchCount = changeType.signature.remove.length + changeType.signature.replace.length + changeType.signature.add.length;
let matchingOps = 0;
for (const change of changes) {
if (changeType.signature[change.op].length > 0) {
if (changeType.signature[change.op] && changeType.signature[change.op].length > 0) {
changeType.signature[change.op].forEach((signature) => {
if (change.path.match(signature)) {
matchingOps++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,19 @@ export const StateEventView = ({ id, event, style, stateManager }) => {
const generatePreview = (changes, resolvedState) => {
const results = [];
for (const changeType of RenderableChangeTypes) {
// Note that we currently only have renderers that depend upon
// add, remove, replace, but we should likely add
// move, copy, test
const requiredMatchCount =
changeType.signature.remove.length +
changeType.signature.replace.length +
changeType.signature.add.length;
let matchingOps = 0;
for (const change of changes) {
if (changeType.signature[change.op].length > 0) {
if (
changeType.signature[change.op] &&
changeType.signature[change.op].length > 0
) {
changeType.signature[change.op].forEach((signature) => {
if (change.path.match(signature)) {
matchingOps++;
Expand Down

0 comments on commit 7798cc7

Please sign in to comment.