✨ Add work command: journal.json-based session toggle with daily folder structure - #40
Open
amy-shinsen-openclaw wants to merge 5 commits into
Open
✨ Add work command: journal.json-based session toggle with daily folder structure#40amy-shinsen-openclaw wants to merge 5 commits into
work command: journal.json-based session toggle with daily folder structure#40amy-shinsen-openclaw wants to merge 5 commits into
Conversation
gdarquie
requested changes
Jul 15, 2026
gdarquie
reviewed
Jul 15, 2026
Contributor
|
The PR description is not correct anymore, for example "src/plugins/gdarquie_work/commands/work.rs" does not exists. |
- Extract determine_work_action() pure function from work() for testability - Add 4 unit tests for determine_work_action (no event, after stop, after start, non-work event) - Add 6 unit tests for find_last_work_event (no journal, empty, start, stop, ignores CreateNot, multiple sessions)
amy-shinsen-openclaw
force-pushed
the
feat/work-command
branch
from
July 16, 2026 19:46
9aa9d29 to
1d680d3
Compare
gdarquie
reviewed
Jul 16, 2026
| /// Outcome of the work-toggle decision. | ||
| #[derive(Debug, PartialEq)] | ||
| pub enum WorkAction { | ||
| Start, |
Contributor
There was a problem hiding this comment.
why don't you use here "StartWork" and "StopWork" EventName ?
| // A non-work event (e.g. CreateNot) is treated as "still open" → stop | ||
| // (shouldn't normally appear as last work event, but defensive check) | ||
| let event = make_event(EventName::CreateNot); | ||
| assert_eq!(determine_work_action(Some(&event)), WorkAction::Stop); |
Contributor
There was a problem hiding this comment.
No, if only a non work event, it should add an event "START_WORK".
| let dir = tempdir().unwrap(); | ||
| env::set_var("NOT_PATH", dir.path().to_str().unwrap()); | ||
| // CreateNot comes after StartWork — it must be ignored; StartWork wins. | ||
| let events = vec![ |
Contributor
There was a problem hiding this comment.
Maybe we can add a warning here saying something like "You should first end the last work session before to create a new note".
- Use EventName variants in determine_work_action() match arms - Non-work event (e.g. CreateNot) as last event now starts a new session - Add warning in new_legacy() when a work session is still open - Update test for determine_work_action_after_create_not accordingly
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.
Closes #39
What this does
Adds a
workcommand (alias:w) that replaces the splitstart-work/end-workworkflow with a single toggle, using the folder-per-day file structure andjournal.jsonfor session state — not the legacy annotation system.The legacy plugin (
gdarquie_work) has been removed frommain.rs— it is no longer wired to any command. Theworkcommand now lives entirely in the coresrc/commands/module.New / changed files
src/commands/work.rsThe command itself:
initialize_project()to ensure.nost/exists.create_note_file_with_folders("work")→ creates<not_path>/year/month/week/day/YYYY-MM-DD.work.mdif absent.journal.jsonviafind_last_work_event().determine_work_action()helper, then recordsSTART_WORKorSTOP_WORK.New exports:
WorkActionenum (Start/Stop)determine_work_action(last_event: Option<&Event>) -> WorkAction— pure, easily testablesrc/events/find.rsReads
journal.jsonand returns the lastSTART_WORKorSTOP_WORKevent.src/main.rswork/wto the new command.gdarquie_workstart-work / end-work / work-stats) removed.Tests
commands::work— 4 unit tests fordetermine_work_actionStartSTOP_WORK→StartSTART_WORK→StopCreateNot) →Stop(defensive)events::find— 6 unit tests forfind_last_work_eventNoneNoneSTART_WORKentry → returns itSTART_WORKthenSTOP_WORK→ returnsSTOP_WORKCreateNotafterSTART_WORK→CreateNotis ignored,START_WORKreturnedAll 20 tests pass (
cargo test).