Repository navigation
Store tab data and state files in XDG-compliant directories - #3694
Conversation
16967c8 to
50305f8
Compare
Codecov Reportâ Patch coverage is
â Your patch check has failed because the patch coverage (70.83%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## master #3694 +/- ##
==========================================
- Coverage 74.52% 74.39% -0.13%
==========================================
Files 256 256
Lines 38010 38118 +108
Branches 5122 5139 +17
==========================================
+ Hits 28328 28359 +31
- Misses 9682 9759 +77 â View full report in Codecov by Harness. ð New features to boost your workflow:
|
50305f8 to
0147857
Compare
There was a problem hiding this comment.
ðĄ Changes recommended
Migration sentinel creation and several state-writes need fixes to avoid losing state/tab data when directories are missing or a migration partially fails.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR restructures CopyQâs on-disk layout to better match XDG semantics by separating configuration, persistent data (tab/item storage), runtime state (UI state, monitor state), and logs into distinct directories, with automatic migration on first server startup.
Changes:
- Move tab data files (
*_tab_*.dat) into the data directory and UI/runtime state files into a dedicated state directory. - Relocate default log output into
state/logs(withCOPYQ_LOG_DIRoverride) and add a newcopyq info statediagnostic path. - Add first-start migration logic (rename with cross-device copy+delete fallback) and update docs/tests accordingly.
File summaries
| File | Description |
|---|---|
| src/tests/tests_drag_n_drop.cpp | Update tests to use new tab-data and state file paths. |
| src/scriptable/scriptableproxy.cpp | Store clipboard monitor ârunningâ state in the state directory. |
| src/platform/win/winplatform.cpp | Set CopyQ_state_path for Windows portable mode initialization. |
| src/item/serialize.h | Remove itemDataPath() declaration from serialize API surface. |
| src/item/serialize.cpp | Move itemDataPath() dependency to common config. |
| src/item/itemstore.h | Declare migration entrypoint for data/state/log files. |
| src/item/itemstore.cpp | Save tab data in data dir; add migration logic and helpers. |
| src/gui/tabwidget.cpp | Move collapsed tabs/counters persistence to state directory. |
| src/gui/tabicons.cpp | Scan tab data files in the new tab-data base directory. |
| src/gui/mainwindow.cpp | Use configuration-only path helper for commands ini. |
| src/gui/geometry.cpp | Move geometry/state persistence to state directory. |
| src/gui/filterlineedit.cpp | Persist filter history to state directory. |
| src/gui/actiondialog.cpp | Persist action dialog history to state directory. |
| src/common/server.cpp | Use configuration-only path helper for lock file path. |
| src/common/log.cpp | Default log directory to state/logs (unless overridden). |
| src/common/encryption.cpp | Ensure encryption material remains in configuration directory. |
| src/common/diagnostics.cpp | Add state to copyq info path identifiers. |
| src/common/config.h | Introduce statePath/stateFilePath, tab base path, and itemDataPath helpers. |
| src/common/config.cpp | Implement XDG state path logic and new path helpers. |
| src/common/commandstore.cpp | Switch commands ini path helper to configuration-only. |
| src/app/clipboardserver.cpp | Trigger migration on first server startup. |
| src/app/app.cpp | Set defaults for item data (AppLocalDataLocation/items) and state path (XDG state). |
| plugins/itemencrypted/itemencrypted.cpp | Ensure GPG keyring files still derive from config path. |
| docs/sessions.rst | Document new data/state/log locations and migration behavior. |
| docs/scripting-api.rst | Document new info('state') identifier. |
| docs/faq.rst | Update FAQ to reflect split config/data/state directories. |
| docs/backup.rst | Update backup guidance for config/data/state split. |
| AGENTS.md | Add COPYQ_STATE_PATH to the recommended env list for builds/tests. |
Review details
Suppressed comments (1)
src/gui/actiondialog.cpp:136
ActionDialog::saveHistory()persists history to a state file but doesn't ensure the state directory exists before opening the file. This can make history saving fail when the state directory hasn't been created yet.
return stateFilePath("_cmds.dat");
}
void ActionDialog::saveHistory()
{
- Files reviewed: 28/28 changed files
- Comments generated: 5
- Review effort level: Lite
ðĄ Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
0147857 to
86be214
Compare
Move tab item data files (`_tab_*.dat`) to the data directory and UI state files (geometry, collapsed tabs, filter history, action history, monitor state) to the state directory. Log files move to a `logs` subdirectory of the state directory. Only actual configuration (`copyq.ini`, commands, encryption keys) remains in the config directory. Default paths on Linux: - Config: `~/.config/copyq` - Data: `~/.local/share/copyq` - State: `~/.local/state/copyq` (follows `$XDG_STATE_HOME`) On Windows, data and state move from `%APPDATA%` (roaming) to `%LOCALAPPDATA%` (local). On macOS, data and state use `~/Library/Application Support`. Windows portable mode is unchanged. Existing files are automatically migrated on first server startup, with a cross-device copy+delete fallback. New environment variables: `COPYQ_STATE_PATH`, `COPYQ_LOG_DIR`. New diagnostic path: `copyq info state`. Fixes #3692 Fixes #3693 Assisted-by: Claude (Anthropic)
86be214 to
282ed22
Compare
Move tab item data files (
_tab_*.dat) to the data directoryand UI state files (geometry, collapsed tabs, filter history,
action history, monitor state) to the state directory. Log files
move to a
logssubdirectory of the state directory.Only actual configuration (
copyq.ini, commands, encryption keys)remains in the config directory.
Default paths on Linux:
~/.config/copyq~/.local/share/copyq~/.local/state/copyq(follows$XDG_STATE_HOME)On Windows, data and state move from
%APPDATA%(roaming) to%LOCALAPPDATA%(local). On macOS, data and state use~/Library/Application Support. Windows portable mode is unchanged.Existing files are automatically migrated on first server startup,
with a cross-device copy+delete fallback.
New environment variables:
COPYQ_STATE_PATH,COPYQ_LOG_DIR.New diagnostic path:
copyq info state.Fixes #3692
Fixes #3693
Assisted-by: Claude (Anthropic)