Eggington
Eggington4w ago

Saving to App State from File Input.

I am trying to create a CSV previewer in the windmill app editor (more steps later that is just step 1)... and I'm thinking my process should be that when a file is uploaded to the "file input" component, a background runnable will update state.csvContent to the decoded csv string, and then my preview text box watches state.csvContent and updates appropriately. The issue i'm encountering is that I can't seem to get state to update. In my background runnable, I have passed state as an input.
export async function main(csv_file: string, state: any) {
const decodedBytes = Uint8Array.from(atob(csv_file), c => c.charCodeAt(0));
const decoder = new TextDecoder("utf-8");
const csvContent = decoder.decode(decodedBytes);
console.log(csvContent)
state.csvContent = csvContent
console.log(state)
}
export async function main(csv_file: string, state: any) {
const decodedBytes = Uint8Array.from(atob(csv_file), c => c.charCodeAt(0));
const decoder = new TextDecoder("utf-8");
const csvContent = decoder.decode(decodedBytes);
console.log(csvContent)
state.csvContent = csvContent
console.log(state)
}
here in the background runnable, when logging state it looks good, but in the editor sidebar, it never shows any new values populating to state... and likewise my text box is not rendering anything from state.csvContent
1 Reply
Eggington
EggingtonOP4w ago
From debugging with claude - i'm learning that maybe a background runnable is not the correct option, but i'm not seeing how to create a regular runnable without it being an inline script directly attached to a component like my text component... i would think it would either be a runnable that is not directly attached to a component - that it would just watch the output of the file input, or it would be directly created as an inline script on the file input component I believe I have figured the above issue out... but i am unable to get the conditional tabs component to work properly. I have 1 condition with 2 conditional tabs, yet neither conditional tab is being rendered, even when I hardcode condition1 to be true. Is there something that must be done to map the tabs to the respective ocnditions?

Did you find this page helpful?