Skip to content

feat: cleanup main#39

Open
StefanBethge wants to merge 12 commits intoseletz:developfrom
StefanBethge:feature/cleanup-main
Open

feat: cleanup main#39
StefanBethge wants to merge 12 commits intoseletz:developfrom
StefanBethge:feature/cleanup-main

Conversation

@StefanBethge
Copy link

Summary

This PR improves the TUI in three areas:

  • visual readability and navigation feedback in the weekly grid
  • correct grouping and search handling for projects/tasks across different companies
  • cleanup of the CLI bootstrap around main

Changes

TUI visual improvements

  • wrap long project/task labels in the timesheet grid instead of truncating them too aggressively
  • highlight the full selected row while keeping the active cell distinct
  • improve readability of dense weekly views in the terminal

Closes #36

Company-aware grouping and search

  • fix the grouping logic so rows are no longer identified by project/task label alone
  • include company in the internal identity for grid rows
  • add a short company prefix to distinguish otherwise identical project/task names
  • make project/task search results company-aware as well
  • load task company information from Odoo so duplicate names across companies can be handled correctly

This fixes cases where entries like Intern / Meeting from different companies could previously collapse into a single row or become ambiguous in search.

Closes #37

Main/bootstrap cleanup

  • simplify and clean up the CLI startup/bootstrap flow
  • reduce the amount of setup logic concentrated in main
  • improve separation between config loading, dependency construction, and command wiring

Why

Before this change, the TUI had two usability problems:

  • long labels were hard to read because they were truncated
  • duplicate project/task names across companies were ambiguous and could be grouped incorrectly

This PR makes the grid easier to work with and fixes the underlying identity problem instead of only changing colors or presentation.

Closes #38

@seletz seletz changed the title Feature/cleanup main feat: cleanup main Mar 14, 2026
@seletz seletz self-requested a review March 14, 2026 16:11
Copy link
Owner

@seletz seletz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

Critical

1. Spurious --merged flag on install subcommand

cmd/config/install.go:40

The install subcommand registers a --merged flag but never reads it — this is a copy-paste from config.go. Running odoo-work-cli config install --merged silently accepts the flag and does nothing. Delete line 40.

2. os.Exit in PersistentPreRunE bypasses cleanup and cobra error handling

cmd/odoo-work-cli/main.go:38-44

PersistentPreRunE calls fmt.Println(err); os.Exit(1) instead of returning the error. This bypasses PersistentPostRun (leaking partially-initialized connections) and breaks cobra's error handling/test infrastructure. Should just return err for both the config-load and client-creation failures.

Important

3. internal/parsing imports internal/tui — wrong dependency direction

internal/parsing/times.go:7

parsing is a utility package but imports the heavy internal/tui package just for ParseWeekMonday. This pure time-calculation function belongs in parsing (or a shared package), with tui importing it — not the other way around.

4. app.Deps holds concrete *odoo.XMLRPCClient instead of odoo.Client interface

internal/app/deps.go:13

The architecture is interface-driven (odoo.Client in internal/odoo/client.go), but Deps.Client uses the concrete type, making command packages untestable without a real XML-RPC server. Fix by adding Close() to the odoo.Client interface and typing Deps.Client as odoo.Client.

5. Wrong package name in cmd/config/

cmd/config/config.go:1, cmd/config/install.go:1

Both files declare package project but live in cmd/config/. All other command packages use their directory name (package clock, package entries, etc.). Should be package config.

6. Package-level flag variables in cmd/timesheet and cmd/tui

cmd/timesheet/timesheet.go:11, cmd/tui/tui.go:10

tsWeek and tuiWeek are package-level vars for cobra flags. Other refactored packages correctly scope flag state inside CMD(). These should follow the same pattern to avoid state leaking across test runs.

@seletz
Copy link
Owner

seletz commented Mar 14, 2026

@StefanBethge could you please look into these?

@StefanBethge
Copy link
Author

@seletz i'll Do it tomorrow. Maybe you can give me access to the Claude Review Tool.

@seletz
Copy link
Owner

seletz commented Mar 14, 2026

@seletz i'll Do it tomorrow.

Cool, no stress.

Maybe you can give me access to the Claude Review Tool.

Well I simply checked out your PR and told Claude Code to do a code review. It knows how to do that. There's no integration in workflow or something-- I just told it to do a code review, looked at it locally, seemed legit. Then I told it to add these comments as my review and ask for changes ... 🤷‍♂️

@StefanBethge
Copy link
Author

@seletz now all Code Review issues, should be fixed

…`rootCmd` initialization, and modularize parsing and filtering logic.
…ing them into dedicated packages. Simplify `rootCmd` setup and reconfigure persistent pre-run logic.
…ncy injection and simplify client and config handling.
… and tests for verification. Remove unused `PersistentPreRunE` in the config command.
…ring unique identification for rows with the same project and task names across different companies. Refactor logic for row and hint key generation, improve sorting, and update tests for validation.
…functions for label wrapping and improve the rendering logic to ensure proper alignment. Add tests to validate label wrapping behavior.
…s, and totals. Add tests to verify row highlighting behavior.
…t/config handling, add dependency tests, and relocate `ParseWeekMonday` to `parsing` package.

All fixes are responses for claude code review
@StefanBethge StefanBethge force-pushed the feature/cleanup-main branch from 79462e0 to d024659 Compare March 15, 2026 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants