113 Commits

Author SHA1 Message Date
MayaTheShy
f0ca8b407e fix: ensure configuration is loaded during initialization 2026-03-29 15:10:00 -04:00
MayaTheShy
3c40cf9ef4 fix: change log level from info to debug for network message queuing and processing 2026-03-29 01:12:09 -04:00
MayaTheShy
aa5f711fe4 fix: acknowledge duplicate commands to prevent sender retries 2026-03-29 01:11:31 -04:00
MayaTheShy
5a83d89509 fix: implement reliable modem command delivery with acknowledgment and retry mechanism 2026-03-29 01:11:24 -04:00
MayaTheShy
4be2d7be8f fix: replace sleep(0) with os.pullEvent() + add diagnostic logging
sleep(0) wakes the processor only on timer ticks, causing a
1-tick delay. os.pullEvent() with no filter wakes the processor
on ANY event — including the modem_message that triggered the
capture — so items are processed in the same event cycle.

Added logging to capture and processor tasks:
- NET-CAP: logs each queued message with type and queue depth
- NET-PROC: logs each message being processed
- Both log on startup to confirm they're running
2026-03-29 00:02:07 -04:00
MayaTheShy
ec1a681924 fix: replace custom event wake-up with polling, remove craftItem double-capture
Two robustness improvements to the Network capture/processor split:

1. Processor wake-up: replaced os.queueEvent('network_queued') /
   os.pullEvent('network_queued') with sleep(0) polling. Custom events
   can be consumed by other coroutines (e.g. craftItem's unfiltered
   os.pullEvent()) or swallowed by the OS event layer. Polling the
   shared queue every tick is simpler and guaranteed reliable.

2. craftItem: removed ORDER_CHANNEL message buffering and re-queuing.
   With the dedicated Network-capture task, ORDER_CHANNEL messages are
   already safely captured into networkQueue. The old buffering caused
   double-capture: capture task adds to queue, craftItem also buffers,
   then re-queues via os.queueEvent -> capture captures again -> dup.
   The commandId dedup caught these, but removing the source is cleaner.
2026-03-28 23:40:09 -04:00
MayaTheShy
36612ecc9f fix: split Network-listener into capture/processor to prevent modem_message loss
CC:Tweaked's parallel.waitForAny drops events when a coroutine's
filter doesn't match. The old Network-listener processed commands
inline, causing it to yield with filter 'task_complete' during
peripheral calls (pushItems, list, etc). Any modem_message arriving
during that window was consumed by the scheduler and lost.

Split into two coroutines:
- Network-capture: only ever yields for 'modem_message', inserts
  into a shared networkQueue table, queues 'network_queued' event
- Network-processor: drains the queue and runs all handler logic,
  safe to yield for peripheral calls without losing messages

This fixes the ~80% message loss rate on dispense requests.
2026-03-28 23:01:14 -04:00
MayaTheShy
3c4d76d4a9 feat: improve billboard monitor detection and logging 2026-03-26 14:23:24 -04:00
MayaTheShy
c7a1b7066a feat: rename BILLBOARD_MONITOR_SIDE to BILLBOARD_MONITOR for consistency 2026-03-26 14:21:15 -04:00
MayaTheShy
8a50bc586d feat: implement billboard monitor support and remove legacy code 2026-03-26 14:16:23 -04:00
MayaTheShy
66ac81de65 feat: optimize broadcastState function to conditionally include recipe tables based on config changes 2026-03-25 22:42:45 -04:00
MayaTheShy
641a317873 feat: remove itemDB initialization and related flush calls for streamlined inventory management 2026-03-25 22:38:10 -04:00
MayaTheShy
b3a69c6797 feat: implement resilient task wrapper for parallel tasks to enhance stability 2026-03-25 21:53:47 -04:00
MayaTheShy
1606d60a06 feat: add new crafting recipes for cobblestone and stone variants; enhance auto-crafting logic for excess items 2026-03-25 18:11:23 -04:00
MayaTheShy
f327f82677 feat: implement auto-crafting feature for excess stock management 2026-03-25 18:07:26 -04:00
MayaTheShy
22836dafb2 feat: implement auto-discard feature for excess stock management 2026-03-25 17:46:18 -04:00
MayaTheShy
b9b69a4966 feat: sync disabled recipes and smelting state from client, improve broadcast logic 2026-03-22 22:31:35 -04:00
MayaTheShy
8b8279878a Fix craft dispatch: add turtle attach/detach handlers, re-scan on craft, log failures
- Add peripheral_attach handler to auto-detect crafting turtle connecting after boot
- Update peripheral_detach handler to clear craftTurtleName when turtle disconnects
- Re-scan peripherals for turtle in display.lua craft handler if none known
- Add log.warn when craft turtle check fails (was silent notification only)
- Sync ctx.craftTurtleOk from broadcastState so display.lua has current value
2026-03-22 22:26:10 -04:00
MayaTheShy
f095e18e95 fix: simplify crafting turtle detection logic by removing unnecessary method checks 2026-03-22 22:19:08 -04:00
MayaTheShy
904d4ec7f7 feat: improve modem detection logic with fallback for wireless modems and ensure channels are open 2026-03-22 22:09:28 -04:00
MayaTheShy
72c978ee75 feat: add find_item functionality to locate items in chests 2026-03-22 21:42:58 -04:00
MayaTheShy
173a0a9f95 Persist config files across Opus package updates
The Opus package manager deletes the entire package directory on
update (fs.delete(packageDir)) before re-downloading files. This
wiped all config files (.manager_config, .client_config, etc.) that
were stored inside packages/inventory-manager/.

Fix: add _configPath() helper to every program that resolves config
file paths to usr/config/inventory-manager/ when running under Opus,
which lives outside the package directory and survives updates.
Falls back to the local _path() for standalone (non-Opus) use.

Updated files:
- inventoryManager.lua, manager/config.lua, inventoryClient.lua,
  inventoryWebBridge.lua, dropperController.lua, craftingTurtle.lua
- .package install script: saves configs to usr/config/inventory-manager/
- autorun/startup.lua: checks both persistent and package dirs
- startup/client.lua: uses persistent dir for .client_setup/.dropper_config
- web/server/Dockerfile: switch health check to wget (from prior fix)
2026-03-22 20:51:31 -04:00
MayaTheShy
381951bd91 fix: clear boot window to prevent future monitor write interference 2026-03-22 19:00:39 -04:00
MayaTheShy
64b3e4b069 debug: log draw errors instead of silent pcall swallowing 2026-03-22 18:52:23 -04:00
MayaTheShy
c4acc2159e fix: prevent early return in parallel tasks from killing waitForAny
Task 12 (supply chest) and Task 13 (network) returned immediately
when not configured, which caused parallel.waitForAny to exit and
the entire program to silently stop after cache build.
2026-03-22 18:49:43 -04:00
MayaTheShy
a0740b81f5 debug: xpcall entire program body, write crash log to .crash.log
Error is now saved to disk even if the window closes instantly.
Uses xpcall with debug.traceback for full stack trace.
2026-03-22 18:47:15 -04:00
MayaTheShy
82d74a01b5 debug: wrap main() in pcall to show crash error before window closes 2026-03-22 18:44:46 -04:00
MayaTheShy
bb139b4afd fix: override dofile to preserve Opus env (require was nil in sub-modules)
CC:Tweaked dofile loads files with _G as environment, but Opus
injects require into the program's sandbox _ENV. All dofile'd
modules (especially display.lua) could not see require.

Also add dropperController to apps.db.
2026-03-22 18:40:03 -04:00
MayaTheShy
37e9b89057 feat: enhance inventory management with recursive crafting and supply chest functionality 2026-03-22 18:15:25 -04:00
MayaTheShy
d43662b2dc Refactor module loading to use dynamic base directory path 2026-03-22 16:07:33 -04:00
MayaTheShy
6760ca5e5d Refactor code structure for improved readability and maintainability 2026-03-22 11:38:41 -04:00
MayaTheShy
e1186ab532 Add remote reboot functionality via system channel 2026-03-22 03:15:47 -04:00
MayaTheShy
deeb70ba0d Buffer ORDER_CHANNEL messages in craftItem function to avoid re-queue bounce 2026-03-22 02:52:30 -04:00
MayaTheShy
7a277a86eb Enhance event handling in craftItem function and improve broadcastState function to include stateVersion 2026-03-22 02:41:36 -04:00
MayaTheShy
8ad05cdeb9 Refactor autoSmelt and autoCompost functions to use snapshots for catalogue iteration and improve command return values 2026-03-22 02:38:00 -04:00
MayaTheShy
24683f23a5 Implement idempotency for command handling to skip duplicates and enhance request processing 2026-03-22 02:12:50 -04:00
MayaTheShy
e9c0cc03f0 Implement idempotent command tracking with TTL for improved command handling 2026-03-22 02:12:08 -04:00
MayaTheShy
304e779fd0 Add log level configuration to enhance logging flexibility 2026-03-22 02:03:37 -04:00
MayaTheShy
50ec1ee6c2 Refactor main function to replace print statements with structured logging for improved debugging 2026-03-22 02:03:31 -04:00
MayaTheShy
33cad06155 Refactor main function to replace print statements with structured logging for improved clarity and debugging 2026-03-22 02:02:58 -04:00
MayaTheShy
e61a13961a Refactor touch handling to use structured logging for improved debugging 2026-03-22 02:02:19 -04:00
MayaTheShy
e017eb1009 Refactor logging to use structured logging for improved clarity and consistency 2026-03-22 02:02:15 -04:00
MayaTheShy
0e4d184059 Add structured logging functionality to inventory manager 2026-03-22 01:59:08 -04:00
MayaTheShy
39b95b3663 Refactor crafting helpers to delegate functionality to shared UI module 2026-03-22 01:56:40 -04:00
MayaTheShy
8cdb2d3b98 Refactor dashboard drawing functions to use setDrawTarget for improved clarity 2026-03-22 01:56:34 -04:00
MayaTheShy
338af14b6b Refactor drawing helpers to utilize shared UI module functions 2026-03-22 01:56:15 -04:00
MayaTheShy
50fa771ca4 Refactor touch zone functions to utilize shared UI helpers 2026-03-22 01:56:07 -04:00
MayaTheShy
4dc06184de Refactor monitor setup functions to use shared UI helpers 2026-03-22 01:55:47 -04:00
MayaTheShy
7404e73fd3 Refactor smelting and composting logic: load data tables from external files for better maintainability 2026-03-22 01:54:44 -04:00
MayaTheShy
d80b0b155e Enhance network state management: skip broadcasting if state has not changed and update state version on configuration changes 2026-03-22 01:41:44 -04:00