The array generated by the (history:) macro contains the names of each of the Passages visited by the Reader (excluding the current Passage) in the order that those passages were visited, and if a specific Passage was visited more than once then it's name will appear in the Array multiple times.
note: the rest of this explanation will be based on the following test code example, which is written in TWEE notation, the Start passage is the first passage of the project.
:: Start
:: Passage A
:: Passage B
:: Passage C
:: Links [footer]
(unless: (passage:)'s name is "View Path")[\
[[Passage A]]
[[Passage B]]
[[Passage C]]
[[View Path]]\
]
:: View Path
You have visited: {
(for: each _passagename, ...(history:))[
<br>_passagename
]}
If you view the above story and visit the passages in the order A > B > C then visit the View Path passage you should see the following output.
You have visited:
Start
Passage A
Passage B
Passage C
And if you restart the story and visit the passages in this order A > C > B > C > View Path instead then you should see the following, and notice that the Passage C passage appears multipe times in the output.
You have visited:
Start
Passage A
Passage C
Passage B
Passage C
So as you can see the order that passages were visited is maintained within the Array generated by the (history:) macro.
If you need a list of passage names that never contains a specific Passage more than once then you will need to use code like the following to generated it.
{
(set: $visited to (a:))
(for: each _passagename, ...(history:))[
(unless: $visited contains _passagename)[
(set: $visited to it + (a: _passagename))
]
]
You have visited:
(for: each _passagename, ...$visited)[
<br>_passagename
]
}
Now for the summary part of your question, and there are a number of ways you could implement this but I will expand on the method you were trying to use. The following example includes both the reducing of the History to a list of unique Passage names as well as using a named hook as the target of the generated summary.
|summary>[]
{
(set: $visited to (a:))
(for: each _passagename, ...(history:))[
(unless: $visited contains _passagename)[
(set: $visited to it + (a: _passagename))
(if: _passagename is "Passage A")[
(append: ?summary)[Passage A's associated Text<br>]
]
(else-if: _passagename is "Passage B")[
(append: ?summary)[Passage B's associated Text<br>]
]
(else-if: _passagename is "Passage C")[
(append: ?summary)[Passage C's associated Text<br>]
]
]
]
}