Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/ISSUE_TEMPLATE/runtime_error_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
name: Runtime error report
about: Report a runtime/model/space error from HARP
title: "HARP runtime error report"
labels: bug
assignees: ""
---

## Summary
<!-- Briefly describe the error -->

## Endpoint
<!-- Space/model endpoint if available -->

## User Notes
<!-- What were you doing when this happened? -->

## Environment
<!-- HARP version, local time, log file path -->

## Reproduction
1.
2.
3.

## Expected Behavior

## Actual Behavior

16 changes: 15 additions & 1 deletion src/MainComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ void MainComponent::openSettingsWindow()
DialogWindow::LaunchOptions options;
options.dialogTitle = "Settings";
options.dialogBackgroundColour = Colours::darkgrey;
options.content.setOwned(new SettingsWindow());
options.content.setOwned(new SettingsWindow([this] { restoreViewDefaults(); }));

options.useNativeTitleBar = true;
options.resizable = true;
Expand All @@ -216,6 +216,20 @@ void MainComponent::openSettingsWindow()
options.launchAsync();
}

void MainComponent::restoreViewDefaults()
{
// Default: status area shown — toggle if currently hidden
if (! showStatusArea)
viewStatusAreaCallback();

// Default: media clipboard shown — toggle if currently hidden
if (! showMediaClipboard)
viewMediaClipboardCallback();

// showWelcomePopup default (true) is already restored by clearing settings;
// it will show on the next launch automatically.
}

/* --View-- */

void MainComponent::viewStatusAreaCallback()
Expand Down
1 change: 1 addition & 0 deletions src/MainComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class MainComponent : public Component,
// View
void viewStatusAreaCallback();
void viewMediaClipboardCallback();
void restoreViewDefaults();

// Help
void openAboutWindow();
Expand Down
80 changes: 53 additions & 27 deletions src/Model.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @file Model.h
* @brief Model state and interface for loading and processing.
* @author hugofloresgarcia, aldo-aguilar, xribene, cwitkowitz
* @author hugofloresgarcia, aldo-aguilar, xribene, cwitkowitz, saumya-pailwan
*/

#pragma once
Expand Down Expand Up @@ -85,19 +85,46 @@ struct ModelMetadata
class Model
{
public:
Model() { resetState(); }
~Model() { resetState(); }
Model() { resetState(/*suppressStatus=*/true); }
~Model() { resetState(/*suppressStatus=*/true); }

bool isEmpty() { return loadedPath.isEmpty() || client == nullptr; }
bool isLoaded() { return ! isEmpty(); }

void setStatus(ModelStatus newStatus)
void setStatus(ModelStatus newStatus, const String& pathContext = "")
{
status = newStatus;

if (statusMessage != nullptr)
{
statusMessage->setMessage("Model Status: " + enumToString(status));
String msg = enumToString(status);

String shortPath = pathContext.fromLastOccurrenceOf("/", false, false).trim();
if (shortPath.isNotEmpty())
msg += " | " + shortPath;

statusMessage->setMessage(msg);
}
}

void setFailure(const OpResult& result, const String& pathContext = "")
{
status = ModelStatus::FAILURE;

if (statusMessage != nullptr)
{
String errMsg = toUserMessage(result.getError());
// Keep only the first line so the status bar stays readable
String shortMsg = errMsg.upToFirstOccurrenceOf("\n", false, false).trim();
if (shortMsg.isEmpty())
shortMsg = errMsg.trim();

String shortPath = pathContext.fromLastOccurrenceOf("/", false, false).trim();
String msg = "[error] " + shortMsg;
if (shortPath.isNotEmpty())
msg += " | " + shortPath;

statusMessage->setMessage(msg);
}
}

Expand All @@ -109,7 +136,7 @@ class Model
ModelComponentInfoList getInputTracks() { return inputTrackComponents; }
ModelComponentInfoList getOutputTracks() { return outputTrackComponents; }

void resetState()
void resetState(bool suppressStatus = false)
{
metadata = ModelMetadata {};

Expand All @@ -124,7 +151,8 @@ class Model
loadedPath.clear();
openablePath.clear();

setStatus(ModelStatus::EMPTY);
if (! suppressStatus)
setStatus(ModelStatus::EMPTY);
}

OpResult load(String pathToLoad)
Expand All @@ -137,12 +165,12 @@ class Model

if (result.failed())
{
setStatus(ModelStatus::FAILURE);
setFailure(result, pathToLoad);

return result;
}

setStatus(ModelStatus::QUERYING_CONTROLS);
setStatus(ModelStatus::QUERYING_CONTROLS, pathToLoad);

// Initialize empty dictionary to hold query response
DynamicObject::Ptr controls;
Expand All @@ -152,7 +180,7 @@ class Model

if (result.failed())
{
setStatus(ModelStatus::FAILURE);
setFailure(result, pathToLoad);

return result;
}
Expand All @@ -164,7 +192,7 @@ class Model

if (result.failed())
{
setStatus(ModelStatus::FAILURE);
setFailure(result, pathToLoad);

return result;
}
Expand All @@ -177,7 +205,7 @@ class Model

if (result.failed())
{
setStatus(ModelStatus::FAILURE);
setFailure(result, pathToLoad);

return result;
}
Expand All @@ -189,28 +217,26 @@ class Model

if (result.failed())
{
setStatus(ModelStatus::FAILURE);
setFailure(result, pathToLoad);

return result;
}

resetState();
resetState(/*suppressStatus=*/true);

// Update model information if all loading operations are successful
metadata = newMetadata;
controlComponents = newControls;
inputTrackComponents = newInputs;
outputTrackComponents = newOutputs;

// Register extracted component IDs
orderedInputComponentIDs = std::move(tempComponentIDs);
// Replace existing client

client = std::move(tempClient);
// Keep track of successfully loaded path

loadedPath = pathToLoad;
openablePath = client->inferDocumentationPath(loadedPath);

setStatus(ModelStatus::READY);
setStatus(ModelStatus::READY, loadedPath);

return OpResult::ok();
}
Expand All @@ -222,7 +248,7 @@ class Model

OpResult result = OpResult::ok();

setStatus(ModelStatus::PREPARING_REQUEST);
setStatus(ModelStatus::PREPARING_REQUEST, loadedPath);

for (auto& fileEntry : inputFiles)
{
Expand All @@ -235,7 +261,7 @@ class Model

if (result.failed())
{
setStatus(ModelStatus::FAILURE);
setFailure(result, loadedPath);

return result;
}
Expand Down Expand Up @@ -331,36 +357,36 @@ class Model

DBG_AND_LOG("Model::process: Payload \"" + payloadJSON + "\" prepared for processing.");

setStatus(ModelStatus::PROCESSING);
setStatus(ModelStatus::PROCESSING, loadedPath);

result = client->process(loadedPath, payloadJSON, outputFiles, labels);

if (result.failed())
{
setStatus(ModelStatus::FAILURE);
setFailure(result, loadedPath);

return result;
}

setStatus(ModelStatus::READY);
setStatus(ModelStatus::READY, loadedPath);

return result;
}

OpResult cancel()
{
setStatus(ModelStatus::CANCELING);
setStatus(ModelStatus::CANCELING, loadedPath);

OpResult result = client->cancel(loadedPath);

if (result.failed())
{
setStatus(ModelStatus::FAILURE);
setFailure(result, loadedPath);

return result;
}

setStatus(ModelStatus::READY);
setStatus(ModelStatus::READY, loadedPath);

return OpResult::ok();
}
Expand Down
Loading
Loading