Tidy DemoService (move inline bot source into samples)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
- Issue type
- Refactor
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- javascript, typescript
- Domain
- backend
Research direction
Read server/src/services/DemoService.ts and the sample files in ui/public/samples; compare the existing runtime file-reading pattern in server/src/api/mcp.ts. Move the demo source into a sample file and have DemoService load it. Run server/test/sampleBots.test.ts; done means the demo reuses the sample source and the sample smoke test passes.
Written by the indexing model from the issue text.
Description
Move DemoService's inline hardcoded bot source into ui/public/samples and reuse it.
Effort: S
Migrated from TASKS.md (Later / nice to have).
Implementation notes
Priority: low — Pure internal code-tidiness refactor of the demo endpoint's hardcoded source with no user-facing behavior change and no stability/security impact.
Purpose
DemoService.getDemoEnvironment (server/src/services/DemoService.ts:19-58) hardcodes ~40 lines of bot source as a template literal set via app1.setSource(...). Moving it into ui/public/samples/*.js (already the single source of truth for sample bots, consumed by the UI's /samples/:name viewer and the MCP robocodejs://samples/{name} resource) removes duplicated/drifting bot logic from server code, keeps demo behavior editable without a server rebuild, and gets it covered by the existing sample-bot smoke test for free.
Implementation approach
- Add the demo's logic as a new file, e.g.
ui/public/samples/demo.js(orpatrol.js/similar), following the header-comment +Event.START/clock.on(Event.TICK, ...)style already used byfirstbot.js,survivor.js, etc. — clean up the rawMath.random()edge-avoidance into the same idiomatic patterns (bot.radar.onReady().then(bot.radar.scan),.catch(() => {})) other samples use. - In
server/src/services/DemoService.ts, replace the inline template literal with a file read, mirroring the existing runtime-read pattern inserver/src/api/mcp.ts(PUBLIC_DIR = path.join(__dirname, '../../public'),readPublic('samples', filename)guarded byPUBLIC_SUBDIRS) rather than re-deriving a new path scheme — consider extractingreadPublic/PUBLIC_DIRout ofmcp.tsinto a small shared util (e.g.util/publicFiles.ts) since both call sites need it. - No compiler.ts / bot-API surface changes — this is pure content relocation, not a new bot capability.
- No UI or Simulation changes required;
ui/src/util/simulate.tsandserver/src/util/simulation.tsare unaffected.
Key details to plan
- No DB/schema changes;
DemoServicestill callsapp1.setSource(...), just with file content instead of a literal — unaffected by the no-migrations gap (#142). - No REST/MCP contract changes (
/api/demo/*endpoints unchanged). - Sandbox/security: none — same trusted, server-authored source, just relocated.
- Testing: extend/rely on
server/test/sampleBots.test.ts, which alreadyfs.readdirSyncsui/public/samplesand drives every file through a real isolate +Simulation.run— the new file is automatically covered. Optionally add a smallDemoServicetest assertingsetSourcereceives non-empty content read from disk (mockfs). - Determinism/SSE/reducer: unaffected.
- Dependencies: none blocking; loosely related to the
terminology-app-vs-bot.mdsweep (samples still use bot-era naming) but not required for this issue. - Effort/risk: matches the S estimate — low risk, mechanical refactor, guarded by an existing test file.
- Dominant language
- TypeScript
- Stars
- 0
- Forks
- 0
- Avg merge
- 8m
- Merged PRs (30d)
- 8
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from LeeAdcock/robocodeJs.com
-
priority: medium tech-debt
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
LeeAdcock/robocodeJs.com#411 ·
Maintainers usually reply within 1 day
-
enhancement priority: medium
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
LeeAdcock/robocodeJs.com#254 ·
Maintainers usually reply within 1 day
-
dependencies priority: low tech-debt
Difficulty 1/5 Under an hour Newbie friendliness 15/100
LeeAdcock/robocodeJs.com#413 ·
Maintainers usually reply within 1 day
-
priority: low tech-debt
Difficulty 3/5 Half a day Newbie friendliness 32/100
LeeAdcock/robocodeJs.com#412 ·
Maintainers usually reply within 1 day
-
PR #319's 4xx health-rule change never took effect — env-level ConfigDocument shadows .ebextensionsOpenbug priority: medium tech-debt
Difficulty 4/5 Half a day Newbie friendliness 12/100
LeeAdcock/robocodeJs.com#410 ·
Maintainers usually reply within 1 day
All issues in LeeAdcock/robocodeJs.com
Similar issues
-
Add: VIVE TVOpenapproved check:passed streams:add
Difficulty 1/5 Under an hour Newbie friendliness 72/100
iptv-org/iptv#55293 · 1 comment ·
Maintainers usually reply within 1 day
-
bug needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Fission-AI/OpenSpec#2084 ·
Maintainers usually reply within 2 days
-
Contrib indemnité de départ à la retraite : faire le pont avec le simulateur sur la page génériqueOpenP1
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
SocialGouv/code-du-travail-numerique#7561 ·
Maintainers usually reply within 1 day
-
beginner bug
Difficulty 1/5 Under an hour Newbie friendliness 88/100
hiero-ledger/hiero-sdk-js#4517 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
kubernetes-sigs/headlamp#7950 ·
Maintainers usually reply within 3 days