Conversation
- A user template lived on one machine: tasks move by export and import, templates had no such path (#181). - Export masks secrets as a task's export does; a template holds no state or logs, and its tasks hold no reference to it, so nothing they did travels with it. - Import takes the file's own identifier only after the schema has checked it, so an untrusted file never names a path; an hf- identifier fails as it does on any write. - A dry run makes every check and writes nothing, so the dashboard can show what a template would run before it is saved. - An existing identifier is replaced only on request, as for tasks, and the answer names the agents and skills this machine lacks.
- A user template row offers Export, saved where the user picks as a task's export is; built-in rows offer none, since every HarmFlow ships them (#181). - Import sits beside New template. Its first click is the daemon's dry run, which shows the type and permission profile, the agents and skills this machine lacks, and for a script template the program it runs; only a second click on the same text saves it, and closing the dialog saves nothing. - The script preview is the task import's own, now exported with a banner each import words for itself: a template is not saved disabled, as an imported script task is. - An existing identifier is replaced only when the user ticks the replace option, as the task import does.
- A file written outside HarmFlow since the last scan is on disk but not in memory; its import now asks before replacing it and is announced as an update, as for a file already read. - The import's toast names the template in the interface's language, as its preview does, since a template's text can differ by language.
- The route guard test failed on main: four template routes from #180 were in the contract but not in its tables. It now sends each of the six template routes without a valid token, with a request that would write a template if the guard let it through. - The export's redaction moves to tasks.go, which already imports the event log, so user_templates.go adds no adapter import to the app layer's allowlist.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
User templates can now move between machines, as tasks already do.
Daemon and contract
GET /api/v1/templates/{templateId}/export(exportTemplate) answers a user template's file asapplication/yaml, saved as<id>.yaml. Secrets are masked as a task's export masks them.template_read_only.POST /api/v1/templates/import(importTemplate) takes bodyTemplateImportRequest{yaml,overwrite,dryRun}.metadata.id, used only once the template schema has passed, so an untrusted file never names a path.hf-identifier answers 422, and nothing is written.template_existsunlessoverwriteis set. This holds for a file not yet read by the watcher too.dryRunmakes every check, writes nothing, and answers 200 with the template as it would be saved, itsdocumentandneedsincluded.needs.missingnames each agent and skill this machine lacks, and the template is saved all the same.template.created, ortemplate.updatedwhen it replaced one.make generaterefreshedgenerated.ts.Desktop (Templates view on the Tasks screen)
TemplateImportDialog.ImportDialog.tsx, with a banner each import words for itself.Tests
app:TestExportTemplateHoldsNoSecretsLogsOrState: a template whose tasks have run, with secrets in its prompt and comments and in the runs' output. The export holds none of them and no execution ID, and it imports on another machine.TestImportTemplateNamesWhatThisMachineLacks: exported wherereview-notesexists, imported where it doesn't and a user template has the ID. Covers a refused replace (dry run too), a confirmed replace (template.updated,needs.missingnamesreview-notes), and a new ID (template.created).TestImportTemplateRejectsAnInvalidOrReservedOne: anhf-identifier (a built-in's or not), an unknown type, a non-identifier (../outside), a task file, a file that is no YAML, and empty input. Each is rejected, dry run or not, and nothing is written.TestImportScriptTemplateDryRunGivesItsProgram.httpapi:TestTemplateImportExportRoutes.tests/integration:TestAPIGuardOnEveryRoutenow lists all six template routes. It failed onmain: four routes from [Feature]: Edit, duplicate, and delete user templates #180 were missing from its tables. It passes here.TasksScreen.test.tsx:What ran (locally; Actions do not start this month)
go test -raceoninternal/app(template tests) andinternal/adapters/httpapi.internal/archtest.TestAPIGuardOnEveryRoute.pnpm -C desktop typecheck, andpnpm -C desktop test(54 files, 1100 tests).make check-generated,check-imports,check-file-names, andcheck-template-texts.make vet-daemonandgofmt -l.make coverage-daemon COVERAGE_UNIT_FLAGS=-race: it ran concurrently withmake test-desktop-daemon. Two failures were this branch's and are fixed in7ee8f5b: archtest (an adapter import inuser_templates.go) and the route guard above. The other failures were in tests this change doesn't touch, under that load:claudecode:TestSkillListThatClaudeCodeCannotGivecodex:TestDetectReadsTheAccountAndItsManagedRequirementsTestRestartEndsWhatTheScriptLeftandTestTasksRunOnTheToolsOwnSignInsapp: a 10-minute package timeout afterTestEditWhileRunningKeepsTheStartingTimeoutcoverage-daemonon its own is in progress. Its result will be added here.make test-desktop-daemonfailed one test this change doesn't touch:realDaemon.test.tsx› "a user's agent selected in the task form…", with a refused connection, under that same load. It has not been rerun alone yet.What did not run
Notes
needs-triagewhen work started. Its one open point (where the dashboard offers import and export) was answered in [Feature]: Edit, duplicate, and delete user templates #180: the Templates view on the Tasks screen.Closes #181