Skip to content

Store tab data and state files in XDG-compliant directories - #3694

Merged
hluk merged 1 commit into
masterfrom
xdg-storage-migration
Sep 7, 2026
Merged

hluk merged 1 commit into
masterfrom
xdg-storage-migration

Conversation

@hluk

@hluk hluk commented Aug 31, 2026 •

Copy link
Copy Markdown
Owner

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)

@hluk
hluk force-pushed the xdg-storage-migration branch from 16967c8 to 50305f8 Compare August 31, 2026 17:21
@codecov

codecov Bot commented Aug 31, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 70.83333% with 42 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.39%. Comparing base (0abed10) to head (282ed22).
⚠ïļ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/item/itemstore.cpp 57.14% 30 Missing ⚠ïļ
src/common/config.cpp 70.00% 9 Missing ⚠ïļ
src/app/app.cpp 72.72% 3 Missing ⚠ïļ

❌ 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.
ðŸ“Ē Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄ïļ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • ðŸ“Ķ JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ðŸŸĄ 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 (with COPYQ_LOG_DIR override) and add a new copyq info state diagnostic 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.

Comment thread src/scriptable/scriptableproxy.cpp
Comment thread src/gui/tabwidget.cpp
Comment thread src/item/itemstore.cpp
Comment thread docs/faq.rst Outdated
Comment thread src/gui/filterlineedit.cpp
@hluk
hluk force-pushed the xdg-storage-migration branch from 0147857 to 86be214 Compare September 1, 2026 10:32
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)
@hluk
hluk force-pushed the xdg-storage-migration branch from 86be214 to 282ed22 Compare September 2, 2026 14:53
@hluk
hluk merged commit df65c0c into master Sep 7, 2026
11 of 13 checks passed
@hluk
hluk deleted the xdg-storage-migration branch September 20, 2026 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CopyQ persistently stores runtime logs in $XDG_DATA_HOME Clipboard history should have a coherent storage location and support $XDG_CACHE_HOME

2 participants