# Biblatex: wrap postnote to \cite command in parentheses

I'm using biblatex with the authoryear-comp style. By default, the \cite command prints citations with no parentheses. I would like to keep this behavior while putting any postnote in parenthes following the citation, like this: See Author 2020 (postnote). For other citation commands I still want the regular punctuation (a comma, by default), e.g. \textcite should produce Author (2020, postnote) and \parencite should produce (Author 2020, postnote).

I have tried to achieve this by redefining \cite with \DeclareCiteCommand so that it doesn't call the postnote bibmacro (which inserts postnotedelim) but instead calls a new macro that wraps the argument in parenthese. But when I do this I get an undesired semicolon in front of my postnote. I can make this go away with \nopunct but I still get an undesired space, which does not go away even if I add \unspace. I don't understand where all this punctuation is coming from since I am not calling postnotedelim.

MWE:

\documentclass{article}

\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@article{myarticle,
author = {Doe, John},
year = {2020},
title = {The Title}}
\end{filecontents*}

\usepackage[style=authoryear-comp]{biblatex}

\DeclareFieldFormat{plainpostnote}{#1}

\newbibmacro{parenpostnote}{%
\iffieldundef{postnote}
{}
\printfield[plainpostnote]{postnote}}}}

\DeclareCiteCommand{\cite} %
{\usebibmacro{cite:init}%
\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\usebibmacro{cite}}
{}
{\usebibmacro{parenpostnote}}

\begin{document}
This is plain \cite[note]{myarticle} and this is text: \textcite[note]{myarticle} and this is parenthetical \parencite[note]{myarticle}.
\end{document}


Output:

Desired output: This is plain Doe 2020 (note) and this is text: Doe (2020, note) and this is parenthetical (Doe 2020, note).

Here is quick way to do that that uses that postnotedelim is context sensitive in new biblatex versions and introduces a context sensitive wrapper for the postnote field format as well.

\documentclass{article}

\usepackage[style=authoryear-comp]{biblatex}

% default postnote wrapper does nothing
\newcommand*{\postnotewrapper}[1]{#1}
% \cite postnote wrapper wraps argument in round brackets
\newcommand*{\postnotewrappercite}{\mkbibparens}

\makeatletter
% apply context-sensitive wrapper
\DeclareFieldFormat{postnote}{%
\ifcsundef{postnotewrapper\blx@delimcontext}
{\postnotewrapper}
{\csuse{postnotewrapper\blx@delimcontext}}%
{\mkpageprefix[pagination][\mknormrange]{#1}}%
}
\makeatother


The undesirable punctuation in the code from the question is caused by not using the biblatex punctuation tracker and by applying a formatting macro like \mkbibparens directly in a bibmacro. If you just write \addspace\mkbibparens{...} in a bibmacro, then the punctuation will not go via the punctuation tracker, it is printed directly. Since authoryear-comp heavily relies on the punctuation tracker you get weird results like this, because the punctuation tracker is not cleared and its contents are then printed inside the parentheses when you call \printfield.